Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 223 lines (159 sloc) 5.564 kb
bea39dee »
2010-10-26 Just started...
1 #stendhal
2
38325606 »
2010-10-26 Docs
3 A small test framework developed as a personal kata to improve my ruby.
bea39dee »
2010-10-26 Just started...
4
18f43561 »
2010-11-13 Update readme with ruby compatibilities
5 Tested with Ruby 1.8.7, 1.9.2, JRuby 1.5.3 and Rubinius 1.1.
6
2f768f18 »
2010-10-29 0.1.0
7 Currently under development, there is only basic functionality for now.
8 Below I will be posting whatever features are available throughout the
9 development.
10
617c3b94 »
2010-10-31 Stendhal 0.1.1
11 ##Current features
12
c390e9e7 »
2010-11-03 Version bump
13 * Pretty decent reporter with colors
4d43184d »
2010-11-13 0.1.7 - Partial stubbing
14 * Test doubles and stubs (also partial stubbing!)
4e84c520 »
2010-11-13 Mocks can return stubbed values
15 * Mocks (message expectations) with _optionally_ stubbable return values
c390e9e7 »
2010-11-03 Version bump
16 * Nested example groups (declare them with either describe or context)
617c3b94 »
2010-10-31 Stendhal 0.1.1
17 * Pending examples
488d1345 »
2010-11-13 0.1.8 - Rake tasks and runner improvements
18 * A rake task to run the specs
617c3b94 »
2010-10-31 Stendhal 0.1.1
19 * Matchers (use with object.must or object.must_not)
577956e4 »
2010-10-31 readme
20
617c3b94 »
2010-10-31 Stendhal 0.1.1
21 eq() / eql()
577956e4 »
2010-10-31 readme
22
617c3b94 »
2010-10-31 Stendhal 0.1.1
23 be_a() / be_kind_of() / be_a_kind_of()
577956e4 »
2010-10-31 readme
24
617c3b94 »
2010-10-31 Stendhal 0.1.1
25 be_whatever # asks object.whatever?
26
27
2f768f18 »
2010-10-29 0.1.0
28 ##Installation
29
30 gem install stendhal
f593f478 »
2010-10-26 docs
31
7de76d2a »
2010-10-26 readme
32 ##Usage
f593f478 »
2010-10-26 docs
33
488d1345 »
2010-11-13 0.1.8 - Rake tasks and runner improvements
34 In your Gemfile:
35
36 gem 'stendhal'
37
38 If you want the :spec task, in your Rakefile:
39
40 require 'stendhal'
41 Stendhal::RakeTask.new
42
43 task :default => :spec
44
45 ##Syntax
46
617c3b94 »
2010-10-31 Stendhal 0.1.1
47 # your spec file for some class - foo_spec.rb
f593f478 »
2010-10-26 docs
48
617c3b94 »
2010-10-31 Stendhal 0.1.1
49 describe "Foo" do
f593f478 »
2010-10-26 docs
50
2f768f18 »
2010-10-29 0.1.0
51 it "does something" do
52 my_object = MyClass.new
617c3b94 »
2010-10-31 Stendhal 0.1.1
53 my_object.must be_a(MyClass)
54 end
2f768f18 »
2010-10-29 0.1.0
55
617c3b94 »
2010-10-31 Stendhal 0.1.1
56
57 it "fails when 7 is not 9" do
58 (3 + 4).must eq(9)
2f768f18 »
2010-10-29 0.1.0
59 end
f593f478 »
2010-10-26 docs
60
617c3b94 »
2010-10-31 Stendhal 0.1.1
61 it "asks for a kind of object" do
62 "string".must be_a(String)
63 end
64
65 it "asks things to objects" do
66 "string".must be_frozen
67 end
68
69 it "has common sense" do
70 "string".must_not eq(3)
71 end
72
73 describe "Pending examples" do
2f768f18 »
2010-10-29 0.1.0
74
75 it "should do something but I don't know what yet"
76
77 pending "will do something else" do
78 my_object = MyClass.new
79 my_object.future_method
80 end
81
c390e9e7 »
2010-11-03 Version bump
82 context "under some unknown circumstances" do
83 it "may act differently" do
84 MyClass.must be_a(Class)
85 end
86 end
87
2f768f18 »
2010-10-29 0.1.0
88 end
4cc2a040 »
2010-10-26 Pending examples report
89
478ef83b »
2010-11-03 Can I has test doubles
90 describe "Test double" do
91 it "is declared with fake" do
92 my_logger = fake('logger')
93 end
94
95 it "is declared with double as well" do
96 my_logger = double('logger')
97 end
98
99 it "can be given stubs" do
100 my_logger = double('logger', :my_method => 6)
101 my_logger.my_method.must eq(6)
102 end
103 end
104
4d43184d »
2010-11-13 0.1.7 - Partial stubbing
105 describe "Partial stubbing" do
106 it "returns nil by default" do
107 string = "my string"
108 string.stubs(:some_method)
109
110 string.some_method # => nil
111 end
112
113 it "returns a value if you tell it to" do
114 string = "my string"
115 string.stubs(:some_method) { 'some value' }
116
117 string.some_method # => "some value"
118 end
119 end
120
0647b1be »
2010-11-09 0.1.5 - Mocks aka message expectations
121 describe "Message expectation" do
122 it "is declared with expects" do
123 string = "my string"
124 string.expects(:reverse)
125
126 string.reverse # Expectation fulfilled!
127 end
128
4e84c520 »
2010-11-13 Mocks can return stubbed values
129 it "can be told the number of times it is expected" do
130 string = "my string"
131 string.expects(:reverse).once # or
132 string.expects(:reverse).twice # or
133 string.expects(:reverse).exactly(3).times
134
135 string.reverse # Fails!
136 end
137
138 it "can return a stubbed value" do
139 string = "my string"
140 string.expects(:reverse).and_returns 'stubbed value'
141
142 string.reverse # => "stubbed value"
143 end
144
145 it "can return a stubbed proc" do
146 string = "my string"
147 string.expects(:reverse).and_returns do
148 3 + 4
149 end
150
151 string.reverse # => 7
152 end
153
0647b1be »
2010-11-09 0.1.5 - Mocks aka message expectations
154 it "is declared with does_not_expect in case it is negative" do
155 string = "my string"
156 string.does_not_expect(:reverse)
157
158 string.reverse # Fails!
159 end
160 end
161
4cc2a040 »
2010-10-26 Pending examples report
162 end
163
7de76d2a »
2010-10-26 readme
164 ###Running the specs!
f593f478 »
2010-10-26 docs
165
617c3b94 »
2010-10-31 Stendhal 0.1.1
166 stendhal foo_spec.rb
bea39dee »
2010-10-26 Just started...
167
c390e9e7 »
2010-11-03 Version bump
168 ###And the nice colored output...
4cc2a040 »
2010-10-26 Pending examples report
169
617c3b94 »
2010-10-31 Stendhal 0.1.1
170 Foo
c390e9e7 »
2010-11-03 Version bump
171 * does something
172 * fails when 7 is not 9 [FAILED]
173 expected 7 to equal 9
174 * asks for a kind of object
175 * asks things to objects [FAILED]
176 expected "string" to be frozen
177 * has common sense
617c3b94 »
2010-10-31 Stendhal 0.1.1
178
179 Pending examples
c390e9e7 »
2010-11-03 Version bump
180 * should do something but I don't know what yet
181 * will do something else
182 under some unknown circumstances
183 * may act differently
4cc2a040 »
2010-10-26 Pending examples report
184
478ef83b »
2010-11-03 Can I has test doubles
185 Test double
c390e9e7 »
2010-11-03 Version bump
186 * is declared with fake
187 * is declared with double as well
188 * can be given stubs
4d43184d »
2010-11-13 0.1.7 - Partial stubbing
189
190 Partial stubbing
191 * returns nil by default
192 * returns a value if you tell it to
478ef83b »
2010-11-03 Can I has test doubles
193
0647b1be »
2010-11-09 0.1.5 - Mocks aka message expectations
194 Message expectation
195 * is declared with expects
4e84c520 »
2010-11-13 Mocks can return stubbed values
196 * can be told the number of times it is expected [FAILED]
197 * can return a stubbed value
198 * can return a stubbed proc
ee85b24b »
2010-11-09 Update readme
199 * is declared with does_not_expect in case it is negative [FAILED]
0647b1be »
2010-11-09 0.1.5 - Mocks aka message expectations
200
4d43184d »
2010-11-13 0.1.7 - Partial stubbing
201 18 examples, 4 failures, 2 pending
4cc2a040 »
2010-10-26 Pending examples report
202
6cd50b45 »
2010-11-03 Update readme
203 ##Feedback
204
205 Reporting issues, asking for new features and constructive criticizing can be
206 done either through Github issues, the mailing list
207 (http://librelist.com/browser/stendhal/) or you can always reach me on twitter
208 (I am @txustice). Don't hesitate to tell me anything! :)
209
bea39dee »
2010-10-26 Just started...
210 ##Note on Patches/Pull Requests
211
212 * Fork the project.
213 * Make your feature addition or bug fix.
214 * Add specs for it. This is important so I don't break it in a
215 future version unintentionally.
216 * Commit, do not mess with rakefile, version, or history.
217 If you want to have your own version, that is fine but bump version
218 in a commit by itself I can ignore when I pull.
219 * Send me a pull request. Bonus points for topic branches.
220
221 ## Copyright
222
223 Copyright (c) 2010 Josep M. Bach. See LICENSE for details.
Something went wrong with that request. Please try again.