Rspec-rails-2.4.0 is released!

rspec-rails-2.4.0 / 2011-01-02

full
changelog

  • Enhancements

    • include ApplicationHelper in helper object in helper specs
    • include request spec extensions in files in spec/integration
    • include controller spec extensions in groups that use :type =>
      :controller
      • same for :model, :view, :helper, :mailer, :request, :routing
  • Bug fixes

    • restore global config.render_views so you only need to say it once
    • support overriding render_views in nested groups
    • matchers that delegate to Rails’ assertions capture
      ActiveSupport::TestCase::Assertion (so they work properly now with
      should_not in Ruby 1.8.7 and 1.9.1)
  • Deprecations

    • include_self_when_dir_matches

I just upgraded from 2.3.1 and I now get this error on all my specs…
Nothing else changed and the Upgrade.md does not indicate any backward
compatibilities unless I missed something.

(in /home/morris/work/ruby/rails3/wolfmanblog)
/opt/ruby-enterprise-1.8.7-2010.02/bin/ruby -S bundle exec rspec ./
spec/controllers/posts_controller_spec.rb
[sequel] Setting up the “test” environment:
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined
method setup' for #<Class:0xa24723c> (NoMethodError) from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:52:inclass_eval’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
activesupport-3.0.3/lib/active_support/concern.rb:52:in
append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ actionpack-3.0.3/lib/action_controller/test_case.rb:439:ininclude’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
actionpack-3.0.3/lib/action_controller/test_case.rb:439
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
activesupport-3.0.3/lib/active_support/concern.rb:52:in class_eval' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:52:inappend_features’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
activesupport-3.0.3/lib/active_support/concern.rb:48:in include' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:insend’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
activesupport-3.0.3/lib/active_support/concern.rb:48:in
append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:ineach’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
activesupport-3.0.3/lib/active_support/concern.rb:48:in
append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:ininclude’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in send' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:inconfigure_group’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in each' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:inconfigure_group’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/world.rb:35:in configure_group' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:inset_it_up’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in subclass' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:indescribe’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in describe' from /home/morris/work/ruby/rails3/wolfmanblog/spec/ controllers/posts_controller_spec.rb:3 from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:inload’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in
load_spec_files' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:inmap’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in
load_spec_files' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:inrun’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in run_in_process' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/runner.rb:46:inrun’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/bin/
rspec:19
rake aborted!
ruby -S bundle exec rspec ./spec/controllers/posts_controller_spec.rb
failed

(See full trace by running task with --trace)

On Sun, Jan 2, 2011 at 9:09 PM, Jim M. [email protected] wrote:

method setup' for #<Class:0xa24723c> (NoMethodError) activesupport-3.0.3/lib/active_support/concern.rb:52:in class_eval’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
configure_group' rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in subclass’
load_spec_files' rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in run’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/bin/
rspec:19
rake aborted!
ruby -S bundle exec rspec ./spec/controllers/posts_controller_spec.rb
failed

I’m not seeing this in any of my apps. Seems like a configuration or
load order problem. Can you post your Gemfile and spec/spec_helper.rb?

Yes I can, the full app is on

although I downgraded back to rspec-rails 2.3.1, before I did that my
Gemfile.lock looked like…

GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.3)
actionpack (= 3.0.3)
mail (~> 2.2.9)
actionpack (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
tzinfo (~> 0.3.23)
activemodel (3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
arel (2.0.6)
builder (2.1.2)
cells (3.4.2)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
factory_girl (1.3.2)
factory_girl_rails (1.0)
factory_girl (~> 1.3)
rails (>= 3.0.0.beta4)
haml (3.0.24)
i18n (0.5.0)
mail (2.2.12)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
nokogiri (1.4.4)
pg (0.10.0)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.3)
actionmailer (= 3.0.3)
actionpack (= 3.0.3)
activerecord (= 3.0.3)
activeresource (= 3.0.3)
activesupport (= 3.0.3)
bundler (~> 1.0)
railties (= 3.0.3)
railties (3.0.3)
actionpack (= 3.0.3)
activesupport (= 3.0.3)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
rdiscount (1.6.5)
rspec (2.4.0)
rspec-core (~> 2.4.0)
rspec-expectations (~> 2.4.0)
rspec-mocks (~> 2.4.0)
rspec-cells (0.0.2)
cells (~> 3.4)
rails (~> 3.0)
rspec-rails (~> 2.2)
rspec-core (2.4.0)
rspec-expectations (2.4.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.4.0)
rspec-rails (2.4.0)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.4.0)
sequel (3.17.0)
sequel-rails (0.1.8)
actionpack (~> 3.0.0)
activesupport (~> 3.0.0)
railties (~> 3.0.0)
sequel (~> 3.13)
stringex (1.2.0)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.23)
uuidtools (2.1.1)
webrat (0.7.2)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)

PLATFORMS
ruby

DEPENDENCIES
cells
factory_girl_rails
haml
pg
rails (= 3.0.3)
rdiscount
rspec-cells
rspec-rails (~> 2.3)
sequel-rails
stringex
uuidtools
webrat

Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.23)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.12)
Using actionmailer (3.0.3)
Using arel (2.0.6)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.3)
Using cells (3.4.2)
Using diff-lcs (1.1.2)
Using factory_girl (1.3.2)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
Using factory_girl_rails (1.0)
Using haml (3.0.24)
Using nokogiri (1.4.4)
Using pg (0.10.0)
Using rdiscount (1.6.5)
Using rspec-core (2.4.0)
Using rspec-expectations (2.4.0)
Using rspec-mocks (2.4.0)
Using rspec (2.4.0)
Using rspec-rails (2.4.0)
Using rspec-cells (0.0.2)
Using sequel (3.17.0)
Using sequel-rails (0.1.8)
Using stringex (1.2.0)
Using uuidtools (2.1.1)
Using webrat (0.7.2)

and spec_helper.rb looked like…

This file is copied to spec/ when you run 'rails generate

rspec:install’
ENV[“RAILS_ENV”] ||= ‘test’
require File.expand_path(“…/…/config/environment”, FILE)
require ‘rspec/rails’

Requires supporting ruby files with custom matchers and macros, etc,

in spec/support/ and its subdirectories.

Dir[Rails.root.join(“spec/support/**/*.rb”)].each {|f| require f}

RSpec.configure do |config|

== Mock Framework

If you prefer to use mocha, flexmock or RR, uncomment the

appropriate line:

config.mock_with :mocha

config.mock_with :flexmock

config.mock_with :rr

config.mock_with :rspec

setup transactional factory for sequel, when running transactional

tests
config.around(:each, :transactional => true) do |example|
Sequel::DATABASES.first.transaction do
example.run
raise Sequel::Error::Rollback
end
end

end

to make factory girl run with sequel

class Sequel::Model
def save!
save(:validate=>false)
end
end

I forgot to mention that I did get a deprecation warning from rspec-
cells (they haven’t updated it yet), but I fixed it by doing what the
deprecation warning said. I don’t think that has anything to do with
the error I am getting though.

On Sun, Jan 2, 2011 at 10:12 PM, Jim M. [email protected] wrote:

Yes I can, the full app is on GitHub - wolfmanjm/wolfmanblog_rails: Wolfman blog ported to rails 3
although I downgraded back to rspec-rails 2.3.1, before I did that my
Gemfile.lock looked like…

Thanks for that.

The problem is with rspec-cells, but I’m not clear yet on the root
cause. Something to do with the way it’s hooking itself into the
framework is failing.

I’ll follow up if/when I have some new information, but it might be a
day or two.

The problem is with rspec-cells, but I’m not clear yet on the root
cause. Something to do with the way it’s hooking itself into the
framework is failing.

I totally removed rspec-cells from my gems and bundle, but I still get
the same failure, so I’m not convinced it is rspec-cells, it did give
a deprecation error but that is easily fixed.

On Sun, Jan 2, 2011 at 10:20 PM, Jim M. [email protected] wrote:

I forgot to mention that I did get a deprecation warning from rspec-
cells (they haven’t updated it yet), but I fixed it by doing what the
deprecation warning said. I don’t think that has anything to do with
the error I am getting though.

I didn’t realize other libs were using it. Now that I know they are I
may consider reversing the deprecation, though I’m not convinced it’s
really the best API, so I’ll have to give that some thought.

That aside, the commit that made that method obsolete within rspec-rails
was:

If you have some time to investigate, please see if reversing that
commit solves the problem. Should point us in the right direction.

On Sun, Jan 2, 2011 at 11:01 PM, Jim M. [email protected] wrote:

I removed the rspec-cells gem but that did not do anything to help.

So if you were to checkout my project and change the Gemfile to get
rspec 2.4.0 then run…

rspec spec/controllers/posts_controller_spec.rb

you should get this dump…

The around hook is a red herring too.

This is very odd. I’m not sure what it is yet, but it’s something to
do with the load order of modules. I can’t reproduce this in my apps,
but I can in yours with no problem.

Onward …

Ok I re installed rspec-rails 2.4.0 looks like my request specs run,
and my model specs run but my
controller specs and helper specs do not run, and throw that error.

I have that config.around… in my spec_helper which applies to most
request specs but not to the helper specs or controller specs (which
use mocks), so that is a difference, the around does NOT run when the
helpers or controller specs run, but I don’t see how that would cause
this error.

I removed the rspec-cells gem but that did not do anything to help.

So if you were to checkout my project and change the Gemfile to get
rspec 2.4.0 then run…

rspec spec/controllers/posts_controller_spec.rb

you should get this dump…

[sequel] Setting up the “test” environment:
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined
method setup' for #<Class:0xa1bda8c> (NoMethodError) from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:52:inclass_eval’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
activesupport-3.0.3/lib/active_support/concern.rb:52:in
append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ actionpack-3.0.3/lib/action_controller/test_case.rb:439:ininclude’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
actionpack-3.0.3/lib/action_controller/test_case.rb:439
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
activesupport-3.0.3/lib/active_support/concern.rb:52:in class_eval' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:52:inappend_features’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
activesupport-3.0.3/lib/active_support/concern.rb:48:in include' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:insend’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
activesupport-3.0.3/lib/active_support/concern.rb:48:in
append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:ineach’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
activesupport-3.0.3/lib/active_support/concern.rb:48:in
append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:ininclude’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in send' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:inconfigure_group’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in each' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:inconfigure_group’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/world.rb:35:in configure_group' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:inset_it_up’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in subclass' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:indescribe’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in describe' from /home/morris/work/ruby/rails3/wolfmanblog/spec/ controllers/posts_controller_spec.rb:3 from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:inload’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in
load_spec_files' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:inmap’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in
load_spec_files' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:inrun’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in run_in_process' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/runner.rb:46:inrun’
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/
rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun’
from /opt/ruby-enterprise-1.8.7-2010.02/bin/rspec:19

On Sun, Jan 2, 2011 at 11:51 PM, David C. [email protected]
wrote:

This is very odd. I’m not sure what it is yet, but it’s something to
do with the load order of modules. I can’t reproduce this in my apps,
but I can in yours with no problem.

Onward …

Found it. Will release a bug fix release of rspec-rails shortly.

I don’t understand why I hadn’t seen it in any of my apps, or in
rspec’s own spec suite, but it boils down to the order in which
RSpec::Rails::RailsExampleGroup and
ActionController::TestCase::Behavior are declared.

Good job :wink:

I was looking around to see where stuff was required, figured it may
have something to do with the fact I don’t use
require ‘rails/all’
in my application.rb, but break out stuff so I don’t include
activerecord but do include sequel, maybe active record which is
usually loaded first pulls something in that you needed?

Thanks