Ruby on Rails TDD Error with 'Bundle Exec Rspec' -


i working through hartl's ruby on rails tutorial , stuck on section 3.2 required run tdd using command:

$bundle exec rspec/requests/static_pages_spec.rb 

and in return:

/home/kelvin_yu/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `require': /home/kelvin_yu/rails_projects/sample_app/spec/spec_helper.rb:2: syntax error, unexpected '.' (syntaxerror) /home/kelvin_yu/rails_projects/sample_app/spec/spec_helper.rb:6: syntax error, unexpected '.'     /home/kelvin_yu/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun' 

so check in "static_pages_spec.rb" file , see same in listing 3.9 in tutorial (http://ruby.railstutorial.org/chapters/static-pages#sec-first_tests):

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

so makes me believe not cause of error (please let me know if assumption incorrect) , proceed check "spec_helper.rb" file:

# file copied spec/ when run 'rails generate rspec:install' . . . rspec.configure |config|   .   .   .   config.include capybara::dsl end 

this same shown in tutorial (listing 3.10 @ http://ruby.railstutorial.org/chapters/static-pages#sec-first_tests).

since error "unexpected '.' (syntaxerror)", remove period line 2 , rerun rspec command. same error, remove periods file now:

# file copied spec/ when run 'rails generate rspec:install' rspec.configure |config|   config.include capybara::dsl end 

and different error:

/home/kelvin_yu/rails_projects/sample_app/spec/spec_helper.rb:3:in `block in <top (required)>': uninitialized constant capybara (nameerror)     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core.rb:92:in `configure'     /home/kelvin_yu/rails_projects/sample_app/spec/spec_helper.rb:2:in `<top (required)>'     /home/kelvin_yu/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `require'     /home/kelvin_yu/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'     /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun' 

not sure error "uninitialized constant capybara (nameerror)" means. can advise next best steps?

those dots in author's examples meant serve ellipses, indicating there's text there that's not being shown (to keep reader's focus on relevant bits).

this closer spec_helper.rb file should like:

# file copied spec/ when 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 custom matchers , macros, etc, # in spec/support/ , subdirectories. dir[rails.root.join("spec/support/**/*.rb")].each {|f| require f}  #def logger #   rails::logger #end  rspec.configure |config|   # ## mock framework   #   # if prefer use mocha, flexmock or rr, uncomment appropriate line:   #   # config.mock_with :mocha   # config.mock_with :flexmock   # config.mock_with :rr    # remove 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 run each of   # examples within transaction, remove following line or assign false   # instead of true.   config.use_transactional_fixtures = true    # if true, base class of anonymous controllers inferred   # automatically. default behavior in future versions of   # rspec-rails.   config.infer_base_class_for_anonymous_controllers = false    # run specs in random order surface order dependencies. if find   # order dependency , want debug it, can fix order providing   # seed, printed after each run.   #     --seed 1234   config.order = "random" end 

if haven't made commits since removed lines, grab previous (complete) version of file github repo.


Comments