I have been trying to use RSpec with Rails 4 but came across this error that I can't get rid of.
However, when I run test on single *.rb files it works without any errors. I use guard and have tried to run rspec in single mode but received the same error.
13:46:26 - INFO - Running: spec
/Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:214:in `initialize!': Application has been already initialized. (RuntimeError)
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/xxx/Documents/Mitt_bolag/Minnesota/beställningssite/order_site/config/environment.rb:5:in `<top (required)>'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /Users/xxx/Documents/Mitt_bolag/Minnesota/beställningssite/order_site/spec/spec_helper.rb:3:in `<top (required)>'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /Users/xxx/Documents/Mitt_bolag/Minnesota/beställningssite/order_site/spec/requests/products_spec.rb:1:in `<top (required)>'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `block in load'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `each'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `load_spec_files'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.5/lib/rspec/core/command_line.rb:22:in `run'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.5/lib/rspec/core/runner.rb:80:in `run'
from /Users/xxx/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.5/lib/rspec/core/runner.rb:17:in `block in autorun'
This is my spec_helper.rb
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
config.include Devise::TestHelpers, :type => :controller
end
class ActionController::TestCase
include Devise::TestHelpers
end
I ran into this problem while upgrading a Rails 4.2 and Ruby 2.2 app to Rails 4.2 and Rails 2.6. Apparently, ActionController::TestResponse is reused and therefore initialized multiple times. You can add a workaround reading this thread, or simply create spec/support/action_controller_workaround.rb:
if RUBY_VERSION>='2.6.0'
if Rails.version < '5'
class ActionController::TestResponse < ActionDispatch::TestResponse
def recycle!
# hack to avoid MonitorMixin double-initialize error:
#mon_mutex_owner_object_id = nil
#mon_mutex = nil
initialize
end
end
else
puts "Monkeypatch for ActionController::TestResponse no longer needed"
end
end
Try setting your spec_helper to this:
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec' # NOTE: I DON'T have this but you do...
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
end
I don't know if you've already got the solution, but here I go anyway:
I'm facing the same problem since yesterday. I've found that running a
single spec by time or removing the 'require "spec_helper" from all specs but one,
it would work.
And a few minutes ago, I've found that the problem was the ruby version.
If you upgrade your ruby-2.0.0-p0 to ruby-2.0.0-p247, then the problem goes away!
I hope I've been helpful.
Related
I have a Rails 5.0.1 app that is NOT backed by any database. When attempting to write a controller test I get a ActiveRecord::ConnectionNotEstablished exception even though I have explicitly configured my spec/rails_helper.rb not to use ActiveRecord and removed references to active_record in config/application.rb. RSpec is trying to run such test within a transaction which requires a database connection to be established. I am attaching the stack trace for reference and I used this Github issue to setup RSpec without ActiveRecord rspec-rails for a rails project without db connection.
Failures:
1) ApplicationController the truth false not equal true
Failure/Error: raise ConnectionNotEstablished, "No connection pool with id #{spec_name} found." unless pool
ActiveRecord::ConnectionNotEstablished:
No connection pool with id primary found.
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `retrieve_connection'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_handling.rb:128:in `retrieve_connection'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_handling.rb:91:in `connection'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/fixtures.rb:516:in `create_fixtures'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/fixtures.rb:1015:in `load_fixtures'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/fixtures.rb:988:in `setup_fixtures'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/fixtures.rb:852:in `before_setup'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-rails-3.6.1/lib/rspec/rails/adapters.rb:126:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:447:in `instance_exec'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:447:in `instance_exec'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:375:in `execute_with'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:342:in `call'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:607:in `run_around_example_hooks_for'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:464:in `run'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:457:in `with_around_example_hooks'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:500:in `with_around_and_singleton_context_hooks'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:251:in `run'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:627:in `block in run_examples'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:623:in `map'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:623:in `run_examples'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:589:in `run'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:590:in `block in run'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:590:in `map'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:590:in `run'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:118:in `block (3 levels) in run_specs'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:118:in `map'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:118:in `block (2 levels) in run_specs'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1894:in `with_suite_hooks'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:113:in `block in run_specs'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/reporter.rb:79:in `report'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:112:in `run_specs'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:87:in `run'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:71:in `run'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:45:in `invoke'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/exe/rspec:4:in `<top (required)>'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/bin/rspec:23:in `load'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/bin/rspec:23:in `<top (required)>'
# /opt/ruby2.3/lib64/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `load'
# /opt/ruby2.3/lib64/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
# /opt/ruby2.3/lib64/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:24:in `run'
# /opt/ruby2.3/lib64/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:304:in `exec'
# /opt/ruby2.3/lib64/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
# /opt/ruby2.3/lib64/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
# /opt/ruby2.3/lib64/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
# /opt/ruby2.3/lib64/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
# /opt/ruby2.3/lib64/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'
# /opt/ruby2.3/lib64/ruby/gems/2.3.0/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>'
# /opt/ruby2.3/lib64/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
# /opt/ruby2.3/lib64/ruby/gems/2.3.0/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>'
# /vagrant/easypost_admin/vendor/bundle/bundle:23:in `load'
# /vagrant/easypost_admin/vendor/bundle/bundle:23:in `<main>'
#
# Showing full backtrace because every line was filtered out.
# See docs for RSpec::Configuration#backtrace_exclusion_patterns and
# RSpec::Configuration#backtrace_inclusion_patterns for more information.
Finished in 0.0058 seconds (files took 2.29 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/controllers/application_controller_spec.rb:15 # ApplicationController the truth false not equal true
UPDATE
rails_help.rb
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
# Checks for pending migration and applies them before tests are run.
# If you are not using ActiveRecord, you can remove this line.
# 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"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false
# The different available types are documented in the features, such as in
# https://relishapp.com/rspec/rspec-rails/docs
config.infer_spec_type_from_file_location!
# Filter lines from Rails gems in backtraces.
config.filter_rails_from_backtrace!
end
spec_helper.rb
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
mocks.verify_partial_doubles = true
end
config.shared_context_metadata_behavior = :apply_to_host_groups
end
I had the very same issue with a rails 5.2.0.alpha app without a database
configured. So I had a look at the rspec-rails code, and figured out this
line which causes all the trouble:
rspec-rails/lib/rspec/rails/fixture_support.rb:
if defined?(ActiveRecord::TestFixtures)
It checks for a loaded ActiveRecord constant, which actually was loaded. I
also had require 'active_record/railtie' commented out from
config/application.rb. Then I figured out who required the ActiveStorage gem
(bundle.lock). In my case it was ActiveStorage.
I just use the ActiveStorage functionality without a database, so I had to
remove the ActiveRecord constant on my spec/rails_helper.rb:
# frozen_string_literal: true
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
# Remove the ActiveRecord constant, because it is autloaded by
# ActiveStorage and not needed for our application. The presence
# of the ActiveRecord constant causes rspec-rails to include
# extra fixture support, which results in:
#
# ActiveRecord::ConnectionNotEstablished:
# No connection pool with 'primary' found.
#
Object.send(:remove_const, :ActiveRecord)
Mind the order, it needs to be placed after
require File.expand_path('../../config/environment', __FILE__)
and before
require 'rspec/rails'
This solution just modify the test environment.
UPDATE
I create an issue on rspec-rails which targets the creation of a global rspec configuration to turn off ActiveRecord handling.
A fix for this has just been merged into rspec-rails, and will supposedly be released along with RSpec Rails 4.0 sometimes next week.
What you have to set the following in your spec/rails_helper.rb:
config.use_active_record = false
Again, the problem is that if you didn't configure/use the database connection, but ActiveRecord is still present (due to Bundler loading it or some other reasons).
I am trying to setup rspec (v3.0.2) on Rails 4.1.9 with factory_girl_rails but after implementing rails_helper.rb and spec_helper.rb I get the following error when running my _spec.rb file:
/Users/user/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.9/lib/active_record/attribute_methods.rb:9:in `<module:AttributeMethods>': uninitialized constant ActiveModel::AttributeMethods (NameError)
from /Users/user/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.9/lib/active_record/attribute_methods.rb:7:in `<module:ActiveRecord>'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.9/lib/active_record/attribute_methods.rb:5:in `<top (required)>'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.9/lib/active_record.rb:101:in `<module:ActiveRecord>'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.9/lib/active_record.rb:31:in `<top (required)>'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.9/lib/active_record/railtie.rb:1:in `require'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.9/lib/active_record/railtie.rb:1:in `<top (required)>'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/railties-4.1.9/lib/rails/all.rb:12:in `require'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/railties-4.1.9/lib/rails/all.rb:12:in `block in <top (required)>'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/railties-4.1.9/lib/rails/all.rb:10:in `each'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/railties-4.1.9/lib/rails/all.rb:10:in `<top (required)>'
from /Users/user/code/rtb-campaign-optimization/config/application.rb:3:in `require'
from /Users/user/code/rtb-campaign-optimization/config/application.rb:3:in `<top (required)>'
from /Users/user/code/rtb-campaign-optimization/config/environment.rb:2:in `require'
from /Users/user/code/rtb-campaign-optimization/config/environment.rb:2:in `<top (required)>'
from /Users/user/code/rtb-campaign-optimization/spec/rails_helper.rb:4:in `require'
from /Users/user/code/rtb-campaign-optimization/spec/rails_helper.rb:4:in `<top (required)>'
from /Users/user/code/rtb-campaign-optimization/spec/models/cpa_calculator_spec.rb:1:in `require'
from /Users/user/code/rtb-campaign-optimization/spec/models/cpa_calculator_spec.rb:1:in `<top (required)>'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `block in load_spec_files'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `each'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load_spec_files'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:97:in `setup'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in `run'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke'
from /Users/user/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.0.4/exe/rspec:4:in `<top (required)>'
from /Users/user/.rvm/gems/ruby-2.2.1/bin/rspec:23:in `load'
from /Users/user/.rvm/gems/ruby-2.2.1/bin/rspec:23:in `<main>'
from /Users/user/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
from /Users/user/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
Here is my gemfile:
group :development do
gem 'rails-dev-tweaks'
gem 'quiet_assets'
gem 'pry'
gem 'pry-byebug'
gem 'hirb'
gem 'spring'
gem 'spring-commands-rspec'
end
group :development, :test do
gem 'rspec-rails', '~> 3.0.0'
gem 'factory_girl_rails'
end
group :test do
gem 'database_cleaner'
end
rails_helper.rb:
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
# in _spec.rb will both be required and run as specs, causing the specs to be
# run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
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"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.
#
# You can disable this behaviour by removing the line below, and instead
# explicitly tag your specs with their type, e.g.:
#
# RSpec.describe UsersController, :type => :controller do
# # ...
# end
#
# The different available types are documented in the features, such as in
# https://relishapp.com/rspec/rspec-rails/docs
config.infer_spec_type_from_file_location!
end
spec_helper.rb:
RSpec.configure do |config|
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
# These two settings work together to allow you to limit a spec run
# to individual examples or groups you care about by tagging them with
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
# get run.
config.filter_run :focus
config.run_all_when_everything_filtered = true
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = 'doc'
end
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# Enable only the newer, non-monkey-patching expect syntax.
# For more details, see:
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
expectations.syntax = :expect
end
# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Enable only the newer, non-monkey-patching expect syntax.
# For more details, see:
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
mocks.syntax = :expect
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended.
mocks.verify_partial_doubles = true
end
end
my _spec file:
require 'rails_helper'
describe 'CampaignsManagement::CpaCalculator' do
let(:campaign) {
camp = FactoryGirl.build_stubbed(:campaign)
# campaign_histories_per_campaigns.times.each do |index|
# Factory.build(:campaign_history, value: index + 1, campaign_id: camp.id)
# end
camp
}
context "when there are some active campaigns" do
context "when the campaign have histories" do
let(:campaign_histories_per_campaigns) { 10 }
context 'when the campaign have histories created today' do
end
context 'when the campaign has only histories in the past (not generated today)' do
end
end
context "when the campaign is histories orphaned" do
let(:campaign_histories_per_campaigns) { 0 }
it "should not update redshift" do
campaign.campaign_histories.size.should.eq(0)
end
end
end
end
application.rb:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module RtbCampaignOptimization
class Application < Rails::Application
config.assets.enabled = false
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.autoload_paths << Rails.root.join('lib')
end
end
any ideas?
Thanks
Try to run:
rails generate rspec:install //which you must have already run
bundle install
And also check out this question and it's answers
According to the above, you need to add spork-rails to your Gemfile.
All the above-shared code snippets all look good.
I'm currently working on my first tests but I'm stuck with a problem I can't seem to fix by myself. I've searched for solutions for some hours now and found similar errors but I didn't find any solution working in my case. Maybe it's because of a version difference, I don't know.
The problem appears when I'm writing a unit test with minitest, maybe also integration tests. I'm using devise for managing users.
This is there error that appears in the terminal when I rake test:
1) Error:
test_deactivate_enrolment(EnrolmentTest):
NoMethodError: undefined method `env' for nil:NilClass
/Users/myname/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.0.3/lib/devise/test_helpers.rb:24:in `setup_controller_for_warden'
/Users/myname/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:429:in `_run__840473936918917337__setup__1779200460764756091__callbacks'
/Users/myname/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
/Users/myname/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_setup_callbacks'
/Users/myname/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
/Users/myname/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.13/lib/active_support/testing/setup_and_teardown.rb:35:in `run'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/minitest/unit.rb:919:in `block in _run_suite'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/minitest/unit.rb:912:in `map'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/minitest/unit.rb:912:in `_run_suite'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/test/unit.rb:657:in `block in _run_suites'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/test/unit.rb:655:in `each'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/test/unit.rb:655:in `_run_suites'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/minitest/unit.rb:867:in `_run_anything'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/minitest/unit.rb:1060:in `run_tests'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/minitest/unit.rb:1047:in `block in _run'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/minitest/unit.rb:1046:in `each'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/minitest/unit.rb:1046:in `_run'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/minitest/unit.rb:1035:in `run'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/test/unit.rb:21:in `run'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/test/unit.rb:774:in `run'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/test/unit.rb:366:in `block (2 levels) in autorun'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/test/unit.rb:27:in `run_once'
/Users/myname/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/test/unit.rb:365:in `block in autorun'
This is what my spec_helper.rb looks like:
require 'listen'
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.color_enabled = true
config.order = :random
config.filter_run :focus => true
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run_excluding :broken => true
config.fail_fast = true
end
def test_latency
0.1
end
# Crash loud in tests!
Thread.abort_on_exception = true
And this is my test_helper.rb
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
# To add Capybara feature tests add `gem "minitest-rails-capybara"`
# to the test group in the Gemfile and uncomment the following:
#require "minitest/rails/capybara"
# Uncomment for awesome colorful output
#require "minitest/pride"
require 'minitest/autorun'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
fixtures :all
include Devise::TestHelpers
# Add more helper methods to be used by all tests here...
end
I've tried adding include Devise::TestHelpers on top of the files which fail but that didn't fix it. Deleting the line in 'test_helper.rb` had the same result. Maybe someone had this error as well?
Update
This is on of the test files, nothing too advanced...
require 'test_helper'
class EnrolmentTest < ActiveSupport::TestCase
test "deactivate enrolment" do
assert true
end
end
Only include the Devise helpers in your controller tests. Your test_helper.rb file should look like this:
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
# To add Capybara feature tests add `gem "minitest-rails-capybara"`
# to the test group in the Gemfile and uncomment the following:
#require "minitest/rails/capybara"
# Uncomment for awesome colorful output
#require "minitest/pride"
require 'minitest/autorun'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end
class ActionController::TestCase
include Devise::TestHelpers
end
Alternative, you can use Warden to test instead of Device test helpers, here there is an example of use. Devise is based on Warden.
Remove include Devise::TestHelpers from your test_helper.rb. Include it only in the test that needs it.
I'm setting up a Rails 3.1 project and like to properly test it using RSpec.
After running rails g rspec:install and further running rspec, the console messages read as follows:
% rspec
/Library/Ruby/Gems/1.8/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:470:in `assert_no_example_groups_defined': RSpec's mock_framework configuration option must be configured before any example groups are defined, but you have already defined a group. (RSpec::Core::Configuration::MustBeConfiguredBeforeExampleGroupsError)
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:168:in `mock_framework='
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:142:in `mock_with'
from /Users/ened/project/spec/controllers/../spec_helper.rb:19
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.7.0/lib/rspec/core.rb:71:in `configure'
from /Users/ened/project/spec/controllers/../spec_helper.rb:11
from /Library/Ruby/Gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from /Users/ened/project/spec/controllers/submissions_controller_spec.rb:1
from /Library/Ruby/Gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `load_spec_files'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `map'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `load_spec_files'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.7.0/lib/rspec/core/command_line.rb:18:in `run'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:80:in `run_in_process'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:69:in `run'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:10:in `autorun'
from /usr/bin/rspec:19
My rspec/spec_helper.rb looks like this:
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
end
I thought it's configured already using the config.mock_with ? I'm puzzled, what is missing?
I just hit this. It turned out to be that some of my old (circa RSpec 1) specs had the following require statement:
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
Most of the new specs had this require statement:
require 'spec_helper'
I'd never bothered to tidy up the old style. What this meant was that the spec_helper.rb filename was passed to require in two different ways: one full path, one local path. This in turn caused spec_helper.rb to be executed twice, triggering the error. Changing all the require statements to the short new style fixed the issue.
I just resolved this problem for my Rails app.
My problem was that two spec files were missing the require 'spec_helper' line at the top of the file.
I met the same problem, and my root cause is:
there are some spec files exist in spec/support folder!
e.g.
spec/support/xx_spec.rb
which looks like:
require 'spec_helper'
describe XX do
...
and in the spec/spec_helper.rb file, there are:
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
This is a situation that 'spec_helper' was recursive required for unlimited times.
So the solution is very simple:
REMOVE all the xx_spec.rb files from spec/support folder.
Could be an issue of Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}. I have placed it below the config block in my app and it worked.
I have a rails app with Cucumber 1.0.0 and cucumber-rails 1.0.2. These tests ran fine last night. Today I just altered some step definitions and tried to run the tests and got the error below. I haven't changed anything in the cucumber support files. Any ideas?
grouperty $ cucumber
Using the default profile...
no such file to load -- /Users/davidtuite/wd/grouperty/features/config/environment(LoadError)
/Users/davidtuite/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/davidtuite/.rvm/rubies/ruby-1.9.2-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/davidtuite/wd/grouperty/features/support/env.rb:12:in `block in <top (required)>'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/gems/spork-0.9.0.rc9/lib/spork.rb:24:in `prefork'
/Users/davidtuite/wd/grouperty/features/support/env.rb:10:in `<top (required)>'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/gems/cucumber-1.0.0/lib/cucumber/rb_support/rb_language.rb:143:in `load'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/gems/cucumber-1.0.0/lib/cucumber/rb_support/rb_language.rb:143:in `load_code_file'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/gems/cucumber-1.0.0/lib/cucumber/runtime/support_code.rb:176:in `load_file'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/gems/cucumber-1.0.0/lib/cucumber/runtime/support_code.rb:78:in `block in load_files!'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/gems/cucumber-1.0.0/lib/cucumber/runtime/support_code.rb:77:in `each'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/gems/cucumber-1.0.0/lib/cucumber/runtime/support_code.rb:77:in `load_files!'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/gems/cucumber-1.0.0/lib/cucumber/runtime.rb:137:in `load_step_definitions'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/gems/cucumber-1.0.0/lib/cucumber/runtime.rb:39:in `run!'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/gems/cucumber-1.0.0/lib/cucumber/cli/main.rb:43:in `execute!'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/gems/cucumber-1.0.0/lib/cucumber/cli/main.rb:20:in `execute'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/gems/cucumber-1.0.0/bin/cucumber:14:in `<top (required)>'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/bin/cucumber:19:in `load'
/Users/davidtuite/.rvm/gems/ruby-1.9.2-head#grouperty/bin/cucumber:19:in `'
Here is the content of /features/support/env.rb. Note that most of it was generated by the spork gem (v0.9.0.rc9).
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'cucumber/rails'
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
# order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPath just remove this line and adjust any selectors in your
# steps to use the XPath syntax.
Capybara.default_selector = :css
end
Spork.each_run do
# By default, any exception happening in your Rails application will bubble up
# to Cucumber so that your scenario will fail. This is a different from how
# your application behaves in the production environment, where an error page will
# be rendered instead.
#
# Sometimes we want to override this default behaviour and allow Rails to rescue
# exceptions and display an error page (just like when the app is running in production).
# Typical scenarios where you want to do this is when you test your error pages.
# There are two ways to allow Rails to rescue exceptions:
#
# 1) Tag your scenario (or feature) with #allow-rescue
#
# 2) Set the value below to true. Beware that doing this globally is not
# recommended as it will mask a lot of errors for you!
#
ActionController::Base.allow_rescue = false
# Remove/comment out the lines below if your app doesn't have a database.
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
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
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
# See the DatabaseCleaner documentation for details. Example:
#
# Before('#no-txn,#selenium,#culerity,#celerity,#javascript') do
# DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
# end
#
# Before('~#no-txn', '~#selenium', '~#culerity', '~#celerity', '~#javascript') do
# DatabaseCleaner.strategy = :transaction
# end
#
end
this line
require File.expand_path("../../config/environment", __FILE__)
requires
/Users/davidtuite/wd/grouperty/features/config/environment
which is not present there this causes error