Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby on Rails TDD Error with 'Bundle Exec Rspec'
    primarykey
    data
    text
    <p>I am working through Hartl's Ruby on Rails tutorial and am stuck on Section 3.2 where I am required to run a TDD using the command:</p> <pre><code>$bundle exec rspec/requests/static_pages_spec.rb </code></pre> <p>and I get this in return:</p> <pre><code>/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 '.' from /home/Kelvin_Yu/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `&lt;top (required)&gt;' from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load' from /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' from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map' from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files' from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run' from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run' from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun' </code></pre> <p>So I check in my "static_pages_spec.rb" file and see that it is the same as in Listing 3.9 in the tutorial (<a href="http://ruby.railstutorial.org/chapters/static-pages#sec-first_tests" rel="nofollow">http://ruby.railstutorial.org/chapters/static-pages#sec-first_tests</a>):</p> <pre><code>require 'spec_helper' describe "Static pages" do describe "Home page" do it "should have the content 'Sample App'" do visit '/static_pages/home' expect(page).to have_content('Sample App') end end end </code></pre> <p>So that makes me believe that this is not the cause of the error (please let me know if this assumption is incorrect) and I proceed to check my "spec_helper.rb" file: </p> <pre><code># This file is copied to spec/ when you run 'rails generate rspec:install' . . . RSpec.configure do |config| . . . config.include Capybara::DSL end </code></pre> <p>This is the same as shown in the tutorial (Listing 3.10 @ <a href="http://ruby.railstutorial.org/chapters/static-pages#sec-first_tests" rel="nofollow">http://ruby.railstutorial.org/chapters/static-pages#sec-first_tests</a>).</p> <p>Since the error is an "unexpected '.' (SyntaxError)", I remove the period from line 2 and rerun the Rspec command. I get the same error, so I remove all periods from that file so it is now: </p> <pre><code># This file is copied to spec/ when you run 'rails generate rspec:install' RSpec.configure do |config| config.include Capybara::DSL end </code></pre> <p>and get a different error:</p> <pre><code>/home/Kelvin_Yu/rails_projects/sample_app/spec/spec_helper.rb:3:in `block in &lt;top (required)&gt;': uninitialized constant Capybara (NameError) from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core.rb:92:in `configure' from /home/Kelvin_Yu/rails_projects/sample_app/spec/spec_helper.rb:2:in `&lt;top (required)&gt;' from /home/Kelvin_Yu/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `require' from /home/Kelvin_Yu/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `&lt;top (required)&gt;' from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load' from /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' from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map' from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files' from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run' from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run' from /usr/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun' </code></pre> <p>Not sure what this error "uninitialized constant Capybara (NameError)" means. Can anyone help advise what would be the next best steps?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload