running
rake cucumber
passes even untested features. while running
cucumber features/something.feature
throws
undefined method `visit' for #<Object:0x00000001b13950> (NoMethodError)
I have googled some github issues where they talk about it but to no relief. This Running Capybara without rack produces errors when using url parameters was helpful but didn't resovle my issue
UPDATE I did touch on the following from capybara readme
Using Capybara with Cucumber
The cucumber-rails gem comes with Capybara support built-in. If you are not using Rails, manually load the capybara/cucumber module:
require 'capybara/cucumber' Capybara.app = MyRackApp
But in which file to include the above? I tried adding the above to env.rb and got this error:
uninitialized constant ActionController (NameError)
Now after commenting it, I still get the same error.
Here is the gemfile:
source 'https://rubygems.org'
#add dependency
gem 'diff-lcs', ">= 1.2.0"
gem 'rspec-expectations', "~> 3.0.0"
#add cucumber
group :test do
gem 'cucumber-rails', :require => false
# database_cleaner is not required, but highly recommended
#gem 'database_cleaner', "~> 1.2.0"
gem 'database_cleaner'
end
#add rspec
group :development, :test do
gem 'rspec-rails', '~> 3.0'
gem "capybara"
gem 'factory_girl_rails'
gem 'watir-webdriver'
gem 'selenium-webdriver', '2.35.0'
gem 'rubyzip'
gem 'zip-zip'
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.7'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
Here is spec/spec_helper.rb (truncated)
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'capybara'
include Capybara::DSL # Adding this line solved the error
require 'rspec/rails'
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.infer_spec_type_from_file_location!
config.include Capybara::DSL
end
Here is env.rb
require 'capybara'
require 'capybara/dsl'
require 'capybara/cucumber'
#require 'capybara/rails'
#require 'capybara/session'
ActionController::Base.allow_rescue = false
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
Cucumber::Rails::Database.javascript_strategy = :truncation