Skip to content

Global before :all hooks with specified :type are not run with 2.14.0 #825

@jarmo

Description

@jarmo

Specifying global before :all hooks for specified :type does not work with rspec-rails version 2.14.0.

Here's how to reproduce it:

  1. generate an empty project
> rails -v
Rails 4.0.0

> rails new rspec-rails-broken
      create
      create  README.rdoc
      create  Rakefile
      create  config.ru
      ...
  1. add rspec-rails into Gemfile:
# Gemfile

group :development, :test do
  gem 'rspec-rails', '2.14.0'
end
  1. setup it:
> bundle install
> rails g rspec:install
  1. add a before hook with specific type into spec_helper:
RSpec.configure do |config|
  config.before :all, type: :request do
    raise "should fail!"
  end
end
  1. create a request spec:
# spec/requests/failing_spec.rb

require "spec_helper"

describe "always failing" do
  it "should fail" do
  end
end
  1. execute the spec and hope for failure:
> bundle exec rake db:migrate spec
ruby -S rspec ./spec/requests/failing_spec.rb
.

Finished in 0.002 seconds
1 example, 0 failures
  1. the spec did not fail! This is because that before :all got not executed. The same happens when using different type - controller for example for spec/controllers/*_spec.rb.

It will work as inspected if using before :each instead or if downgrading to 2.13.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions