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 trialHarrison Hondo
7,283 PointsCan't figure out how to fix error
I've been following Jason's videos and can't figure out why I am receiving this error when running
bin/rspec --format=documentation spec/features/todo_items/create_spec.rb
Adding todo items
is successful with valid content (FAILED - 1)
Failures:
1) Adding todo items is successful with valid content
Failure/Error: fill_in "Content", with: "Milk"
Capybara::ElementNotFound:
Unable to find field "Content"
# ./spec/features/todo_items/create_spec.rb:16:in `block (2 levels) in <top (required)>'
Finished in 0.41681 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/features/todo_items/create_spec.rb:13 # Adding todo items is successful with valid content
Randomized with seed 41716
My Github repository for the project is: https://github.com/hondoh/ODOT
5 Answers
Jim Withington
12,025 PointsHello Harrison Hondo !
I went to your code over here and it didn't seem to have a commit from today. There's also no create_spec.rb, so it looks like maybe you didn't push your most recent commits to Github.
Other than that, remember: the error messages are gold! Try starting with line 13 of your spec -- thats where the problem is starting!
Hope this helps!
Jim Withington
12,025 PointsHi Harrison Hondo,
Well, it looks like that create spec is still not showing in your Github repo. I wonder if maybe you didn't commit all of the files.
At any rate, some things:
Sometimes in the later stages of the ODOT classes, Jason makes changes between videos that change how the tests and stuff work. You might want to compare your code with the code for the video you worked on, or even for the following video, and see what you may have left out.
Your error is also mentioning that it's
Unable to find field "Content"
. I'm pretty new at this so this is a bit of a stab in the dark, but I wonder if one of your views or forms just doesn't have that field listed. In fact, I noticed this when I searched for "content" in your repo:
Looks like maybe your code didn't create "content" in your database. As a result, you might have to rollback your database, change the code, and then re-rake it. Here's some help for that. Good luck, and please do let me know how it goes!
Jim Withington
12,025 PointsThanks for the best answer click! Is everything working now?
Jim Withington
12,025 PointsThanks for the best answer click! Is everything working now?
Dave Alexander
4,894 PointsI am getting this error and can't find an answer anywhere.
1) Editing todo items is successful with valid content Failure/Error: fill_in "Content", with: "Lots of Milk" Capybara::ElementNotFound: Unable to find field "Content" # ./spec/features/todo_items/edit_spec.rb:19:in `block (2 levels) in <top (required)>'
MY CODE:
require 'spec_helper'
describe "Editing todo items" do let!(:todo_list) { TodoList.create(title: "Grocery List", description: "Groceries") } let!(:todo_item) { todo_list.todo_items.create(content: "Milk") }
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.content).to eq("Lots of Milk")
end
end
Harrison Hondo
7,283 PointsHarrison Hondo
7,283 PointsOh, oops I just made a new commit to reflect the changes I've made. I'm still not sure about what the issue is though.
https://github.com/hondoh/ODOT