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 PointsGetting failures when I shouldn't be...
I tried asking this question a couple of days ago and I need more help because the answer isn't coming. I'd like to request the help of a MOD or INSTRUCTOR, please.
I'm getting this from my rspec 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 ')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
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 ')
--------------------------------------------------------------------------------
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
I will provide the code when contacted by a MOD or INSTRUCTOR, or someone who can actually help. :)
4 Answers
Joel Smith
14,779 PointsI have since successfully completed this course without any difficulties. The issue was that My rails and Rspec were the wrong versions!
Roberto Alicata
Courses Plus Student 39,959 Pointsis your app/views/todo_lists/new.html.erb like this?
<h1>New todo_list</h1>
<%= render 'form' %>
<%= link_to 'Back', todo_lists_path %>
Joel Smith
14,779 PointsNope, it is like this...
app/views/todo_lists/new.html.erb_spec.rb:
require 'spec_helper'
describe "todo_lists/new" do
before(:each) do
assign(:todo_list, stub_model(TodoList,
:title => "MyString",
:description => "MyText"
).as_new_record)
end
it "renders new todo_list form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form[action=?][method=?]", todo_lists_path, "post" do
assert_select "input#todo_list_title[name=?]", "todo_list[title]"
assert_select "textarea#todo_list_description[name=?]", "todo_list[description]"
end
end
end
there is no file called: app/views/todo_lists/new.html.erb
Roberto Alicata
Courses Plus Student 39,959 PointsYou've made some mistakes in the previous steps to create the Rails application, probably when you generated the scaffold for the todo_list model.
I recap the steps:
1 - open the terminal, go to your working directory and write:
rails new odot
cd odot
2 - now you need to configure GIT with your email and name
git config --global user.email "my@email.com"
git config --global user.name "My Name"
3 - initialize GIT
git init
4 - add all file to GIT
git add .
5 - commit
git commit -m "My Message"
6 - Now open your project in the text edito and add these lines to the Gemfile:
group :development, :test do
gem 'rspec-rails', '~> 2.0'
end
group :test do
gem 'capybara', '~> 2.1.0'
end
7 - Add these lines to spec/spec_helper.rb
require 'capybara/rspec'
8 - Go to the console and write:
bundle
bundle binstubs rspec-core
9 - In the console write:
bin/rails generate rspec:install
rm -rf test/
10 - [generate the scaffold] In the console write:
bin/rails generate scaffold todo_list title:string description:text
bin/rake db:migrate
bin/rake db:migrate RAILS_ENV=test
11 - Add this line to config/routes.rb file:
root 'todo_lists#index'
NOW you are ready to redo the video "Write Our First Tests"
Joel Smith
14,779 Pointswell... your instruction has left Me without spec... I'll just start the whole project again.
I'm also getting an error when using bundle:
There was an error in your Gemfile, and Bundler cannot continue..
Nice try, though. I'm going to start the whole thing over after I've done the Ruby track and hope that it works next time.
Roberto Alicata
Courses Plus Student 39,959 PointsWhat's the error in the Gemfile ?
Joel Smith
14,779 Pointsit didn't say. As I said, I'm going to complete the Ruby track, then come back to RonR at a later date, when I feel like I understand what's going on a bit better.