Sha256: 2b07bc88349cab1b8d3d0e961e4e443eaf0f0d5aee42a0f50f9cd2d188c71fb6
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib' require 'not_a_mock' describe "A stub instance" do before do @object = String.stub_instance(:length => 42, :id => 99) end it "should return the right result for a stubbed method" do @object.length.should == 42 end it "should return its name when inspected" do @object.inspect.should == "Stub String" end it "should handle the id method being stubbed" do @object.id.should == 99 end it "should raise an error when a method that's not stubbed is called" do lambda { @object.whatever }.should raise_error(NoMethodError) end it "should record a call to a stubbed method" do @object.length NotAMock::CallRecorder.instance.calls.should include(:object => @object, :method => :length, :args => [], :result => 42) end it "should allow adding of new stubbed methods" do @object.stub_method(:width => 7) @object.width.should == 7 end it "should identify itself as the underlying object" do @object.is_a?(String).should be_true @object.should be_kind_of(String) @object.should be_kind_of(Object) @object.should be_instance_of(String) @object.class.should == String end after do NotAMock::CallRecorder.instance.reset NotAMock::Stubber.instance.reset end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
not_a_mock-1.0.1 | spec/stub_instance_spec.rb |
not_a_mock-1.0.0 | spec/stub_instance_spec.rb |