黄瓜测试失败

时间:2014-10-01 16:54:29

标签: ruby ruby-on-rails-3.2 cucumber

我是铁杆和黄瓜的新手,我正试图让黄瓜情景通过。
这是我的write_profile.feature文件:

Feature: Write profile
As a profile owner
I can write new profile

Scenario Outline: Write profile
  Given I am on the login page
  When I fill "<email>" as Email
  When I fill "<password>" as Password
  When I click "<btn>" button
  Then I should be on the <page_name> page
# When I click "<btn>" button
# Then I should see "Success"
Examples:
| email                | password   | btn    | page_name |
| admin@mysite.com     | secret     | Log in | profiles  |

这是我的profile_steps.rb

Given(/^I am on the login page$/) do
  visit "http://localhost:3000"
end

When /^I fill "(.*?)" as Email$/ do |email|
  @email = email
  fill_in "Email", :with => email
end
When /^I fill "(.*?)" as Password$/ do |password|
  fill_in "Password", :with => password
end
When /^I click "(.*?)" button$/ do |btn|
  click_button btn
end

Then /^I should be on the (.+?) page$/ do |page_name|
  request.request_uri.should == send("#{page_name.downcase.gsub(' ','_')}_path")
  response.should be_success
end

Then /^I should be redirected to the (.+?) page$/ do |page_name|
  request.headers['HTTP_REFERER'].should_not be_nil
  request.headers['HTTP_REFERER'].should_not == request.request_uri

  Then "I should be on the #{page_name} page"
end


Then /^I should see the "Success"/ do
  page.should have_content("Success")
end

以下是运行测试的输出:

    Using the default profile...
Feature: Write profile
  As a profile owner
  I can write new profile

  Scenario Outline: Write profile            # features/write_profile.feature:5
    Given I am on the login page             # features/step_definitions/profile_steps.rb:1
    When I fill "<email>" as Email           # features/step_definitions/profile_steps.rb:5
    When I fill "<password>" as Password     # features/step_definitions/profile_steps.rb:9
    When I click "<btn>" button              # features/step_definitions/profile_steps.rb:12
    Then I should be on the <page_name> page # features/step_definitions/profile_steps.rb:16

    #    When I click "<btn>" button
    #    Then I should see "Success"
    Examples: 
      | email               | password | btn    | page_name |
      |[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
 admin@mysite.com | secret   | Log in | profiles  |
      wrong number of arguments (0 for 1..2) (ArgumentError)
      ./features/step_definitions/profile_steps.rb:17:in `/^I should be on the (.+?) page$/'
      features/write_profile.feature:10:in `Then I should be on the <page_name> page'

Failing Scenarios:
cucumber features/write_profile.feature:5 # Scenario: Write profile

1 scenario (1 failed)
5 steps (1 failed, 4 passed)
0m0.137s

我想知道为什么我得到关于1 ... 2参数的0的错误,以及如何使失败的测试通过。非常感谢任何帮助。

0 个答案:

没有答案