Sha256: 455e2b9a920791b9dd651be442b1c052840a338e3e7e0da104aa8fa4b8b3be10

Contents?: true

Size: 1.94 KB

Versions: 41

Compression:

Stored size: 1.94 KB

Contents

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

describe RR do
  attr_reader :subject
  before do
    @subject = Object.new
  end

  describe "#mock" do
    it "creates a mock DoubleInjection Double" do
      mock(subject).foobar(1, 2) {:baz}
      subject.foobar(1, 2).should == :baz
    end
  end

  describe "#stub" do
    it "creates a stub DoubleInjection Double" do
      stub(subject).foobar {:baz}
      subject.foobar("any", "thing").should == :baz
    end
  end

  describe "#mock and #proxy" do
    before do
      def subject.foobar
        :baz
      end
    end

    it "creates a proxy DoubleInjection Double" do
      mock.proxy(subject).foobar
      subject.foobar.should == :baz
    end
  end

  describe "#stub and #proxy" do
    before do
      def subject.foobar
        :baz
      end
    end

    it "creates a proxy DoubleInjection Double" do
      stub.proxy(subject).foobar
      subject.foobar.should == :baz
    end
  end

  describe "#stub and #proxy" do
    before do
      def subject.foobar
        :baz
      end
    end

    it "creates a proxy DoubleInjection Double" do
      stub.proxy(subject).foobar
      subject.foobar.should == :baz
    end
  end

  describe "spies" do
    it "validates that a Double was called after it was called" do
      stub(subject).foobar
      subject.foobar(1, 2)

      subject.should have_received.foobar(1, 2)
      lambda do
        subject.should have_received.foobar(1, 2, 3)
      end.should raise_error(Spec::Expectations::ExpectationNotMetError)
    end
  end

  it "creates an invocation matcher with a method name" do
    method  = :test
    matcher = 'fake'
    mock(RR::Adapters::Rspec::InvocationMatcher).new(method) { matcher }
    have_received(method).should == matcher
  end

  it "creates an invocation matcher without a method name" do
    matcher = 'fake'
    mock(RR::Adapters::Rspec::InvocationMatcher).new(nil) { matcher }
    have_received.should == matcher
  end
end

Version data entries

41 entries across 37 versions & 8 rubygems

Version Path
jferris-rr-0.7.1.0.1239654108 spec/rr/rspec/rspec_usage_spec.rb
redinger-redinger-rr-0.10.3 spec/rr/rspec/rspec_usage_spec.rb
redinger-rr-0.10.4 spec/rr/rspec/rspec_usage_spec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/rspec/rspec_usage_spec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/rspec/rspec_usage_spec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/rspec/rspec_usage_spec.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/rspec/rspec_usage_spec.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/rspec/rspec_usage_spec.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/rspec/rspec_usage_spec.rb
bitclust-core-0.5.1 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/rspec/rspec_usage_spec.rb
mcmire-rr-1.0.5.rc1 spec/rr/rspec/rspec_usage_spec.rb
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rr-1.0.2/spec/rr/rspec/rspec_usage_spec.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rr-1.0.2/spec/rr/rspec/rspec_usage_spec.rb
rr-1.0.4 spec/rr/rspec/rspec_usage_spec.rb
rr-1.0.3 spec/rr/rspec/rspec_usage_spec.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rr-1.0.2/spec/rr/rspec/rspec_usage_spec.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/rr-1.0.2/spec/rr/rspec/rspec_usage_spec.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/rr-1.0.2/spec/rr/rspec/rspec_usage_spec.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/rr-1.0.2/spec/rr/rspec/rspec_usage_spec.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/rr-1.0.2/spec/rr/rspec/rspec_usage_spec.rb