0

我在菠菜回购中遵循了自述文件,并包括菠菜导轨而不是基本菠菜宝石。

菠菜文档指出:

# 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 类时,我可以看到两个命中 - 一个是“基础”类,另一个是水豚版本:

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 和菠菜一起工作?

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

静态文件的默认 spring-boot 路径是一个名为static的文件夹,保存在src/main/resources中。请参阅 spring文档示例

4

0 回答 0