Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

James Krill
James Krill
3,759 Points

Super weird: completed_todo_item.completed_at and todo_item.completed_at are different!!

Failures:

1) Completing todo items with completed items shows completed items as complete Failure/Error: expect(page).to have_content(completed_todo_item.completed_at) expected to find text "2016-05-16 11:09:58 -0700" in "2000-01-01 18:09:58 UTC Eggs Edit Delete" # ./spec/features/todo_items/complete_spec.rb:23:in block (4 levels) in <top (required)>' # ./spec/features/todo_items/complete_spec.rb:22:inblock (3 levels) in <top (required)>'

Here is the test:

it "shows completed items as complete" do
      visit_todo_list todo_list
      within dom_id_for(completed_todo_item) do
        expect(page).to have_content(completed_todo_item.completed_at)
      end
    end

and here is the index.html.erb output:

<% if todo_item.completed? %>
        <%= todo_item.completed_at %>
      <% else %>
        <%= link_to "Mark Complete", complete_todo_list_todo_item_path(todo_item), method: :patch %>
      <% end %>

The only thing I can think is that the printed value of .completed_at is different from the value stored in the db?!?

Has anyone ever seen this?

1 Answer

Hi James,

I just added some explanation of this in another post. It is a confusing error, I agree!

I hope that helps,

Steve.