什么是黄瓜#source_tag?

时间:2012-02-20 02:40:17

标签: ruby-on-rails cucumber rake

我遇到黄瓜这个问题的时候。这就是一切。

我的Gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.1'

gem 'pg'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

group :test do 
  gem 'rspec-rails'
  gem 'factory_girl_rails'
  gem 'cucumber-rails'
  gem 'database_cleaner'
  gem 'capybara'
end

特征测试

Feature: Requesting invitations
  As a visitor
  I want to request a beta invitation
  So I can be sent an invitation when the site is ready

  Scenario: Requesting an invitation
    Given I am on the homepage
    When I request and invitation for "foo@example.com"
    Then I should see "Your on the list" confirmation

错误输出

    Feature: Requesting invitations
      As a visitor
      I want to request a beta invitation
      So I can be sent an invitation when the site is ready

      Scenario: Requesting an invitation
        Given I am on the homepage
        When I request and invitation for "foo@example.com"
        Then I should see "Your on the list" confirmation

rake cucumber:ok
/Users/node/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -S bundle exec cucumber  --profile default
Using the default profile...
Feature: Requesting invitations
  As a visitor
  I want to request a beta invitation
  So I can be sent an invitation when the site is ready

  Scenario: Requesting an invitation                    # features/requesting_invitations.feature:6
Deprecated: please use #source_tags instead.
    Given I am on the homepage                          # features/requesting_invitations.feature:7
      Undefined step: "I am on the homepage" (Cucumber::Undefined)
      features/requesting_invitations.feature:7:in `Given I am on the homepage'
    When I request and invitation for "foo@example.com" # features/requesting_invitations.feature:8
      Undefined step: "I request and invitation for "foo@example.com"" (Cucumber::Undefined)
      features/requesting_invitations.feature:8:in `When I request and invitation for "foo@example.com"'
    Then I should see "Your on the list" confirmation   # features/requesting_invitations.feature:9
      Undefined step: "I should see "Your on the list" confirmation" (Cucumber::Undefined)
      features/requesting_invitations.feature:9:in `Then I should see "Your on the list" confirmation'

1 scenario (1 undefined)
3 steps (3 undefined)
0m0.967s

You can implement step definitions for undefined steps with these snippets:

Given /^I am on the homepage$/ do
  pending # express the regexp above with the code you wish you had
end

When /^I request and invitation for "([^"]*)"$/ do |arg1|
  pending # express the regexp above with the code you wish you had
end

Then /^I should see "([^"]*)" confirmation$/ do |arg1|
  pending # express the regexp above with the code you wish you had
end

rake aborted!
Command failed with status (1): [/Users/node/.rvm/rubies/ruby-1.9.2-p290/bi...]

Tasks: TOP => cucumber:ok
(See full trace by running task with --trace)

因此,当我运行此rake任务时,由于某种原因你可以看到它正在崩溃。当我运行'rake cucumber'时我得到同样的东西我不知道#source_tag是什么,并且无法找到它的文档。我该如何解决这个问题并删除错误?我认为这是一个非常直接的场景。宝石列表给出:

cucumber (1.1.8)
cucumber-rails (1.3.0)

感谢。欢迎任何帮助。

2 个答案:

答案 0 :(得分:3)

#source_tag警告真正适用于水豚开发者。水豚是黄瓜铁路的依赖。

提示,这是修剪Gemfile的好时机......每一点都有帮助。

cucumber github issues

中所示
  

实际上,弃用警告旨在向Capybara开发人员展示,因此您作为Cucumber用户看到它是没有意义的。我想我们应该完全删除弃用警告,除非有人能想到一个聪明的机制,只有在他们运行测试时才向Capybara devs显示它。 @aslakhellesoy @joliss @jnicklas WDYT?

...

  

Cucumber 1.1.9已经发布,删除了警告。

tl; dr 升级到cucumber> = 1.1.9,#source_tag分心会消失。

答案 1 :(得分:0)

我不确定'source_tags'消息的含义,但它是一个警告而不是一个错误。真正的问题似乎是Cucumber没有找到任何步骤定义。您需要编写步骤定义,Cucumber应该为您提供开始的代码 - 它通常会在结果摘要后立即打印“片段”。

相关问题