Sha256: 7ee4ead8c7a805f6020f73d23e83c55d8b8b262f12d2cf12b7eb2f90d73a4e6c

Contents?: true

Size: 1.6 KB

Versions: 8

Compression:

Stored size: 1.6 KB

Contents

$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
$LOAD_PATH << File.expand_path('../../../rspec-core/lib', __FILE__)
$LOAD_PATH << File.expand_path('../../../rspec-expectations/lib', __FILE__)
require 'rspec/core'
require 'rspec/mocks'
require 'rspec/expectations'

module Macros
  def treats_method_missing_as_private(options = {:noop => true, :subject => nil})
    it "should have method_missing as private" do
      with_ruby 1.8 do
        self.class.describes.private_instance_methods.should include("method_missing")
      end
      with_ruby 1.9 do
        self.class.describes.private_instance_methods.should include(:method_missing)
      end
    end

    it "should not respond_to? method_missing (because it's private)" do
      formatter = options[:subject] || described_class.new({ }, StringIO.new)
      formatter.should_not respond_to(:method_missing)
    end

    if options[:noop]
      it "should respond_to? all messages" do
        formatter = described_class.new({ }, StringIO.new)
        formatter.should respond_to(:just_about_anything)
      end

      it "should respond_to? anything, when given the private flag" do
        formatter = described_class.new({ }, StringIO.new)
        formatter.respond_to?(:method_missing, true).should be_true
      end
    end
  end
end

module Rspec  
  module Matchers
    def with_ruby(version)
      yield if RUBY_VERSION =~ Regexp.compile("^#{version.to_s}")
    end
  end
end

Rspec.configure do |config|
  config.mock_with :rspec
  config.color_enabled = true
  config.extend(Macros)
  config.include(Rspec::Matchers)
  config.include(Rspec::Mocks::Methods)
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rspec-mocks-2.0.0.beta.8 spec/spec_helper.rb
rspec-mocks-2.0.0.beta.7 spec/spec_helper.rb
rspec-mocks-2.0.0.beta.6 spec/spec_helper.rb
rspec-mocks-2.0.0.beta.5 spec/spec_helper.rb
rspec-mocks-2.0.0.beta.4 spec/spec_helper.rb
rspec-mocks-2.0.0.beta.3 spec/spec_helper.rb
rspec-mocks-2.0.0.beta.2 spec/spec_helper.rb
rspec-mocks-2.0.0.beta.1 spec/spec_helper.rb