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 Editing Todo Lists

Hoormazd Kia
PLUS
Hoormazd Kia
Courses Plus Student 6,075 Points

syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)

Hello, My problem begins about 5 minutes into the tutorial video, where we are asked to run the following command in our CLI

"bin/rspec spec/features/todo_lists/edit_spec.rb "

We are supposed to expect a failure, but I receive a "expecting keyword_end" syntax error as mentioned above, but the error isn't coming from the edit_spec.rb file, it's coming from all over the place, here's the full text...

** Myname-MacBook-Pro:odot username$ bin/rspec spec/features/todo_lists/edit_spec.rb /Users/username/treehouse/projects/odot/config/environment.rb:2:in require': /Users/username/treehouse/projects/odot/config/application.rb:28: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError) from /Users/username/treehouse/projects/odot/config/environment.rb:2:in<top (required)>' from /Users/username/treehouse/projects/odot/spec/spec_helper.rb:3:in require' from /Users/username/treehouse/projects/odot/spec/spec_helper.rb:3:in<top (required)>' from /Users/username/treehouse/projects/odot/spec/features/todo_lists/edit_spec.rb:1:in require' from /Users/username/treehouse/projects/odot/spec/features/todo_lists/edit_spec.rb:1:in<top (required)>' from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in load' from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:inblock in load_spec_files' from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in each' from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:inload_spec_files' from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/command_line.rb:18:in run' from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:103:inrun' from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:17:in `block in autorun' Myname-MacBook-Pro:odot username$ **

Here's the code (so far) from edit_spec.rb

''' require 'spec_helper'

describe "Editing todo lists" do it "updates a todo list successfully with correct information" do todo_list = TodoList.create(title: "Groceries", description: "Grocery list.")

    visit "/todo_lists"
    within "#todo_list_#{todo_list.id}" do
        click_link "Edit"
    end

    fill_in "Title", with: "New title"
    fill_in "Description", with: "New description"
    click_button "Update Todo list"

    todo_list.reload

    expect(page).to have_content("Todo list was successfully updated")
    expect(todo_list.title).to eq("New title")
    expect(todo_list.description).to eq("New description")  
end

end '''

Thanks

Cyrus

2 Answers

Hi,

It seems you forgot to add end to account for your it block.

describe "Editing todo lists" do
  it "updates a todo list successfully with correct information" do 

    todo_list = TodoList.create(title: "Groceries", description: "Grocery list.") 

    visit "/todo_lists"
    within "#todo_list_#{todo_list.id}" do
        click_link "Edit"
    end

    fill_in "Title", with: "New title"
    fill_in "Description", with: "New description"
    click_button "Update Todo list"

    todo_list.reload

    expect(page).to have_content("Todo list was successfully updated")
    expect(todo_list.title).to eq("New title")
    expect(todo_list.description).to eq("New description")
  end # You forgot an end here 
end

Here's a screenshot proving that this will fix your problem

Hoormazd Kia
Hoormazd Kia
Courses Plus Student 6,075 Points

Hi,

thanks for your effort! My initial thought was that that was the syntax error, but it didn't correct the issue. I reverted to a previous version and just worked from there. Going to mark it as the best answer though since I recreated the error and this solved the problem. Not sure what was different from the first go around, but your solution worked the second time!

Hi again, Hoormazd Kia:

It may have been a problem beyond your syntax error; it may have been also a runtime error your previous version did not have.

That said, glad this problem is behind you so you can continue learning Rails!

Hoormazd Kia
Hoormazd Kia
Courses Plus Student 6,075 Points

I found the issue that caused my original problem. At first it caused no issues whatsoever, which is why it was so hard for me to find the problem.

In one of the tutorial videos for the todo list project Jason decides to add some additional information to applications.rb to reduce the amount of textual information we receive in the command line. The solution didn't work for me, so I added the following code...

    #Added by me (may be what caused the problems BELOW)
    ##ENDED UP CAUSING PROBLEMS
        #RSpec.configure do |c|
         #   c.expose_current_running_example_as :example
        #end
    #Added by me (may be what caused the problems ABOVE)    

It did exactly what Jason desired. So I thought nothing of it. For lack of a technical explanation the problem just "creeps up" as I progress through building the application.