【问题标题】:What is a cucumber #source_tag ?什么是黄瓜 #source_tag ?
【发布时间】:2012-03-10 11:09:24
【问题描述】:

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

我的宝石文件

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)

谢谢。欢迎任何帮助。

【问题讨论】:

标签: ruby-on-rails cucumber rake


【解决方案1】:

#source_tag 警告实际上是针对水豚开发者的。 Capybara 是 cucumber-rails 的依赖项。

提示,现在是精简 Gemfile 的好时机……每一点都有帮助。

cucumber github issues中所见

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

...

Cucumber 1.1.9 已发布,删除警告。

tl;dr 升级到 cucumber >= 1.1.9,#source_tag 干扰就会消失。

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2011-09-15
      • 1970-01-01
      • 1970-01-01
      • 2020-06-04
      • 1970-01-01
      • 2017-06-27
      • 2015-05-04
      • 1970-01-01
      • 2018-05-04
      相关资源
      最近更新 更多