Module: RSpec::Eth::HelperMethods

Defined in:
lib/rspec/eth/helper_methods.rb

Instance Method Summary collapse

Instance Method Details

#accountsObject



18
19
20
21
22
23
# File 'lib/rspec/eth/helper_methods.rb', line 18

def accounts
  @accounts ||= begin
    accounts_data = File.read(RSpec::Eth::Config.)
    JSON.parse(accounts_data)['addresses'].keys
  end
end

#clientObject



6
7
8
9
10
# File 'lib/rspec/eth/helper_methods.rb', line 6

def client
  @client ||= begin
    Ethereum::HttpClient.new("http://#{RSpec::Eth::Config.host}:#{RSpec::Eth::Config.port}")
  end
end

#contractObject



12
13
14
15
16
# File 'lib/rspec/eth/helper_methods.rb', line 12

def contract
  @contract ||= begin
    Ethereum::Contract.create(file: contract_path, client: client)
  end
end

#contract_pathObject



25
26
27
28
29
30
# File 'lib/rspec/eth/helper_methods.rb', line 25

def contract_path
  @contract_path ||= begin
    filename = self.class.[:file_path].split('/').last.gsub('_spec', '').gsub('.rb', '')
    File.join(RSpec::Eth::Config.contracts_path, "#{filename}.sol")
  end
end