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 Adding Todo Items

ceriannejackson
ceriannejackson
23,759 Points

Please help! Failure/Error: visit "/todo_lists"

I cannot find the source of my error! I keep getting this error message

Failure/Error: visit "/todo_lists" SyntaxError: /home/ubuntu/workspace/app/views/layouts/application.html.erb:22: syntax error, unexpected keyword_ensure, expecting keyword_end /home/ubuntu/workspace/app/views/layouts/application.html.erb:24: syntax error, unexpected end-of-input, expecting keyword_end # ./spec/features/todo_items/create_spec.rb:7:in visit_todo_list' # ./spec/features/todo_items/create_spec.rb:15:inblock (2 levels) in <top (required)>'

Here is my application.html.erb:

<!DOCTYPE html> <html> <head> <title>Workspace</title> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> </head> <body>

<% flash.each do |type, message| %> <div class = "alert flash <%= type %>"> <%= message %> </div> </end>

<%= yield %>

</body> </html>

Can someone help please?

6 Answers

nulled
nulled
1,890 Points

I am currently working on this course. Here is some of my code for those two specific files:

<!DOCTYPE html>
<html>
<head>
  <title>Odot</title>
  <%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true %>
  <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
  <%= csrf_meta_tags %>
</head>
<body>

  <% flash.each do |type, message| %>
  <div class="alert flash <%= type %>">
    <%= message %>
  </div>
  <% end %>

<%= yield %>

</body>
</html>
require 'spec_helper'

describe "Adding todo items" do
  let!(:todo_list) { TodoList.create(title: "Grocery Lists", description: "Groceries") }

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)
    click_link "New Todo Item"
    fill_in "Content", with: "Milk"
    click_button "Save"
    expect(page).to have_content("Added todo list item.")
    within("ul.todo_items") do
      expect(page).to have_content("Milk")
    end
  end

Make sure your indents are correct. Also, follow specifically line by line what the errors are given to you on the terminal.

Alternatively, you can also go down to the teachers notes and download the file to check your work.

Kevin Egstorf
Kevin Egstorf
26,590 Points

Its seems you have a syntax error at your create_spec.rb file

ceriannejackson
ceriannejackson
23,759 Points

Thanks, I know, but I can't spot what's wrong. Am I missing something obvious?

require 'spec_helper'

describe "Adding todo items" do let!(:todo_list){TodoList.create(title: "Grocery list",description: "Groceries")}

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)
   click_link "New Todo Item"
   fill_in "Content", with: "Milk"
   click_button "Save"
   expect(page).to have_content("Added todo list item.")
   within("ul.todo_items") do
        expect(page).to have_content("Milk")
   end
end

end

ceriannejackson
ceriannejackson
23,759 Points

Row 15 is this one:

visit_todo_list(todo_list)

Kevin Egstorf
Kevin Egstorf
26,590 Points

does the file belong to a class? because the error states you are missing or have an extra end

ceriannejackson
ceriannejackson
23,759 Points

Finally found it! Thanks so much for your help! I had a </end> instead of <% end %> in my application.html.erb file. Can't believe I didn't spot it earlier!