lib/remarkable/matchers.rb in remarkable-3.1.2 vs lib/remarkable/matchers.rb in remarkable-3.1.3

- old
+ new

@@ -7,11 +7,19 @@ # Helper that includes required Remarkable modules into the given klass. # # If the module to be included responds to :after_include, it's called with the # target as argument. # - def self.include_matchers!(base, target) + def self.include_matchers!(base, target=nil) + if target.nil? + if rspec_defined? + target = Spec::Example::ExampleGroup + else + raise ArgumentError, "You haven't supplied the target to include_matchers! and RSpec is not loaded, so we cannot infer one." + end + end + target.send :extend, Remarkable::Pending target.send :extend, Remarkable::Macros if defined?(base::Matchers) target.send :include, base::Matchers @@ -21,7 +29,11 @@ end if base.respond_to?(:after_include) base.after_include(target) end + end + + def self.rspec_defined? #:nodoc: + defined?(Spec) end end