Sha256: 0b716b69cb60f07c298ca3e1e2d889ea0359201fd98bf769d69593b8c74270e2

Contents?: true

Size: 1.36 KB

Versions: 23

Compression:

Stored size: 1.36 KB

Contents

module RSpec
  describe Expectations do
    describe '.method_handle_for(object, method_name)' do

      class UntamperedClass
        def foo
          :bar
        end
      end

      class ClassWithMethodOverridden < UntamperedClass
        def method
          :baz
        end
      end

      if RUBY_VERSION.to_f > 1.8
        class BasicClass < BasicObject
          def foo
            :bar
          end
        end

        class BasicClassWithKernel < BasicClass
          include ::Kernel
        end
      end

      it 'fetches method definitions for vanilla objects' do
        object = UntamperedClass.new
        expect(Expectations.method_handle_for(object, :foo).call).to eq :bar
      end

      it 'fetches method definitions for objects with method redefined' do
        object = ClassWithMethodOverridden.new
        expect(Expectations.method_handle_for(object, :foo).call).to eq :bar
      end

      it 'fetches method definitions for basic objects', :if => RUBY_VERSION.to_i >= 2 do
        object = BasicClass.new
        expect(Expectations.method_handle_for(object, :foo).call).to eq :bar
      end

      it 'fetches method definitions for basic objects with kernel mixed in', :if => RUBY_VERSION.to_f > 1.8 do
        object = BasicClassWithKernel.new
        expect(Expectations.method_handle_for(object, :foo).call).to eq :bar
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 6 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/spec/rspec/expectations_spec.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/spec/rspec/expectations_spec.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/spec/rspec/expectations_spec.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/expectations_spec.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/expectations_spec.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/expectations_spec.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/expectations_spec.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/expectations_spec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-expectations-2.14.5/spec/rspec/expectations_spec.rb
dxruby_rp5-0.0.4 spec/vendor/rspec-expectations-2.14.4/spec/rspec/expectations_spec.rb
rspec-expectations-2.14.5 spec/rspec/expectations_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-expectations-2.14.4/spec/rspec/expectations_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-expectations-2.14.4/spec/rspec/expectations_spec.rb
dxruby_rp5-0.0.3 spec/vendor/rspec-expectations-2.14.4/spec/rspec/expectations_spec.rb
tuktuk-rails-0.0.10 vendor/bundle/ruby/2.0.0/gems/rspec-expectations-2.14.4/spec/rspec/expectations_spec.rb
tuktuk-rails-0.0.9 vendor/bundle/ruby/2.0.0/gems/rspec-expectations-2.14.4/spec/rspec/expectations_spec.rb
tuktuk-rails-0.0.8 vendor/bundle/ruby/2.0.0/gems/rspec-expectations-2.14.4/spec/rspec/expectations_spec.rb
tuktuk-rails-0.0.7 vendor/bundle/ruby/2.0.0/gems/rspec-expectations-2.14.4/spec/rspec/expectations_spec.rb
dxruby_rp5-0.0.2 spec/vendor/rspec-expectations-2.14.4/spec/rspec/expectations_spec.rb
dxruby_rp5-0.0.1 spec/vendor/rspec-expectations-2.14.4/spec/rspec/expectations_spec.rb