{"id":16941758,"url":"https://github.com/thesmartnik/rspec-eth","last_synced_at":"2025-04-11T19:32:41.832Z","repository":{"id":56892857,"uuid":"475932078","full_name":"TheSmartnik/rspec-eth","owner":"TheSmartnik","description":"RSpec extension that allows to easily test solidity smart contracts","archived":false,"fork":false,"pushed_at":"2023-04-23T22:44:42.000Z","size":16,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T15:21:19.360Z","etag":null,"topics":["ethereum","rspec","solidity-contracts"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheSmartnik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-30T15:06:59.000Z","updated_at":"2023-04-23T22:45:03.000Z","dependencies_parsed_at":"2024-10-20T02:53:44.531Z","dependency_job_id":"d7bff86c-bf8f-400d-8736-5ca0f7b6fa79","html_url":"https://github.com/TheSmartnik/rspec-eth","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"f88a648cd1e4d72492d168a61419081cd3c925c1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheSmartnik%2Frspec-eth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheSmartnik%2Frspec-eth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheSmartnik%2Frspec-eth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheSmartnik%2Frspec-eth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheSmartnik","download_url":"https://codeload.github.com/TheSmartnik/rspec-eth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248467122,"owners_count":21108599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ethereum","rspec","solidity-contracts"],"created_at":"2024-10-13T21:10:15.308Z","updated_at":"2025-04-11T19:32:41.802Z","avatar_url":"https://github.com/TheSmartnik.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RSpec::Eth\n\nRSpec extension that allows to easily test solidity smart contracts.\n\n## What it does\n\n* Spins up ganache server for tests\n* Adds a few handy methods to ease testing of solidity contracts in ruby main ones:\n    1. `contract` to access contract\n    2. `accounts` to access addresses used by ganache\n\nIt's build on top of [etherium.rb](https://github.com/EthWorks/ethereum.rb). For documentation on how to interact with etherium blockchain please refer to its documentation\n\n## Example Usage\nGiven a simple [Greeter contract](https://github.com/TheSmartnik/rspec-eth/blob/master/contracts/simple_greeter.sol). Here is an example of basic spec\n\n```ruby\nRSpec.describe 'SimpleGreeter', type: :smart_contract do\n  before { contract.deploy_and_wait }\n\n  it 'sets greeting' do\n    expect(contract.call.greet).to eq(\"Hello, World!\")\n  end\n\n  it 'changes message' do\n    contract.transact_and_wait.set_super_greeting(\"Yo\")\n\n    expect(contract.call.greet).to eq(\"Yo\")\n  end\n\n  context 'when sender not owner' do\n    before { contract.sender = accounts[1] }\n\n    it 'trying to set not from owner' do\n      expect {\n        contract.transact_and_wait.set_super_greeting(\"Yo\")\n      }.to raise_exception(IOError, \"VM Exception while processing transaction: revert Only owner\")\n    end\n  end\nend\n```\n\n## Installation\n\n### Prerequisite\n\n1. Install ganache-cli\n```\nnpm install -g ganache-cli\n```\n2. [Install solidity compilier](https://docs.soliditylang.org/en/v0.8.9/installing-solidity.html)\n```\nbrew install solidity\n```\n\n3. Add gem to a Gemfile\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'rspec-eth'\n```\n\n4. Require extension in `spec_helper.rb` or `rails_helper.rb`\n```\nrequire 'rspec/eth'\n```\n\n## Configuration\n\n`RSpec::Eth` provides a few configuration option that you probably won't need\n\n```ruby\n# spec_helper.rb\n\nRSpec::Eth.configure do |config|\n  config.account_keys_path = temp_path # Path for accounts created\n  config.host = '127.0.0.1' # Host of ganache server\n  config.port = '8545' # Port of ganache server\n  config.contracts_path = 'contracts'# Set paths for your contracts\nend\n\n```\n\n\n## Development\n\nAfter checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec rspec` to run the tests.\n\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/TheSmartnik/rspec-eth.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthesmartnik%2Frspec-eth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthesmartnik%2Frspec-eth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthesmartnik%2Frspec-eth/lists"}