0

本「The Cucumber Book」の電卓プロジェクトでステップ 2 を実行しようとしています。このフォームで提供された以前の回答に従って、一重引用符の代わりにバックトリックを使用しようとしましたが、以下の同じエラーメッセージが引き続き表示されます。

.F-

(::) failed steps (::)

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

Failing Scenarios:
cucumber features/adding.feature:3 # Scenario: Add two numbers

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

これは、以前にフォーラムで見つけた正確な手順情報です。

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 |arg1|
  pending # express the regexp above with the code you wish you had
end

私は何が間違っている可能性がありますか?

4

1 に答える 1

0

calc.rb:

#!/usr/bin/env ruby

# install bc with 'sudo apt-get install bc'

if ARGV.size > 0
    command='echo ' +  ARGV.join('') + ' | bc'
    exec(command)
end
...
Now my cucumber output looks like:
auser@worker1:~/cucumber/calculator# cucumber
Feature: Adding

  Scenario: Add two numbers       # features/adding.feature:2
    Given the input "2+2"         # features/step_definitions/calculator_steps.rb:1
    When the calculator is run    # features/step_definitions/calculator_steps.rb:5
    Then the output should be "4" # features/step_definitions/calculator_steps.rb:10

1 scenario (1 passed)
3 steps (3 passed)
0m0.021s
于 2013-10-06T06:22:31.430 に答える