Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Viewing Todo Lists

Bin/Rake error after transitioning table into divs on Todo Lists index

I am getting the following error after running bin/rake. I ran bin/rake after transitioning my table into divs on the Todo Lists index page. I followed the video exactly.

Failures:

  1) todo_lists/index renders a list of todo_lists
     Failure/Error: assert_select "div", :text => "Title".to_s, :count => 2
     Minitest::Assertion:
       <Title> expected but was
       <Title
             MyText

               List Items | 
               Show | 
               Edit | 
               Destroy>..
       Expected: 2
         Actual: 0
     # ./spec/views/todo_lists/index.html.erb_spec.rb:20:in `block (2 levels) in <top (required)>'

I looked in Spec > Views > todo_lists > index.html.erb_spec.rb and I see what I need to edit but I am not exactly sure how to edit it (the "it" block):

describe "todo_lists/index" do
  before(:each) do
    assign(:todo_lists, [
      stub_model(TodoList,
        :title => "Title",
        :description => "MyText"
      ),
      stub_model(TodoList,
        :title => "Title",
        :description => "MyText"
      )
    ])
  end

  it "renders a list of todo_lists" do
    render
    # Run the generator again with the --webrat flag if you want to use webrat matchers
    assert_select "tr>td", :text => "Title".to_s, :count => 2
    assert_select "tr>td", :text => "MyText".to_s, :count => 2
  end
end

1 Answer

Seth Kroger
Seth Kroger
56,366 Points

Your spec for the view is still trying to look for table elements in the two assert_select's near the bottom. Because there's no table any longer, you need to select the new elements the title and description are in now.

Thanks Seth.... I actually did that initially but I switched the tr>td with a div.... then I realized they were in an h3 and a p! hahah