Permalink
Browse files

Heckle requires "self.$method_name" for class methods

- Closes #2.
  • Loading branch information...
1 parent 09c2416 commit 40e737dac4198f2fc489656206146a5c069edfe6 @dkubb dkubb committed with Aug 5, 2010
Showing with 8 additions and 3 deletions.
  1. +7 −2 lib/spec/runner/heckle_runner.rb
  2. +1 −1 spec/spec/runner/heckle_runner_spec.rb
@@ -17,12 +17,17 @@ def initialize(filter, heckle_class=Heckler)
# Runs all the example groups held by +rspec_options+ once for each of the
# methods in the matched classes.
def heckle_with
- if @filter =~ /(.*)[#\.](.*)/
- heckle_method($1, $2)
+ case @filter
+ when /(.*)#(.*)/ then heckle_method($1, $2)
+ when /(.*)\.(.*)/ then heckle_class_method($1, $2)
else
heckle_class_or_module(@filter)
end
end
+
+ def heckle_class_method(class_name, method_name)
+ heckle_method(class_name, "self.#{method_name}")
+ end
def heckle_method(class_name, method_name)
verify_constant(class_name)
@@ -53,7 +53,7 @@ def four; end
end
it "should heckle specific method in a class (with .)" do
- @heckle_class.should_receive(:new).with("Foo::Bar", "two", Spec::Runner.options).and_return(@heckle)
+ @heckle_class.should_receive(:new).with("Foo::Bar", "self.two", Spec::Runner.options).and_return(@heckle)
heckle_runner = Spec::Runner::HeckleRunner.new("Foo::Bar.two", @heckle_class)
heckle_runner.heckle_with

0 comments on commit 40e737d

Please sign in to comment.