Rspec error cannot find matching line from backtrace

rspec, rspec-rails

Solution

The problem here is that you have not specified a block for the before method:

before @user = User.new(name: 'example', password: 'foobar', password_confirmation: 'foobar',
                    email: 'example@example.com', description: 'Lorem ipsum dolor...')

should be:

before do
  @user = User.new(name: 'example', password: 'foobar', password_confirmation: 'foobar',
                    email: 'example@example.com', description: 'Lorem ipsum dolor...')
end

Admittedly the error message is not very helpful here. The Ruby interpreter can't always pinpoint the exact line in the program that an error is raised, e.g. when there is a Stack level deep error' but I'm not sure why it cannot in this case.

Problem

I have written a group of 23 tests for my user model and all of them are failing with the following error: ``` Failure/Error: Unable to find matching line from backtrace ArgumentError: block not supplied ``` I have tried messing with different versions of capybara, rspec-rails, and growl, but to be perfectly honest, I really don't know what I'm doing here, and don't really understand the error. I would really appreciate help from anyone who could point me in the right direction. Here is a sample from my `user_spec.rb` file ``` require 'spec_helper' describe User do before @user = User.new(name: 'example', password: 'foobar', password_confirmation: 'foobar', email: 'example@example.com', description: 'Lorem ipsum dolor...') subject { @user } it { should respond_to(:name) } it { should respond_to(:email) } it { should respond_to(:password) } it { should respond_to(:password_confirmation) } it { should respond_to(:password_digest) } it { should respond_to(:description) } it { should respond_to(:admin) } it { should respond_to(:remember_token) } describe "when name is not present" do before { @user.name = " " } it { should_not be_valid } end . . . end ``` Here are the relevant parts of my `Gemfile`: ``` group :development do gem 'rspec-rails', '2.11.0' gem 'guard' gem 'guard-spork', :github => 'guard/guard-spork' gem 'guard-rspec' gem 'spork' gem 'sqlite3' end group :test do gem 'capybara', '1.1.2' gem 'rb-fsevent', '0.9.1', :require => false gem 'growl', '1.0.3' gem 'factory_girl_rails', '4.1.0' end ``` Thanks for reading!

Original source

Related problems