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