this has been driving me crazy. Please help, I'm sure it's a simple fix, even though it's for a silly treehouse todo app. (So those of you experienced programmers on your lunchbreak please help me out, I wouldn't resort to this if it was needed).
I'm trying to create an authentication system, and I'm getting failures for not being able to find css"#todo_list_1"
This is all after I run BIN/RAKE
Here's a list of my failures:
Failures:
1) Editing todo items is successful with valid content
Failure/Error: visit_todo_list(todo_list)
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/edit_spec.rb:9:in `block (2 levels) in <top (required)>'
2) Editing todo items is unsuccessful with not enough content
Failure/Error: visit_todo_list(todo_list)
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/edit_spec.rb:34:in `block (2 levels) in <top (required)>'
3) Editing todo items is unsuccessful with no content
Failure/Error: visit_todo_list(todo_list)
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/edit_spec.rb:21:in `block (2 levels) in <top (required)>'
4) Editing todo lists updates a todo list successfully with correct information
Failure/Error: within "#todo_list_#{todo_list.id}" do
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/features/todo_lists/edit_spec.rb:14:in `update_todo_list'
# ./spec/features/todo_lists/edit_spec.rb:24:in `block (2 levels) in <top (required)>'
5) Editing todo lists displays an error with too short a title
Failure/Error: within "#todo_list_#{todo_list.id}" do
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/features/todo_lists/edit_spec.rb:14:in `update_todo_list'
# ./spec/features/todo_lists/edit_spec.rb:44:in `block (2 levels) in <top (required)>'
6) Editing todo lists displays an error with no title
Failure/Error: within "#todo_list_#{todo_list.id}" do
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/features/todo_lists/edit_spec.rb:14:in `update_todo_list'
# ./spec/features/todo_lists/edit_spec.rb:54:in `block (2 levels) in <top (required)>'
7) Editing todo lists displays an error with no description
Failure/Error: within "#todo_list_#{todo_list.id}" do
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/features/todo_lists/edit_spec.rb:14:in `update_todo_list'
# ./spec/features/todo_lists/edit_spec.rb:49:in `block (2 levels) in <top (required)>'
8) Editing todo lists displays an error with no title
Failure/Error: within "#todo_list_#{todo_list.id}" do
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/features/todo_lists/edit_spec.rb:14:in `update_todo_list'
# ./spec/features/todo_lists/edit_spec.rb:36:in `block (2 levels) in <top (required)>'
9) Deleting todo lists is successful when clicking the destroy link
Failure/Error: within "#todo_list_#{todo_list.id}" do
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/features/todo_lists/destroy_spec.rb:9:in `block (2 levels) in <top (required)>'
10) todo_lists/index renders a list of todo_lists
Failure/Error: assert_select "tr>td", :text => "Title".to_s, :count => 2
Minitest::Assertion:
Expected exactly 2 elements matching "tr > td", found 0..
Expected: 2
Actual: 0
# ./spec/views/todo_lists/index.html.erb_spec.rb:20:in `block (2 levels) in <top (required)>'
11) Completing todo items is successful when marking a single item complete
Failure/Error: visit_todo_list todo_list
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/complete_spec.rb:9:in `block (2 levels) in <top (required)>'
12) Completing todo items with completed items shows completed items as complete
Failure/Error: visit_todo_list todo_list
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/complete_spec.rb:21:in `block (3 levels) in <top (required)>'
13) Completing todo items with completed items does not give the option to make complete
Failure/Error: visit_todo_list todo_list
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/complete_spec.rb:28:in `block (3 levels) in <top (required)>'
14) Viewing todo items displays the title of the todo list
Failure/Error: visit_todo_list(todo_list)
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/index_spec.rb:8:in `block (2 levels) in <top (required)>'
15) Viewing todo items displays item content when a todo list has items
Failure/Error: visit_todo_list(todo_list)
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/index_spec.rb:23:in `block (2 levels) in <top (required)>'
16) Viewing todo items displays no items when a todo list is empty
Failure/Error: visit_todo_list(todo_list)
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/index_spec.rb:15:in `block (2 levels) in <top (required)>'
17) Adding todo items is successful with valid content
Failure/Error: visit_todo_list(todo_list)
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/create_spec.rb:9:in `block (2 levels) in <top (required)>'
18) Adding todo items displays an error with content les than 2 characters long
Failure/Error: visit_todo_list(todo_list)
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/create_spec.rb:31:in `block (2 levels) in <top (required)>'
19) Adding todo items displays an error with no content
Failure/Error: visit_todo_list(todo_list)
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/create_spec.rb:20:in `block (2 levels) in <top (required)>'
20) Deleting todo items is successful
Failure/Error: visit_todo_list(todo_list)
Capybara::ElementNotFound:
Unable to find css "#todo_list_1"
# ./spec/support/todo_list_helpers.rb:4:in `visit_todo_list'
# ./spec/features/todo_items/delete_spec.rb:9:in `block (2 levels) in <top (required)>'
Here's a list of my ./spec/support/todo_list_helpers.rb:4
module TodoListHelpers
def visit_todo_list(list)
visit "/todo_lists"
within dom_id_for(list) do
click_link "List Items"
end
end
end
Here's a list of my ./spec/views/todo_lists/index.html.erb_spec
require 'spec_helper'
describe "Deleting todo lists" do
let!(:todo_list) { TodoList.create(title: "Groceries", description: "Grocery list.") }
it "is successful when clicking the destroy link" do
visit "/todo_lists"
within "#todo_list_#{todo_list.id}" do
click_link "Destroy"
end
expect(page).to_not have_content(todo_list.title)
expect(TodoList.count).to eq(0)
end
end
Here's a list of my ./spec/views/todo_lists/index.html.erb_spec
require 'spec_helper'
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
***Here's my app/views/todo_lists/index.html.erb
<h1>Todo Lists</h1>
<% @todo_lists.each do |todo_list| %>
<div class="todo_list" id"<%= dom_id(todo_list) %>">
<h2><%= todo_list.title %></h2>
<p><%= todo_list.description %></p>
<ul class="functions">
<li><%= link_to "List Items", todo_list_todo_items_path(todo_list) %></li>
<li><%= link_to 'Show', todo_list %></li>
<li><%= link_to 'Edit', edit_todo_list_path(todo_list) %></li>
<li><%= link_to 'Destroy', todo_list, method: :delete, data: { confirm: 'Are you sure?' } %></li>
</ul>
<br class="clear" />
</div>
<% end %>
<br>
<%= link_to 'New Todo list', new_todo_list_path %>
#index
view which we cannot see. – engineersmnky