Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Write Our First Tests

Stuck on "Write Our First Test" in Rails Todo List

Around 4:36, after writing some test code, Jason runs it and receives an expected return. I received this:

bin/rspec spec/fea
tures/todo_lists/create_spec.rb
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.
0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:
1065:in `load': /home/treehouse/projects/odot/spec/features
/todo_lists/create_spec.rb:33: syntax error, unexpected end
-of-input, expecting keyword_end (SyntaxError)
        from /home/treehouse/.rbenv/versions/2.0.0-p353/lib
/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/conf
iguration.rb:1065:in `block in load_spec_files'
        from /home/treehouse/.rbenv/versions/2.0.0-p353/lib
/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/conf
iguration.rb:1065:in `each'
        from /home/treehouse/.rbenv/versions/2.0.0-p353/lib
/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/conf
iguration.rb:1065:in `load_spec_files'
        from /home/treehouse/.rbenv/versions/2.0.0-p353/lib
/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/comm
and_line.rb:18:in `run'
        from /home/treehouse/.rbenv/versions/2.0.0-p353/lib
/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/runn
er.rb:103:in `run'
        from /home/treehouse/.rbenv/versions/2.0.0-p353/lib
/ruby/gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/runn
er.rb:17:in `block in autorun'

4 Answers

David Gross
David Gross
19,443 Points

It looks like you have a syntax error on line 33 on create_spec.rb. Its saying that you need to add a key_word end . Even though it spits out alot of information, you need to get in the habit of reading the error reports. It will usually tell you how and where to solve the problem.

create_spec.rb:33: syntax error, unexpected end
-of-input, expecting keyword_end (SyntaxError)

Yep. This is why I asked if you could copy the create_spec.rb. Only than can we help find the syntax error.

Can you copy your create spec file?

RSpec has introduced a few breaking changes in 2.99 and 3+. Just make sure that you're using the same RSpec version.

I would recommend that you instead have:

gem 'rspec-rails', '2.14.2'

If you stick closely to the gem versions that Jason Seifer uses in the video, you shouldn't encounter problems associated with breaking changes.

I'm having a similar problem. I just installed gem 'rspec-rails', '2.14.2'

require 'spec_helper'

describe "Creating todo lists" do it "redirects to the do list index page on success" do visit "/todo_lists" click_link "New Todo list" expect(page).to have_content("New todo_list")

    fill_in "Title", with: "My todo list"
    fill_in 'Description' with: "This is what I'm doing today"
    click_button "Create Todo list"

    expect(page).to have_content ("New todo_list")
end 

it "displays an error when the todo list has no title" do
    expect(TodoList.count).to eq(0)
    visit "/todo_lists" 
    click_link "New Todo list" 
    expect(page).to have_content("New todo_list")

    fill_in "Title", with: ""
    fill_in 'Description' with: "This is what I'm doing today"
    click_button "Create Todo list"

    expect(page).to have_content("error")
    expect(TodoList.count).to eq(0)

    visit "/todo_lists"
    expect(page).to_not have_content("This what I'm doing today")
end

end