0

I've followed the README at the spinach repo as well as including spinach-rails instead of the base spinach gem.

Spinach documentation states:

# 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`.

Which I have done:

Head of my env.rb file:

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'

The step failing in the test reads:

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

When I inspect the Spinach::FeatureSteps class using RubyMine I can see two hits - one to the "base" class and the other to the capybara version:

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

Which really makes it seem like there should be a switch of sorts in the spinach configuration that lets me choose to use the capybara DSL in my tests.

But it doesn't appear to be working properly.

How can I get Capybara working with 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)

test and feature group in Gemfile:

group :test, :feature do
  gem "factory_girl_rails"
  gem "capybara"
  gem "webmock"
  gem "capybara-webkit"
  gem "spinach-rails"
end
notaceo
  • 1,093
  • 10
  • 28
  • You need to include `RSpec::Matchers` or require `rspec` before `spinach` see this [Closed Git Hub Issue](https://github.com/codegram/spinach/issues/87) – engineersmnky Sep 10 '15 at 20:07
  • @engineersmnky - manually sending the include in env.rb makes the matchers work - I think according to that link I'm no longer supposed to _have_ to do this, but there must be some newer conflict rendering that PR invalid for my situation. It works - so perhaps post it as an answer and I'll accept. – notaceo Sep 10 '15 at 20:38

0 Answers0