Sha256: d11d02b6bef466109def8ea7b83c39497875d4175ae572a65da2a175b02cc60f

Contents?: true

Size: 999 Bytes

Versions: 20

Compression:

Stored size: 999 Bytes

Contents

require 'spec_helper'

describe RSpecCandy::Helpers::NewWithStubs do

  describe Class do

    describe '#new_with_stubs'

    it 'should instantiate a class with an empty constructor and stub out the given methods' do
      klass = Class.new do
        def initialize
        end
        def foo
          'stubbed foo'
        end
        def bar
          'unstubbed bar'
        end
        def unstubbed_method
          'unstubbed result'
        end
      end
      instance = klass.new_with_stubs(:foo => 'stubbed foo', :bar => 'stubbed bar')
      instance.foo.should == 'stubbed foo'
      instance.bar.should == 'stubbed bar'
      instance.unstubbed_method.should == 'unstubbed result'
    end

    it 'should raise an error when trying to stub non-existing methods' do
      klass = Class.new do
        def initialize
        end
      end
      expect do
        klass.new_with_stubs(:foo => 'foo')
      end.to raise_error(/Attempted to stub non-existing method/)
    end

  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rspec_candy-0.5.1 spec/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.5.0 spec/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.4.1 spec/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.4.0 spec/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.3.1 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.3.0 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.2.10 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.2.9 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.2.8 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.2.7 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.2.6 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.2.5 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.2.4 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.2.3 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.2.2 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.2.1 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.2.0 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.1.2 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.1.1 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb
rspec_candy-0.1.0 spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb