I'm using rspec expectations in a cucumber framework and they look fine when used at the steps definition level.
I've configured my env.rb file with:
require 'rspec/expectations'
World(RSpec::Matchers)
The problem I've noticed now is that if I try to use rspec inside a method of an object that's used inside one of the steps then I've got a failure.
E.g.
Steps_definition.rb
service.use_rspec
class Service
def use_rspec
header = page.find("div#services h2").text
header.should (be 'TV')
end
end
Error after execution:
undefined method `be' for #<Service:0x2592570> (NoMethodError)
Any idea where the problem could be?
I've tried a similar assertion with Capybara.page.find(...).should have_content('...') inside that class and 'have_content' is not recognized either, so not really sure what's going on :S
Many thanks for any tip!