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 trialDavid Ho
1,482 PointsError when : rspec spec/features/todo_lists/create_spec.rb
I got an Error : .... C:\Treehouse\Project\odot (master) λ rspec spec/features/todo_lists/create_spec.rb FF
Failures:
1) Creating Todo lists redirect to the todo list index page on success Failure/Error: expect(page).to have_content("New todo_lists") expected to find text "New todo_lists" in "New Todo List Title Description Back" # ./spec/features/todo_lists/create_spec.rb:6: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_lists") expected to find text "New todo_lists" in "New Todo List Title Description Back" # ./spec/features/todo_lists/create_spec.rb:19: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 C:/Ruby21/lib/ruby/gems/2.1.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>')
---------- AND Below are my code ---------- require 'spec_helper' describe "Creating Todo lists" do it "redirect to the todo list index page on success" do visit "/todo_lists" click_link "New Todo list" expect(page).to have_content("New todo_lists")
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_lists")
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 have_content("This is what I'm doing today.")
end
end
I need your help ! what I have to do to solve this issue. Thank you.
3 Answers
Justin Black
24,793 PointsYou did the same thing I did, which is relying on the instructor to actually write passing code ( while his passes, it should not )
The line:
expect(page).to have_content("New todo_list")
should actually be:
expect(page).to have_content("New Todo List")
David Ho
1,482 PointsHi Justin , Paste your code into create_spec.rb?
I got this : ...
C:\Treehouse\Project\odot (master)
λ rspec spec/features/todo_lists/create_spec.rb
C:/Treehouse/Project/odot/spec/features/todo_lists/create_spec.rb:15:in <top (required)>': undefined method
it' for main:Object (NoMethodError)
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:in load'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:in
block in load_spec_files'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:in each'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:in
load_spec_files'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:18:in run'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:103:in
run'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:17:in `block in autorun'
C:\Treehouse\Project\odot (master) ...
David Ho
1,482 PointsHi Justin,
I'm still can't get my problem solved. Please help me ! It stopped from moving forward. I got and Error - kindly help Here is my code :
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 end
Here is my Error Message:
C:\Treehouse\Project\odot ((detached from d64afef)) λ rspec spec/features/todo_lists/create_spec.rb
Failures:
1) Creating todo lists redirects to the todo list index page on success Failure/Error: click_link "New Todo list" NoMethodError: undefined method click_link' for <RSpec::ExampleGroups::CreatingTodoLists:0x45c5cb8> # ./spec/features/todo_lists/create_spec.rb:6:inblock (2 levels) in '
Finished in 0.001 seconds (files took 1 second to load) 1 example, 1 failure
Failed examples: rspec ./spec/features/todo_lists/create_spec.rb:4 # Creating todo lists redirects to the todo list index page on succes C:\Treehouse\Project\odot ((detached from d64afef))
Justin Black
24,793 PointsWell, do you have capybara in your gem file? in your spec file are you requiring capybara/rspec and capybara/rails?
You can try putting include Capybara::DSL in your environment...
Aside from that I'm not sure. If none of that fixes your issues, i'm going to pull the "i'm greater than thou" response and say ditch windows and get on linux. Much easier, less headache, and it's not by microsoft... It's a 3 way win... If this site did hashtags, i'd type #microsoftsucks right about now...
But seriously, if you're using windows to develop on -- you're not a real developer.
David Ho
1,482 PointsDavid Ho
1,482 PointsHi Justin I still can't get this thing solve after make changes of what you advised me.
Failures:
1) Creating Todo lists redirect to the todo list index page on success Failure/Error: expect(page).to have_content("My Todo List") expected to find text "My Todo List" in "Todo list was successfully created. Title: My todo list Description: This is what I'm doing today. Edit | Back" # ./spec/features/todo_lists/create_spec.rb:11: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("error") expected to find text "error" in "Todo list was successfully created. Title: Description: This is what I'm doing today. Edit | Back" # ./spec/features/todo_lists/create_spec.rb:26:in `block (2 levels) in <top (required)>'
Failed examples:
rspec ./spec/features/todo_lists/create_spec.rb:3 # Creating Todo lists redirect to the todo list index page on success rspec ./spec/features/todo_lists/create_spec.rb:14 # Creating Todo lists displays an error when the todo list has no title
--please help! -- What is wrong with the code.
Justin Black
24,793 PointsJustin Black
24,793 Pointsif it still fails, then it's either the html.erb file or the controller that has issues.
mikeaarts2
Courses Plus Student 4,249 Pointsmikeaarts2
Courses Plus Student 4,249 PointsThanks, Justin.
This makes sense and also worked for me.
Justin Black
24,793 PointsJustin Black
24,793 PointsGood, glad it works.