changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/spec/spec/mocks/once_counts_spec.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
3module Spec
4 module Mocks
5 describe "OnceCounts" do
6 before(:each) do
7 @mock = mock("test mock")
8 end
9
10 it "once should fail when called once with wrong args" do
11 @mock.should_receive(:random_call).once.with("a", "b", "c")
12 lambda do
13 @mock.random_call("d", "e", "f")
14 end.should raise_error(MockExpectationError)
15 @mock.rspec_reset
16 end
17
18 it "once should fail when called twice" do
19 @mock.should_receive(:random_call).once
20 @mock.random_call
21 @mock.random_call
22 lambda do
23 @mock.rspec_verify
24 end.should raise_error(MockExpectationError)
25 end
26
27 it "once should fail when not called" do
28 @mock.should_receive(:random_call).once
29 lambda do
30 @mock.rspec_verify
31 end.should raise_error(MockExpectationError)
32 end
33
34 it "once should pass when called once" do
35 @mock.should_receive(:random_call).once
36 @mock.random_call
37 @mock.rspec_verify
38 end
39
40 it "once should pass when called once with specified args" do
41 @mock.should_receive(:random_call).once.with("a", "b", "c")
42 @mock.random_call("a", "b", "c")
43 @mock.rspec_verify
44 end
45
46 it "once should pass when called once with unspecified args" do
47 @mock.should_receive(:random_call).once
48 @mock.random_call("a", "b", "c")
49 @mock.rspec_verify
50 end
51 end
52 end
53end