04 Jan 2013, 08:43
20120621_115648_pragsmall

Rahul Panjiyar (6 posts)

while running the same code as there, i stucked on “I’m empty!” (Runtime error). as no value is passes to contents so it raises the message. Please define me the solution of that.

04 Jan 2013, 20:05
Avatar_pragsmall

Matt Wynne (87 posts)

Hi Rahul

It’s hard to advise without looking at the code. Could you put the code that you have, exactly as you have it, on a gist or github project, then someone can try to reproduce your issue?

07 Jan 2013, 06:21
20120621_115648_pragsmall

Rahul Panjiyar (6 posts)

#nice_bank.rb
class CashSlot
  def contents
    @contents  or raise("I'm empty!")
  end
  
  def dispense(amount)
    @contents = amount
  end
end

#cash_slot.rb

Then /^(#{CAPTURE_CASH_AMOUNT}) should be dispensed$/ do |amount|

  cash_slot = CashSlot.new
  cash_slot.contents.should == amount
end
07 Jan 2013, 13:25
Avatar_pragsmall

Matt Wynne (87 posts)

Hi Rahul,

The code in the step definition is wrong. You need to use the @KnowsTheDomain@ World module exactly as in the code samples. Specifically, you should not be creating a new instance of @CashSlot@ in your step def.

I’d suggest downloading the example code and comparing that with what you have.

  You must be logged in to comment