small medium large xlarge

Generic-user-small
31 Jul 2014, 09:15
Richard Donovan (1 post)

According to 2.7 Adding an Assertion I need to create a blank calc.rb file (which I have put in the calculator dir. When I run cucumber again I get the same output as before -

C:\Users\466368\calculator>cucumber Feature: Adding

Scenario: Add two numbers # features\feature_file_adding.feature:3 Given the input “2+2” # features/step_definitions/calculator_steps.rb:1 When the calculator is run # features/step_definitions/calculator_steps.rb:5 undefined method success?' for nil:NilClass (NoMethodError) ./features/step_definitions/calculator_steps.rb:7:in /^the calculator is run$/’ features\feature_file_adding.feature:6:in `When the calculator is run’ Then the outut should be “4” # features/step_definitions/calculator_steps.rb:10

Failing Scenarios: cucumber features\feature_file_adding.feature:3 # Scenario: Add two numbers

1 scenario (1 failed) 3 steps (1 failed, 1 skipped, 1 passed) 0m0.120s

And when I run it as cucumber –format progress, I get this -

C:\Users\466368\calculator>cucumber –format progress .F-

(::) failed steps (::)

undefined method success?' for nil:NilClass (NoMethodError) ./features/step_definitions/calculator_steps.rb:7:in /^the calculator is run$/’ features\feature_file_adding.feature:6:in `When the calculator is run’

Failing Scenarios: cucumber features\feature_file_adding.feature:3 # Scenario: Add two numbers

1 scenario (1 failed) 3 steps (1 failed, 1 skipped, 1 passed) 0m0.101s

C:\Users\466368\calculator>

At this point I should have 2 tests pass and 1 pending. What have I done wrong..?

Avatar_pragsmall
01 Sep 2014, 20:39
Matt Wynne (87 posts)

Hi,

Can you show me the code for your file features/step_definitions/calculator_steps.rb please?

It sounds as though you have a typo in there somewhere.

Generic-user-small
02 Oct 2015, 01:29
Aya Seit (1 post)

Oh, I’m stuck on the same issue, could please anyone help me to go further?

Given(/^the input "([^"]*)"$/) do |input|
  @input = input
end

When(/^the calculator is run$/) do
  @output = 'ruby calc.rb #{input}'
  raise('Command failed!') unless $?.success?
end

Then(/^the output should be "([^"]*)"$/) do |expected_output|
  @output.should == expected_output
end

Generic-user-small
02 Nov 2015, 22:36
Alan D. Frank (1 post)

Hi Matt, I have the same issue trying to step through the calculator example in chapter 2.

You must be logged in to comment