未定义的方法`expect'用于#<菠菜::特征

时间:2015-09-10 19:48:34

标签: ruby-on-rails ruby capybara bdd spinach

=“”

我在菠菜回购中遵循README以及包括菠菜 - 导轨而不是基础菠菜宝石。

Spinach文档声明:

# When using Capybara, you can switch the driver to use another one with
# javascript capabilities (Selenium, Poltergeist, capybara-webkit, ...)
#
# Spinach already integrates with Capybara if you add
# `require spinach/capybara` in `features/support/env.rb`.

我做过的事:

我的env.rb文件负责人:

require 'spinach-rails'
require 'spinach/capybara'

ENV['RAILS_ENV'] = 'feature'

require 'rspec'
require 'factory_girl_rails'
require 'webmock'
require 'coffee_script'

include WebMock::API

WebMock.disable_net_connect!(:allow_localhost => true)

require_relative '../../config/environment'

测试失败的步骤是:

  step 'I see the Generals Page' do
    expect(page).to have_content("Inventory")
  end

当我使用RubyMine检查Spinach :: FeatureSteps类时,我可以看到两个命中 - 一个到“base”类,另一个到capybara版本:

require 'capybara'
require 'capybara/dsl'
require 'rbconfig'
require 'spinach/config'
require_relative 'feature_steps'

module Spinach
  class FeatureSteps
    # Spinach's capybara module makes Capybara DSL available in all features.
    #
    # @example
    #   require 'spinach/capybara'
    #   class CapybaraFeature < Spinach::FeatureSteps
    #     Given "I go to the home page" do
    #       visit '/'
    #     end
    #   end
    #
    module Capybara
      include ::Capybara::DSL

这真的让菠萝配置中应该有一种切换,让我选择在我的测试中使用capybara DSL。

但它似乎没有正常工作。

如何让Capybara与Spinach合作?

Gemfile.lock的:

spinach (0.8.10)
      colorize
      gherkin-ruby (>= 0.3.2)
      json
    spinach-rails (0.2.1)
      capybara (>= 2.0.0)
      railties (>= 3)
      spinach (>= 0.4)

Gemfile中的测试和功能组:

group :test, :feature do
  gem "factory_girl_rails"
  gem "capybara"
  gem "webmock"
  gem "capybara-webkit"
  gem "spinach-rails"
end

0 个答案:

没有答案