]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/spec/spec/spec_classes.rb
Show whether a trace is public or private in the trace list, so that a user can easil...
[rails.git] / vendor / gems / rspec-1.1.2 / spec / spec / spec_classes.rb
1 # This file contains various classes used by the specs.
2 module Spec
3   module Expectations
4     class Person
5       attr_reader :name
6       def initialize name
7         @name = name
8       end
9       def == other
10         return @name == other.name
11       end
12     end
13     
14     class ClassWithMultiWordPredicate
15       def multi_word_predicate?
16         true 
17       end
18     end
19
20     module Helper
21       class CollectionWithSizeMethod
22         def initialize; @list = []; end
23         def size; @list.size; end
24         def push(item); @list.push(item); end
25       end
26
27       class CollectionWithLengthMethod
28         def initialize; @list = []; end
29         def length; @list.size; end
30         def push(item); @list.push(item); end
31       end
32
33       class CollectionOwner
34         attr_reader :items_in_collection_with_size_method, :items_in_collection_with_length_method
35
36         def initialize
37           @items_in_collection_with_size_method = CollectionWithSizeMethod.new
38           @items_in_collection_with_length_method = CollectionWithLengthMethod.new
39         end
40
41         def add_to_collection_with_size_method(item)
42           @items_in_collection_with_size_method.push(item)
43         end
44
45         def add_to_collection_with_length_method(item)
46           @items_in_collection_with_length_method.push(item)
47         end
48         
49         def items_for(arg)
50           return [1, 2, 3] if arg == 'a'
51           [1]
52         end
53         
54         def items
55           @items_in_collection_with_size_method
56         end
57       end
58
59       class HandCodedMock
60         include Spec::Matchers
61         def initialize(return_val)
62           @return_val = return_val
63           @funny_called = false
64         end
65
66         def funny?
67           @funny_called = true
68           @return_val
69         end
70
71         def hungry?(a, b, c)
72           a.should equal(1)
73           b.should equal(2)
74           c.should equal(3)
75           @funny_called = true
76           @return_val
77         end
78         
79         def exists?
80           @return_val
81         end
82         
83         def multi_word_predicate?
84           @return_val
85         end
86
87         def rspec_verify
88           @funny_called.should be_true
89         end
90       end
91       class ClassWithUnqueriedPredicate
92         attr_accessor :foo
93         def initialize(foo)
94           @foo = foo
95         end
96       end
97     end
98   end
99 end
100
101 module Custom
102   require 'spec/runner/formatter/base_text_formatter'
103   class Formatter < Spec::Runner::Formatter::BaseTextFormatter
104     attr_reader :options, :where
105     
106     def initialize(options, where)
107       @options = options
108       @where = where
109     end
110   end
111
112   class BadFormatter < Spec::Runner::Formatter::BaseTextFormatter
113     attr_reader :where
114     
115     def initialize(options, where)
116       bad_method
117     end
118   end
119
120   class Differ
121     attr_reader :options
122     def initialize(options)
123       @options = options
124     end
125   end
126 end
127
128 class FakeReporter < Spec::Runner::Reporter
129 end