Sha256: f811d7e9f1c2810250b3d27c6faeda53f3d08c981a28c768a7c1527bf8c74d90

Contents?: true

Size: 1.44 KB

Versions: 74

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

module RSpec
  module Mocks
    describe "#once" do
      before(:each) do
        @double = double
      end

      it "passes when called once" do
        @double.should_receive(:do_something).once
        @double.do_something
        @double.rspec_verify
      end

      it "passes when called once with specified args" do
        @double.should_receive(:do_something).once.with("a", "b", "c")
        @double.do_something("a", "b", "c")
        @double.rspec_verify
      end

      it "passes when called once with unspecified args" do
        @double.should_receive(:do_something).once
        @double.do_something("a", "b", "c")
        @double.rspec_verify
      end

      it "fails when called with wrong args" do
        @double.should_receive(:do_something).once.with("a", "b", "c")
        lambda do
          @double.do_something("d", "e", "f")
        end.should raise_error(RSpec::Mocks::MockExpectationError)
        @double.rspec_reset
      end

      it "fails fast when called twice" do
        @double.should_receive(:do_something).once
        @double.do_something
        lambda do
          @double.do_something
        end.should raise_error(RSpec::Mocks::MockExpectationError)
      end
      
      it "fails when not called" do
        @double.should_receive(:do_something).once
        lambda do
          @double.rspec_verify
        end.should raise_error(RSpec::Mocks::MockExpectationError)
      end
    end
  end
end

Version data entries

74 entries across 69 versions & 9 rubygems

Version Path
classiccms-0.5.2 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
classiccms-0.5.1 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
classiccms-0.5.0 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
classiccms-0.4.2 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
rspec-mocks-2.11.1 spec/rspec/mocks/once_counts_spec.rb
rspec-mocks-2.11.0 spec/rspec/mocks/once_counts_spec.rb
classiccms-0.4.1 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
classiccms-0.4.0 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
classiccms-0.3.9 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
rails-uploader-0.0.4 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
classiccms-0.3.8 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb
classiccms-0.3.7 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/once_counts_spec.rb