Class: Spec::Runner::HeckleRunner
- Defined in:
- lib/spec/runner/heckle_runner.rb,
lib/spec/runner/heckle_runner_unsupported.rb
Overview
Dummy implementation for Windows that just fails (Heckle is not supported on Windows)
Instance Method Summary collapse
- #heckle_class_method(class_name, method_name) ⇒ Object
- #heckle_class_or_module(class_or_module_name) ⇒ Object
- #heckle_method(class_name, method_name) ⇒ Object
-
#heckle_with ⇒ Object
Runs all the example groups held by
rspec_options
once for each of the methods in the matched classes. -
#initialize(filter) ⇒ HeckleRunner
constructor
A new instance of HeckleRunner.
- #verify_constant(name) ⇒ Object
Constructor Details
#initialize(filter) ⇒ HeckleRunner
Returns a new instance of HeckleRunner.
12 13 14 15 |
# File 'lib/spec/runner/heckle_runner.rb', line 12 def initialize(filter, heckle_class=Heckler) @filter = filter @heckle_class = heckle_class end |
Instance Method Details
#heckle_class_method(class_name, method_name) ⇒ Object
28 29 30 |
# File 'lib/spec/runner/heckle_runner.rb', line 28 def heckle_class_method(class_name, method_name) heckle_method(class_name, "self.#{method_name}") end |
#heckle_class_or_module(class_or_module_name) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/spec/runner/heckle_runner.rb', line 38 def heckle_class_or_module(class_or_module_name) verify_constant(class_or_module_name) pattern = /^#{class_or_module_name}/ classes = [] ObjectSpace.each_object(Class) do |klass| classes << klass if klass.name =~ pattern end classes.each do |klass| klass.instance_methods(false).each do |method_name| heckle = @heckle_class.new(klass.name, method_name, Spec::Runner.) heckle.validate end end end |
#heckle_method(class_name, method_name) ⇒ Object
32 33 34 35 36 |
# File 'lib/spec/runner/heckle_runner.rb', line 32 def heckle_method(class_name, method_name) verify_constant(class_name) heckle = @heckle_class.new(class_name, method_name, Spec::Runner.) heckle.validate end |
#heckle_with ⇒ Object
Runs all the example groups held by rspec_options
once for each of the methods in the matched classes.
19 20 21 22 23 24 25 26 |
# File 'lib/spec/runner/heckle_runner.rb', line 19 def heckle_with case @filter when /(.*)#(.*)/ then heckle_method($1, $2) when /(.*)\.(.*)/ then heckle_class_method($1, $2) else heckle_class_or_module(@filter) end end |
#verify_constant(name) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/spec/runner/heckle_runner.rb', line 54 def verify_constant(name) begin # This is defined in Heckle name.to_class rescue raise "Heckling failed - \"#{name}\" is not a known class or module" end end |