ruby on rails - Uninitialized constant Capybara -


i'm having problem running test in rails capybara. whenever run it, tells me have 'uninitialized constant capybara (nameerror)' in spec_helper.rb file.

i'm following tutorial: http://www.railstutorial.org/book/static_pages#code-capybara_dsl

this spec_helper.rb

rspec.configure |config|   config.include(capybara::dsl) end 

and i'm trying run test static_pages_spec.rb

require 'spec_helper'   describe "static pages"  "should have content 'sample app'"   visit '/static_pages/home'   expect(page).to have_content('sample app') end  

if there other more information needed let me know

--------update----------------

i figured out problem. version of rspec have creates rails_helper.rb file in spec folder. had do:

require 'capybara/rspec' 

in file , config.include capybara::dsl in configurations.

-----new problem------------ problem saying 'visit' undefined.

 undefined method `visit' #<rspec::examplegroups::staticpages::aboutpage:0x000001033f5d50> 

i tried require 'capybara', , require 'capybara/dsl' still give me errors , some.

i sort of found out problem, i'm getting initialized constant capybara because in newer versions of rspec have new folder "rails_helper" when first create spec folder creates both rails_helper , spec_helper. first mock speck test in spec folder has @ top

require 'rails_helper' 

i following tutorial told me require 'spec_helper' not true newer versions of rspec.

so added

config.include(capybara::dsl) 

in rails helper folder , worked, except error css believe because tests run headless not work. spec tests run fine after errors displayed though. if have more questions let me know.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -