In my previous identical post I didn't get to solve my problem and didn't get many answers, so I'm reposting my problem to try and get more help.
I am following a tutorial by Michael Hartl and in 3.2.1 we are testing the server with:
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
When I input "bundle exec rspec spec/requests/static_pages_spec.rb" in the console I get a bunch of errors shown below:
root@KyleBuntu:~/Desktop/Rails/sample_app# bundle exec rspec spec/requests/static_pages_spec.rb
/home/verendus/Desktop/Rails/sample_app/spec/requests/static_pages_spec.rb:1:in `require': /home/verendus/Desktop/Rails/sample_app/spec/spec_helper.rb:44: syntax error, unexpected tIDENTIFIER, expecting end-of-input (SyntaxError)
:DSL to config.include Capybara::DSL
^
from /home/verendus/Desktop/Rails/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
from /home/verendus/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
from /home/verendus/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
from /home/verendus/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
from /home/verendus/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from /home/verendus/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
from /home/verendus/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
from /home/verendus/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
I know that I am supposed to get an error, but in the book the errors that the author received was much shorter and was different. (Link in comments)
I have changed the rspec_helper.rb file to add the Capybara DSL, but I'm not sure if that's the problem and if I did or didn't input it properly. I am also quite new to Rails, Ruby and coding/Linux systems (I am using Ubuntu) in general, so if anything is needed then just ask.
Github link in comments.
You seem to have a comment line in spec_helper.rb:44 that has been partially deleted and thus uncommented.
:DSL to config.include Capybara::DSL
# This file is copied to spec/ when you run 'rails generate rspec:install'
You may or may not want to actually config.include Capybara::DSL
, but the :DSL to
part is what causes the syntax error.
In addition, you have some strange .
periods on the lines below which likely will cause you some more syntax errors. You may even want to run rails generate rspec:install
again to regenerate the file completely.
You have an error in your spec_helper.rb file.
This line
:DSL to config.include Capybara::DSL
should be erased. Instead, if you want Capybara::DSL
to be included, you should add
config.include Capybara::DSL
inside of RSpec::configure do |config|
block.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.