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

ODOT "cleaning up our code"

After running bin/rake, I have 23 examples and 4 failures: I need some help identifying the errors below, which I've been stuck on for a few days now, checking syntax, changing context, etc. : Failures:

1) TodoItemsController GET 'index' returns http success Failure/Error: get 'index' ActionController::UrlGenerationError: No route matches {:action=>"index", :controller=>"todo_items"} # ./spec/controllers/todo_items_controller_spec.rb:7:in `block (3 levels) in <top (required)>'

2) Editing todo items is successful with valid content Failure/Error: within "#todo_item_#{todo_item.id}" do NameError: undefined local variable or method todo_item' for #<RSpec::Core::ExampleGroup::Nested_3:0xba7bac40> # ./spec/features/todo_items/edit_spec.rb:17:inblock (2 levels) in <top (required)>'

3) Adding todo items displays an error with no content Failure/Error: expect(page).to have_content("Content can't be blank") expected to find text "Content can't be blank" in "There was a problem adding that todo list item. {:error=>\"There was a problem adding that todo list item.\"} 2 errors prohibited this todo item from being saved: Content translation missing: de.activerecord.errors.models.todo_item.attributes.content.blank Content translation missing: de.activerecord.errors.models.todo_item.attributes.content.too_short Content" # ./spec/features/todo_items/create_spec.rb:36:in `block (2 levels) in <top (required)>'

4) Adding todo items displays an error with less than two characters long Failure/Error: expect(page).to have_content("Description translation missing:") expected to find text "Description translation missing:" in "There was a problem adding that todo list item. {:error=>\"There was a problem adding that todo list item.\"} 1 error prohibited this todo item from being saved: Content translation missing: de.activerecord.errors.models.todo_item.attributes.content.too_short Content" # ./spec/features/todo_items/create_spec.rb:48:in `block (2 levels) in <top (required)>'

Here's my code to the associated failed files:

1 todo_items_controller_spec.rb

require 'spec_helper'

describe TodoItemsController do

describe "GET 'index'" do it "returns http success" do get 'index' response.should be_success end end

end

2 edit_spec.rb

require 'spec_helper'

describe "Editing 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)
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

end

3 create_spec.rb

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


it "displays an error with no content" do
    visit_todo_list(todo_list)
    click_link "New Todo Item"
    fill_in "Content", with: ""
    click_button "Save"

    within("div.flash")do
    expect(page).to have_content("There was a problem adding that todo list item.")
end
expect(page).to have_content("Content can't be blank")

end

it "displays an error with less than two characters long" do visit_todo_list(todo_list) click_link "New Todo Item" fill_in "Content", with: "2" click_button "Save"

    within("div.flash")do
    expect(page).to have_content("There was a problem adding that todo list item.")
end
expect(page).to have_content("Content is too short")

end end

4 create_spec.rb

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


it "displays an error with no content" do
    visit_todo_list(todo_list)
    click_link "New Todo Item"
    fill_in "Content", with: ""
    click_button "Save"

    within("div.flash")do
    expect(page).to have_content("There was a problem adding that todo list item.")
end
expect(page).to have_content("Content can't be blank")

end

it "displays an error with less than two characters long" do visit_todo_list(todo_list) click_link "New Todo Item" fill_in "Content", with: "2" click_button "Save"

    within("div.flash")do
    expect(page).to have_content("There was a problem adding that todo list item.")
end
expect(page).to have_content("Content is too short")

end end