Sha256: 64804ec5184443a94987b0d653938098e70787c2eca710a3c4682c274ccb8af5

Contents?: true

Size: 1.49 KB

Versions: 99

Compression:

Stored size: 1.49 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

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

      it "once should fail 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(MockExpectationError)
        @mock.rspec_reset
      end

      it "once should fail 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(MockExpectationError)
      end
      
      it "once should fail when not called" do
        @mock.should_receive(:random_call).once
        lambda do
          @mock.rspec_verify
        end.should raise_error(MockExpectationError)
      end

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

      it "once should pass 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 should pass 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

99 entries across 99 versions & 14 rubygems

Version Path
picolena-0.1.0 rails_plugins/rspec/spec/spec/mocks/once_counts_spec.rb
picolena-0.1.1 rails_plugins/rspec/spec/spec/mocks/once_counts_spec.rb
picolena-0.1.2 rails_plugins/rspec/spec/spec/mocks/once_counts_spec.rb
picolena-0.1.4 rails_plugins/rspec/spec/spec/mocks/once_counts_spec.rb
picolena-0.1.3 rails_plugins/rspec/spec/spec/mocks/once_counts_spec.rb
picolena-0.1.5 rails_plugins/rspec/spec/spec/mocks/once_counts_spec.rb
pictrails-0.5.0 vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb
radiant-0.6.5.1 vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb
radiant-0.6.5 vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb
radiant-0.6.7 vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb
radiant-0.6.6 vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb
radiant-0.6.9 vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb
radiant-0.6.8 vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb
rspec-0.0.10 spec/spec/mocks/once_counts_spec.rb
rspec-1.0.5 spec/spec/mocks/once_counts_spec.rb
rspec-1.0.8 spec/spec/mocks/once_counts_spec.rb
rspec-1.1.10 spec/spec/mocks/once_counts_spec.rb
rspec-1.1.1 spec/spec/mocks/once_counts_spec.rb
rspec-1.1.0 spec/spec/mocks/once_counts_spec.rb
rspec-1.0.7 spec/spec/mocks/once_counts_spec.rb