I am new to Ruby and couldn't get any help from answers here, because code level seems pretty advance here:
I have created a step_definitions like this:
Then(/^I should see "([^"]*)" as the name for line item (.*)$/) do |puppy_name, line_item|
@cart.name_for_line_item line_item
end
where method name_for_line_item
takes only one argument ie line_item
but in above step_definition I have to verify the puppy_name
I am passing.
So I tried:
@cart.name_for_line_item.should include puppy_name line_item
but this is red line of error under the method and
if I try
@cart.name_for_line_item line_item .should include puppy_name
it give compile time error:
RSpec::Expectations::ExpectationNotMetError
Source: Cucumber and Cheese by Jeff Morgan
You should use parenthesis :
(@cart.name_for_line_item(line_item).should).include? puppy_name
Latest version of rspec allow another syntax :
expect(@cart.name_for_line_item(line_item)).to include(puppy_name)
Link to rspec documentation : https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.