Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using RCov RakeTask doesn't include modules into example groups with RSpec.configure #216

Closed
jarmo opened this issue Nov 5, 2010 · 1 comment

Comments

@jarmo
Copy link
Contributor

jarmo commented Nov 5, 2010

Consider the following project structure:
# 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
module MyLib
  def my_method
    "works"
  end
end

require "rspec"
RSpec.configure do |config|
  config.include(MyLib)
end

# .rspec
-r
lib/my_lib 

# Rakefile 
require 'rspec/core/rake_task' 
RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:rcov) do |spec| 
  spec.rcov = true 
end 

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 set a breakpoint into the 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]

For some reason the module is not included when running with RCov.

@dchelimsky
Copy link
Contributor

I'm pretty sure this is resolved by #203. If not, comment here and I'll reopen it.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants