lib/pact/rspec.rb in pact-1.1.1 vs lib/pact/rspec.rb in pact-1.2.1.rc1

- old
+ new

@@ -1,5 +1,6 @@ +# This is horrible, must work out a better way of doing this module Pact module RSpec def self.color_enabled? if ::RSpec.configuration.respond_to?(:color_enabled?) @@ -7,14 +8,45 @@ else ::RSpec.configuration.color_enabled? end end + def self.formatter_class + if ::RSpec::Core::Formatters.respond_to?(:register) + require 'pact/provider/rspec/formatter_rspec_3' + Pact::Provider::RSpec::Formatter + else + require 'pact/provider/rspec/formatter_rspec_2' + Pact::Provider::RSpec::Formatter2 + end + + end + def self.full_description example example.respond_to?(:full_description) ? example.full_description : example.example.full_description end def self.runner_defined? defined?(::RSpec::Core::Runner) + end + + def self.is_rspec_3 + ::RSpec::Core::Formatters.respond_to?(:register) + end + + def self.is_rspec_2 + !is_rspec_3 + end + + def self.with_rspec_3 + if is_rspec_3 + yield + end + end + + def self.with_rspec_2 + if is_rspec_2 + yield + end end end end \ No newline at end of file