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 trialJohn Jobe
1,603 PointsI am receiving an error that states "uninitialized constant" which is accompanied by a deprecation warning.
Failures:
1) Creating todo lists displays an error when the todo list has no title Failure/Error: expect(Todolist.count).to eq(0) NameError: uninitialized constant Todolist # ./spec/features/todo_lists/create_spec.rb:17:in `block (2 levels) in <top (required)>'
2) Creating todo lists displays an error when the todo list has a title less than 3 characters Failure/Error: expect(Todolist.count).to eq(0) NameError: uninitialized constant Todolist # ./spec/features/todo_lists/create_spec.rb:35: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/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>')
2 Answers
Chris Shaw
26,676 PointsHi John,
Based on the error you appear to have a typo as you have Todolist
but the l is lowercase not uppercase, simply change it to TodoList
and the error should go away, as for the deprecation error you won't need to worry about that for the moment as until Rspec 3 is released the tests will run as shown in the video.
Sahil Prajapati
8,524 PointsHi John,
For removing the deprecation warning you should open this file spec/spec_helper.rb and then add the line config.expose_current_running_example_as :example like this:
RSpec.configure do |config|
#add this line inside the block
config.expose_current_running_example_as :example
end
This should work for you.
Akbar Khatibi
8,137 Pointswhere exactly does this go? does it matter? just before the last end?