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 trialmv
3,664 PointsError when bin/rspec --format=documentation spec/features/todo_items/edit_spec.rb is run.
'odot veeni$ bin/rspec --format=documentation spec/features/todo_items/edit_spec.rb
/Users/veeni/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:in load': /Users/veeni/Documents/treehouse/odot/spec/features/todo_items/edit_spec.rb:4: syntax error, unexpected tLABEL (SyntaxError)
...list) { TodoList.create (title: "Grocery List", description:...
... ^
/Users/veeni/Documents/treehouse/odot/spec/features/todo_items/edit_spec.rb:4: syntax error, unexpected ',', expecting '}'
....create (title: "Grocery List", description: "Groceries") }
... ^
/Users/veeni/Documents/treehouse/odot/spec/features/todo_items/edit_spec.rb:4: syntax error, unexpected ')', expecting '}'
...ist", description: "Groceries") }
... ^
/Users/veeni/Documents/treehouse/odot/spec/features/todo_items/edit_spec.rb:52: syntax error, unexpected keyword_end, expecting '}'
from /Users/veeni/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:in
block in load_spec_files'
from /Users/veeni/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:in each'
from /Users/veeni/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:in
load_spec_files'
from /Users/veeni/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:18:in run'
from /Users/veeni/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:103:in
run'
from /Users/veeni/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:17:in `block in autorun' '
And the code is:
require 'spec_helper'
describe "Editing todo items" do
let!(:todo_list) { TodoList.create (title: "Grocery List", description: "Groceries") }
let!(:todo_item) { todo_list.todo_items.create(content: "Milk") }
def visit_todo_list(list)
visit "/todo_lists"
within "#todo_list_#{list.id}" do
click_link "List Items"
end
end
it "is successful with valid content" do
visit_todo_list(todo_list)
within("#todo_item_#{todo_item.id}") do
click_link "Edit"
end
fill_in "Content", with: "Lots of Milk"
click_button "Save"
expect(page).to have_content("Saved todo list item.")
todo_item.reload
expect(todo_item.title).to eq("Lots of Milk")
end
it "is unsuccessful with no content" do
visit_todo_list(todo_list)
within ("#todo_items_#{todo_item.id}") do
click_link "Edit"
end
fill_in "Content", with: ""
click_button "Save"
expect(page).to have_content("Saved todo list item.")
expect(page).to have_content("Content can't be blank")
todo_item.reload
expect(todo_item.title).to eq ("Milk")
end
it "is unsuccessful with not enough content" do
visit_todo_list(todo_list)
within ("#todo_items_#{todo_item.id}") do
click_link "Edit"
end
fill_in "Content", with: "1"
click_button "Save"
expect(page).to have_content("Saved todo list item.")
expect(page).to have_content("Content is too short")
todo_item.reload
expect(todo_item.title).to eq ("Milk")
end
end
please guide if possible, thank you!
1 Answer
Maciej Czuchnowski
36,441 PointsIn line 4:
let!(:todo_list) { TodoList.create (title: "Grocery List", description: "Groceries") }
Remove the space after create
, so:
let!(:todo_list) { TodoList.create(title: "Grocery List", description: "Groceries") }
It should work now.