Sha256: 52801bcf533635b1d2114efb214cadb3d5cd4e8872b8f95ac99e75e83256472d

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")

describe "spy" do
  attr_reader :subject
    before(:each) do
      @subject = Object.new
      extend RR::Adapters::RRMethods
    end

    after(:each) do
      RR.reset
    end

  it "should record all method invocations" do
    subject = Object.new
    def subject.something
    end

    def subject.something_else
    end

    spy(subject)

    subject.something
    subject.something_else
    subject.to_s

    received(subject).something.call
    received(subject).something_else.call
    received(subject).to_s.call
  end

  describe "RR recorded_calls" do
    it "should verify method calls after the fact" do
      stub(subject).pig_rabbit
      subject.pig_rabbit("bacon", "bunny meat")
      #subject.should have_received.pig_rabitt("bacon", "bunny meat")
      received(subject).pig_rabbit("bacon", "bunny meat").call
    end

    it "should verify method calls after the fact" do
      stub(subject).pig_rabbit
      lambda do
        received(subject).pig_rabbit("bacon", "bunny meat").call
      end.should raise_error(RR::Errors::SpyVerificationErrors::SpyVerificationError)
    end
  end  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rr-0.10.9 spec/api/spy/spy_spec.rb
rr-0.10.8 spec/api/spy/spy_spec.rb
rr-0.10.7 spec/api/spy/spy_spec.rb
rr-0.10.6 spec/api/spy/spy_spec.rb