changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/lib/spec/mocks/spec_methods.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
1module Spec
2 module Mocks
3 module ExampleMethods
4 include Spec::Mocks::ArgumentConstraintMatchers
5
6 # Shortcut for creating an instance of Spec::Mocks::Mock.
7 #
8 # +name+ is used for failure reporting, so you should use the
9 # role that the mock is playing in the example.
10 #
11 # +stubs_and_options+ lets you assign options and stub values
12 # at the same time. The only option available is :null_object.
13 # Anything else is treated as a stub value.
14 #
15 # == Examples
16 #
17 # stub_thing = mock("thing", :a => "A")
18 # stub_thing.a == "A" => true
19 #
20 # stub_person = stub("thing", :name => "Joe", :email => "joe@domain.com")
21 # stub_person.name => "Joe"
22 # stub_person.email => "joe@domain.com"
23 def mock(name, stubs_and_options={})
24 Spec::Mocks::Mock.new(name, stubs_and_options)
25 end
26
27 alias :stub :mock
28
29 # Shortcut for creating a mock object that will return itself in response
30 # to any message it receives that it hasn't been explicitly instructed
31 # to respond to.
32 def stub_everything(name = 'stub')
33 mock(name, :null_object => true)
34 end
35
36 end
37 end
38end