module RSpecCandy::Switcher
Public Instance Methods
active_record_loaded?()
click to toggle source
# File lib/rspec_candy/switcher.rb, line 22 def active_record_loaded? defined?(ActiveRecord) end
active_record_version()
click to toggle source
# File lib/rspec_candy/switcher.rb, line 18 def active_record_version ActiveRecord::VERSION::MAJOR end
define_matcher(*args, &block)
click to toggle source
# File lib/rspec_candy/switcher.rb, line 49 def define_matcher(*args, &block) rspec_matcher_registry.define(*args, &block) end
new_mock(*args)
click to toggle source
# File lib/rspec_candy/switcher.rb, line 26 def new_mock(*args) case rspec_version when 1 Spec::Mocks::Mock.new(*args) when 2 RSpec::Mocks::Mock.new(*args) else RSpec::Mocks::Double.new(*args) end end
rspec_matcher_registry()
click to toggle source
# File lib/rspec_candy/switcher.rb, line 45 def rspec_matcher_registry rspec_root.const_get(:Matchers) end
rspec_root()
click to toggle source
# File lib/rspec_candy/switcher.rb, line 37 def rspec_root if rspec_version == 1 Spec else RSpec end end
rspec_version()
click to toggle source
# File lib/rspec_candy/switcher.rb, line 5 def rspec_version begin require 'rspec/version' RSpec::Version::STRING.to_i rescue LoadError if defined?(Spec) 1 else raise 'Cannot determine RSpec version' end end end