Sha256: 3ef5f9d75e09c56e3b8e3d8f0f1eeb59e7aad30110a046c33790bffa95faf4e6

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

module RSpec
  module Matchers
    describe DifferentiateBlockMethodTypes do
      let(:differentiator) do
        DifferentiateBlockMethodTypes.new do
          def some_instance_method_1; end
          def self.some_singleton_method_1; end
          define_method(:some_instance_method_2) { }

          if RUBY_VERSION.to_f > 1.8
            define_singleton_method(:some_singleton_method_2) { }
          else
            def self.some_singleton_method_2; end
          end
        end
      end

      it 'differentiates singleton method defs from instance method defs' do
        expect(differentiator.instance_methods).to eq([:some_instance_method_1, :some_instance_method_2])
        expect(differentiator.singleton_methods).to eq([:some_singleton_method_1, :some_singleton_method_2])
      end

      it 'passes the given args through to the block' do
        expect { |b|
          DifferentiateBlockMethodTypes.new(1, 2, &b)
        }.to yield_with_args(1, 2)
      end

      it 'ignores unrecognized DSL methods called in the block' do
        expect {
          DifferentiateBlockMethodTypes.new { foo.bar; some_dsl { nested } }
        }.not_to raise_error
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rspec-expectations-2.99.2 spec/rspec/matchers/differentiate_block_method_types_spec.rb
rspec-expectations-2.99.1 spec/rspec/matchers/differentiate_block_method_types_spec.rb
rspec-expectations-2.99.0 spec/rspec/matchers/differentiate_block_method_types_spec.rb
rspec-expectations-2.99.0.rc1 spec/rspec/matchers/differentiate_block_method_types_spec.rb
rspec-expectations-2.99.0.beta2 spec/rspec/matchers/differentiate_block_method_types_spec.rb
rspec-expectations-2.99.0.beta1 spec/rspec/matchers/differentiate_block_method_types_spec.rb