Sha256: 97398af10df4746e96c06976fd3bf1886a1c95246edfc7431bfb0e646b445ab0

Contents?: true

Size: 1.47 KB

Versions: 112

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

module RSpec
  module Mocks
    describe "OnceCounts" do
      before(:each) do
        @mock = double("test mock")
      end

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

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

      it "once passes when called once" do
        @mock.should_receive(:random_call).once
        @mock.random_call
        @mock.rspec_verify
      end

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

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

Version data entries

112 entries across 109 versions & 10 rubygems

Version Path
classiccms-0.3.4 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
classiccms-0.3.3 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
classiccms-0.3.2 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
classiccms-0.3.1 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
classiccms-0.3.0 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.8.0/spec/rspec/mocks/once_counts_spec.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
classiccms-0.2.4.pre vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
horseman-0.0.5 vendor/ruby/1.9.1/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
classicCMS-0.2.3 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
classicCMS-0.2.2 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
classicCMS-0.2.1 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
classicCMS-0.2.0 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
classicCMS-0.1.2 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/once_counts_spec.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/rspec-mocks-2.8.0/spec/rspec/mocks/once_counts_spec.rb