Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何在Cucumber中指定路径_Ruby On Rails_Cucumber - Fatal编程技术网

Ruby on rails 如何在Cucumber中指定路径

Ruby on rails 如何在Cucumber中指定路径,ruby-on-rails,cucumber,Ruby On Rails,Cucumber,我已在“spree\u fit\u卡/新礼品卡”中设置了此黄瓜功能。功能: @gift-card Feature: access gift cards As a general user I will be able to place an order for a gift card Scenario: The gift card index page will redirect to /new When I am on the gift card page The

我已在“spree\u fit\u卡/新礼品卡”中设置了此黄瓜功能。功能:

@gift-card
Feature: access gift cards
  As a general user
  I will be able to place an order for a gift card

  Scenario: The gift card index page will redirect to /new
    When I am on the gift card page
    Then I will be redirected to the new gift card page
支持/path.rb
中:

module NavigationHelpers
  def path_to(page_name)
    when /the gift card page/
      spree.gift_cards_path
    when /the new gift card page/
      spree.new_gift_card_path
    else
      ...
    end
  end
end
When(/^I am on the gift card page$/) do
  pending
end

Then(/^I will be redirected to the new gift card page$/) do
  pending
end
当我们签出
step\u definitions/new\u gift\u card\u steps.rb

module NavigationHelpers
  def path_to(page_name)
    when /the gift card page/
      spree.gift_cards_path
    when /the new gift card page/
      spree.new_gift_card_path
    else
      ...
    end
  end
end
When(/^I am on the gift card page$/) do
  pending
end

Then(/^I will be redirected to the new gift card page$/) do
  pending
end
黄瓜产量:

$ zeus cucumber --tags @gift-card
Loading fixtures
Using the default profile...
@gift-card
Feature: access gift cards
  As a general user
  I will be able to place an order for a gift card

  Scenario: The gift card page will redirect to the new gift card page # features/spree_gift_card/new_gift_card.feature:6
    When I am on the gift card page                                 # features/spree_gift_card/new_gift_card.feature:7
      Ambiguous match of "I am on the gift card page":

      features/step_definitions/spree_gift_card/new_gift_cards_steps.rb:1:in `/^I am on the gift card page$/'
      cucumber-websteps-0.10.0/lib/cucumber/websteps/browsing_steps.rb:1:in `/^(?:|I )am on (.+)$/'

      You can run again with --guess to make Cucumber be more smart about it
       (Cucumber::Ambiguous)
      -e:1:in `<main>'
      features/spree_gift_card/new_gift_card.feature:7:in `When I am on the gift card page'
    Then I will be redirected to the new gift card page              # features/step_definitions/spree_gift_card/new_gift_cards_steps.rb:5

Failing Scenarios:
cucumber features/spree_gift_card/new_gift_card.feature:6 # Scenario: The gift card page will redirect to the new gift card page

我很高兴它通过了
——猜猜看
,但我不明白为什么它没有通过就不能通过。我想我把它设置好了,但我显然没有。如果Ruby on Rails版本3.2.17有帮助,我将使用该框架。

原因可以从您给出的错误中找到:

cucumber-websteps-0.10.0/lib/cucumber/websteps/browsing_steps.rb:1:in `/^(?:|I )am on (.+)$/'

显示在浏览_steps.rb中有一个“默认”步骤,它也与您的测试匹配。这就是为什么会出现这个错误的原因。正如您所看到的,匹配比您的步骤“少”,这就是“猜测”起作用的原因:它会自动选择“最适合”的步骤定义。

我的回答对您的问题有帮助吗?