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 trialJoel Smith
14,779 Points2 failed tests upon rspec create spec.rb expecting 0 failed tests as per the video at this stage.
I have found the fix for the deprecation errors that are included with this message, but I am stumped as to why I'm getting 2 failures here at this stage when Jason is getting 0 failures.
The following is My test;
joel@joel-U80A:~/workspace/odot$ bin/rspec spec/features/todo_lists/create_spec.rb
FF
Failures:
1) Creating todo lists redirects to the todo list index page on success
Failure/Error: expect(page).to have_content("New todo_list")
expected to find text "New todo_list" in "New Todo List Title Description Back"
# ./spec/features/todo_lists/create_spec.rb:7:in `block (2 levels) in <top (required)>'
2) Creating todo lists displays an error when the todo list has no title
Failure/Error: expect(page).to have_content("New todo_list")
expected to find text "New todo_list" in "New Todo List Title Description Back"
# ./spec/features/todo_lists/create_spec.rb:22:in `block (2 levels) in <top (required)>'
Deprecation Warnings:
--------------------------------------------------------------------------------
RSpec::Core::ExampleGroup#example is deprecated and will be removed
in RSpec 3. There are a few options for what you can use instead:
- rspec-core's DSL methods (`it`, `before`, `after`, `let`, `subject`, etc)
now yield the example as a block argument, and that is the recommended
way to access the current example from those contexts.
- The current example is now exposed via `RSpec.current_example`,
which is accessible from any context.
- If you can't update the code at this call site (e.g. because it is in
an extension gem), you can use this snippet to continue making this
method available in RSpec 2.99 and RSpec 3:
RSpec.configure do |c|
c.expose_current_running_example_as :example
end
(Called from /home/joel/workspace/odot/path/ruby/2.1.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
RSpec::Core::ExampleGroup#example is deprecated and will be removed
in RSpec 3. There are a few options for what you can use instead:
- rspec-core's DSL methods (`it`, `before`, `after`, `let`, `subject`, etc)
now yield the example as a block argument, and that is the recommended
way to access the current example from those contexts.
- The current example is now exposed via `RSpec.current_example`,
which is accessible from any context.
- If you can't update the code at this call site (e.g. because it is in
an extension gem), you can use this snippet to continue making this
method available in RSpec 2.99 and RSpec 3:
RSpec.configure do |c|
c.expose_current_running_example_as :example
end
(Called from /home/joel/workspace/odot/path/ruby/2.1.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:21:in `block (2 levels) in <top (required)>')
--------------------------------------------------------------------------------
If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.
2 deprecation warnings total
Finished in 0.23995 seconds
2 examples, 2 failures
Failed examples:
rspec ./spec/features/todo_lists/create_spec.rb:4 # Creating todo lists redirects to the todo list index page on success
rspec ./spec/features/todo_lists/create_spec.rb:16 # Creating todo lists displays an error when the todo list has no title
Randomized with seed 49310
This is My code in create_spec.rb
require 'spec_helper'
describe "Creating todo lists" do
it "redirects to the todo list index page on success" do
visit "/todo_lists"
click_link "New Todo list"
expect(page).to have_content("New todo_list")
fill_in "Title", with: "My todo list"
fill_in "Description", with: "This is what I'm doing today."
click_button "Create Todo list"
expect(page).to have_content("My todo list")
end
it "displays an error when the todo list has no title" do
expect(TodoList.count).to eq(0)
visit "/todo_lists"
click_link "New Todo list"
expect(page).to have_content("New todo_list")
fill_in "Title", with: ""
fill_in "Description", with: "This is what I'm doing today."
click_button "Create Todo list"
expect(page).to have_content("error")
expect(TodoList.count).to eq(0)
visit "/todo_lists"
expect(page).to_not have_content("This is what I'm doing today.")
end
end
And this is todo_list.rb
class TodoList < ActiveRecord::Base
validates :title, presence: true
end
5 Answers
Joel Smith
14,779 PointsNothing is working. I'm pretty stumped. Can I get a MOD or an INSTRUCTOR to help Me out with this please?
Charlie Jaime
17,351 PointsWell after reviewing your code, I think it might be a minor mistake to 2 places with this code: expect(page).to have_content("New todo_list") just remove the underscore in "New todo_list" and have "New Todo List" instead that should work.
if you like my answer vote me up or mark me for the best answer thank you and great coding!
Joel Smith
14,779 PointsThanks Charlie, but that wasn't the answer. I did that in all iterations of My tests, but it didn't work.
David Bell
16,997 PointsThis helped me. Thanks!
Josiah Schaefer
7,489 PointsHey this worked! Thank you!
Raghav Mangrola
3,050 PointsThank you, this helped me!
Charlie Jaime
17,351 PointsBUMMER! here is my code when I did this part use to compare hope it helps.
describe "Creating todo lists" do it "redirects to the todo list index page on success" do visit "/todo_lists" click_link "New Todo list" expect(page).to have_content("New Todo List")
fill_in "Title", with: "My todo list"
fill_in "Description", with: "This is what I'm doing today."
click_button "Create Todo list"
expect(page).to have_content("My todo list")
end
it "displays an error when the todo list has no title" do
expect(TodoList.count).to eq(0)
visit "/todo_lists"
click_link "New Todo list"
expect(page).to have_content("New Todo List")
fill_in "Title", with: ""
fill_in "Description", with: "This is what I'm doing today."
click_button "Create Todo list"
expect(page).to have_content("error")
expect(TodoList.count).to eq(0)
visit "/todo_lists"
expect(page).to_not have_content("This is what I'm doing today.")
end
end
Darren Emory
Courses Plus Student 4,076 PointsI, too, noticed in the video that he wrote: expect(page).to have_content("New todo_list")
- where I think the correct argument is expect(page).to have_content("New todo list")
- changing this helped solve one RSPEC error for me.
Darren Emory
Courses Plus Student 4,076 PointsFound my bug.
I had expect(Todolist.count).to eq(0)
when it should have been expect(TodoList.count).to eq(0)
- need that capital 'L' in TodoList.
All clear now. No errors! Feels good, man.
Jennifer Poole
4,318 PointsI'm having similar problems. I'm getting a failure at this point, too -- have tried removing the underscore, putting in back in -- and am assuming it has something to do with the versions of Ruby, Rails, and rspec? I'm not computer-savvy enough to diagnose this, but am currently running Ruby 2.1.2, Rails 4.1.7, and rspec 2.99.2.
Any red flags there? Thank you.
Joel Smith
14,779 PointsI also installed the latest versions of all of the applications. If downgrading is the solution. perhaps upgrading the course is the TRUE answer.