Skip to content
This repository
Browse code

Put some highlight for the ruby code on the README

  • Loading branch information...
commit 4db3a81fb028e593810840e25c437ea872b159b7 1 parent 43867d4
Marcelo Griggio Cajueiro authored September 21, 2012

Showing 1 changed file with 24 additions and 24 deletions. Show diff stats Hide diff stats

  1. 48  README.md
48  README.md
Source Rendered
@@ -23,7 +23,7 @@ _rspec-given_ is ready for production use.
23 23
 
24 24
 Here is a specification written in the rspec-given framework:
25 25
 
26  
-<pre>
  26
+```ruby
27 27
 require 'rspec/given'
28 28
 require 'spec_helper'
29 29
 require 'stack'
@@ -86,7 +86,7 @@ describe Stack do
86 86
     end
87 87
   end
88 88
 end
89  
-</pre>
  89
+```
90 90
 
91 91
 Let's talk about the individual statements used in the Given
92 92
 framework.
@@ -123,9 +123,9 @@ preconditions running before inner preconditions.
123 123
 
124 124
 #### Given examples:
125 125
 
126  
-<pre>
  126
+```ruby
127 127
     Given(:stack) { Stack.new }
128  
-</pre>
  128
+```
129 129
 
130 130
 The block for the given clause is lazily run if 'stack' is ever
131 131
 referenced in the test and the value of the block is bound to 'stack'.
@@ -133,18 +133,18 @@ The first reference to 'stack' in the specification will cause the
133 133
 code block to execute. Futher references to 'stack' will reuse the
134 134
 previously generated value.
135 135
 
136  
-<pre>
  136
+```ruby
137 137
     Given!(:original_size) { stack.size }
138  
-</pre>
  138
+```
139 139
 
140 140
 The code block is run unconditionally once before each test and the
141 141
 value of the block is bound to 'original_size'.  This form is useful
142 142
 when you want to record the value of something that might be affected
143 143
 by the When code.
144 144
 
145  
-<pre>
  145
+```ruby
146 146
     Given { stack.clear }
147  
-</pre>
  147
+```
148 148
 
149 149
 The block for the given clause is run unconditionally once before each
150 150
 test. This form of given is used for code that is executed for side
@@ -160,7 +160,7 @@ There should only be one _When_ clause for a given context. However, a
160 160
 _When_ in an outer context shoud be treated as a _Given_ in an inner
161 161
 context.  E.g.
162 162
 
163  
-<pre>
  163
+```ruby
164 164
     context "outer context" do
165 165
       When { code specified in the outer context }
166 166
       Then { assert something about the outer context }
@@ -174,22 +174,22 @@ context.  E.g.
174 174
         Then { assert something about the inner context }
175 175
       end
176 176
     end
177  
-</pre>
  177
+```
178 178
 
179 179
 #### When examples:
180 180
 
181  
-<pre>
  181
+```ruby
182 182
     When { stack.push(:item) }
183  
-</pre>
  183
+```
184 184
 
185 185
 The code block is executed once per test.  The effect of the _When{}_
186 186
 block is very similar to _Given{}_.  However, When is used to identify
187 187
 the particular code that is being specified in the current context or
188 188
 describe block.
189 189
 
190  
-<pre>
  190
+```ruby
191 191
     When(:result) { stack.pop }
192  
-</pre>
  192
+```
193 193
 
194 194
 The code block is executed once per test and the value of the code
195 195
 block is bound to 'result'.  Use this form when the code under test
@@ -207,10 +207,10 @@ For example, if the stack is empty when it is popped, then it is
207 207
 reasonable for pop to raise an UnderflowError. This is how you might
208 208
 specify that behavior:
209 209
 
210  
-<pre>
  210
+```ruby
211 211
     When(:result) { stack.pop }
212 212
     Then { result.should have_failed(UnderflowError, /empty/) }
213  
-</pre>
  213
+```
214 214
 
215 215
 Note that the arguments to the 'have_failed' matcher are the same as
216 216
 those given to the standard RSpec matcher 'raise_error'.
@@ -232,15 +232,15 @@ there will be no examples to be run for that group. If all the
232 232
 assertions in an example group are done via Invariants, then the group
233 233
 should use an empty _Then_ clause, like this:
234 234
 
235  
-<pre>
  235
+```ruby
236 236
     Then { }
237  
-</pre>
  237
+```
238 238
 
239 239
 #### Then examples:
240 240
 
241  
-<pre>
  241
+```ruby
242 242
     Then { stack.should be_empty }
243  
-</pre>
  243
+```
244 244
 
245 245
 After the related block for the _When_ clause is run, the stack should
246 246
 be empty. If it is not empty, the test will fail.
@@ -280,11 +280,11 @@ stick with _Then_ clauses.
280 280
 
281 281
 #### Then/And examples:
282 282
 
283  
-<pre>
  283
+```ruby
284 284
   Then { pop_result.should == :top_item }           # Required
285 285
   And  { stack.top.should == :second_item }         # No Setup rerun
286 286
   And  { stack.depth.should == original_depth - 1 } # ... for these
287  
-</pre>
  287
+```
288 288
 
289 289
 ### Invariant
290 290
 
@@ -322,9 +322,9 @@ the examples to produce better looking output. If you don't care about
322 322
 the pretty output and wish to disable source code caching
323 323
 unconditionally, then add the following line to your spec helper file:
324 324
 
325  
-<pre>
  325
+```ruby
326 326
     RSpec::Given.source_caching_disabled = true
327  
-</pre>
  327
+```
328 328
 
329 329
 # Future Directions
330 330
 

0 notes on commit 4db3a81

Please sign in to comment.
Something went wrong with that request. Please try again.