ruby on rails - Why do I get "including Capybara::DSL in the global scope is not recommended!" -


everytime run spec, if spec passes, e.g.

$ rspec spec/integration/view_homepage_spec.rb  including capybara::dsl in global scope not recommended! .  finished in 0.6174 seconds 1 example, 0 failures  randomized seed 14130  $  

my gemfile has:

group :test, :development   gem 'rspec-rails'   gem 'capybara' end 

my spec_helper has:

env["rails_env"] ||= 'test' require file.expand_path("../../config/environment", __file__) require 'rspec/rails' require 'rspec/autorun' require 'capybara' include capybara::dsl dir[rails.root.join("spec/support/**/*.rb")].each { |f| require f }  activerecord::migration.check_pending! if defined?(activerecord::migration) rspec.configure |config|   config.fixture_path = "#{::rails.root}/spec/fixtures"   config.use_transactional_fixtures = true   config.infer_base_class_for_anonymous_controllers = false   config.order = "random" end 

if comment out include capybara::dsl capybara methods visit don't work.

because including capybara::dsl in global scope not recommended.

this includes many methods globally in system, interfere own code.

here's correct way:

rspec.configure |config|   config.include capybara::dsl, :type => :feature end 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -