[rspec-users] Upgrade problems/questions regarding RSpec 1.3.0 to 2.0.1

Jarmo Pertman jarmo.p at gmail.com
Thu Nov 4 19:14:35 EDT 2010


It also fails with RCov very strangely when including module in
RSpec.configure block like this:

# spec/my_lib_spec.rb
require "rspec"

describe "should work" do
  it "with rcov also" do
    MyLib.should be
    my_method.should == "works"
  end
end

# lib/my_lib.rb
require "rspec"

module MyLib
  def my_method
    "works"
  end
end

RSpec.configure do |config|
  config.include(MyLib)
end

# .rspec
-r
lib/my_lib

and Rakefile is the same as before.

When using `rake spec` then example passes, but with `rake rcov` i see
this:
C:\Users\jarmo\Desktop\minu\projects\Ruby\blah>rake rcov
(in C:/Users/jarmo/Desktop/minu/projects/Ruby/blah)
c:/ruby/bin/ruby.exe -S rcov -Ispec "./spec/my_lib_spec.rb"
F

Failures:
  1) should work with rcov also
     Failure/Error: my_method.should == "works"
     undefined local variable or method `my_method' for
#<RSpec::Core::ExampleGroup::Nested_1:0x59cb488 @__memoized={}>
     # ./spec/my_lib_spec.rb:6

Finished in 0.014 seconds
1 example, 1 failure
rake aborted!
ruby -S rcov -Ispec "./spec/my_lib_spec.rb" failed

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

When i put a breakpoint into example block then with `rake spec` i can
see that module is included, but not with `rake rcov` although
my_lib.rb is loaded because the first expectation succeeds as seen
above.

With `rake spec`:
(rdb:1) l
[3, 12] in C:/Users/jarmo/Desktop/minu/projects/Ruby/blah/spec/
my_lib_spec.rb
   3  describe "should work" do
   4    it "with rcov also" do
   5      MyLib.should be
   6      require "ruby-debug"
   7      debugger
=> 8      my_method.should == "works"
   9    end
   10  end

(rdb:1) self.class.included_modules
[MyLib, RSpec::Matchers, RSpec::Core::MockFrameworkAdapter,
RSpec::Core::Pending, RSpec::Core::Let::InstanceMethods,
RSpec::Core::Let, RSpec::Core::Subject,
RSpec::Core::Extensions::InstanceEvalWithArgs, RSpec::Mocks::Methods,
PP::ObjectMixin, RSpec::Core::SharedExampleGroup,
RSpec::Core::ObjectExtensions, Kernel]

With `rake rcov`:
(rdb:1) self.class.included_modules
[RSpec::Matchers, RSpec::Core::MockFrameworkAdapter,
RSpec::Core::Pending, RSpec::Core::Let::InstanceMethods,
RSpec::Core::Let, RSpec::Core::Subject,
RSpec::Core::Extensions::InstanceEvalWithArgs, RSpec::Mocks::Methods,
PP::ObjectMixin, RSpec::Core::SharedExampleGroup,
RSpec::Core::ObjectExtensions, Kernel]

So, for some reason the module is not included when running with RCov.
By the way all the specs were working before with 1.3.0.

Jarmo Pertman
-----
IT does really matter - http://www.itreallymatters.net

On Nov 4, 10:37 pm, Jarmo Pertman <jarm... at gmail.com> wrote:
> There seems to be also a problem when using RCov raketask - it doesn't
> seem to load RSpec.


More information about the rspec-users mailing list