Question

My IronRuby install of the rspec gem seems to be lacking the automated be_* method helpers. For instance, the following code generates an undefined method error:

require 'rubygems'
require 'rspec'

x = 7
x.should == 7 # works
x.nonzero?.should == 7 #works
x.should be_nonzero # undefined method `be_nonzero' for main:Object

I used igem to install the rspec gem. Here is the list of my installed gems:

bewildr (0.1.14)
builder (3.0.0)
cucumber (0.6.3)
diff-lcs (1.1.3)
iron-term-ansicolor (0.0.3)
json_pure (1.7.3)
polyglot (0.3.3)
rspec (2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.1)
rspec-mocks (2.11.1)
term-ansicolor (1.0.7)
treetop (1.4.10)

Any idea what I am missing here?

Was it helpful?

Solution

RSpec matchers are generally only available in an it block, in order to avoid polluting the global namespace. Have you tried running your code on a different Ruby implementation? You'll get the same error.

OTHER TIPS

I had same problem but your post inspired me to do some research. I've found solution here: https://github.com/cucumber/cucumber/wiki/RSpec-Expectations In short in my "features\support\env.rb" I have added this:

require 'rspec/expectations'
World(RSpec::Matchers)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top