do_riak 0.10.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/CHANGELOG +2 -0
  2. data/Gemfile +9 -0
  3. data/LICENSE +20 -0
  4. data/README.textile +23 -0
  5. data/TODO.txt +4 -0
  6. data/deps.rip +8 -0
  7. data/do_riak.gemspec +40 -0
  8. data/do_riak.pre.gemspec +8 -0
  9. data/gems/cache/bacon-1.1.0.gem +0 -0
  10. data/gems/cache/code-cleaner-0.8.1.gem +0 -0
  11. data/gems/cache/nake-0.0.8.gem +0 -0
  12. data/gems/cache/term-ansicolor-1.0.4.gem +0 -0
  13. data/gems/environment.rb +107 -0
  14. data/gems/gems/bacon-1.1.0/COPYING +18 -0
  15. data/gems/gems/bacon-1.1.0/ChangeLog +220 -0
  16. data/gems/gems/bacon-1.1.0/RDOX +69 -0
  17. data/gems/gems/bacon-1.1.0/README +290 -0
  18. data/gems/gems/bacon-1.1.0/Rakefile +138 -0
  19. data/gems/gems/bacon-1.1.0/bin/bacon +117 -0
  20. data/gems/gems/bacon-1.1.0/lib/autotest/bacon.rb +36 -0
  21. data/gems/gems/bacon-1.1.0/lib/autotest/bacon_rspec.rb +2 -0
  22. data/gems/gems/bacon-1.1.0/lib/autotest/discover.rb +9 -0
  23. data/gems/gems/bacon-1.1.0/lib/bacon.rb +354 -0
  24. data/gems/gems/bacon-1.1.0/test/spec_bacon.rb +374 -0
  25. data/gems/gems/bacon-1.1.0/test/spec_should.rb +32 -0
  26. data/gems/gems/code-cleaner-0.8.1/LICENSE +20 -0
  27. data/gems/gems/code-cleaner-0.8.1/README.textile +87 -0
  28. data/gems/gems/code-cleaner-0.8.1/TODO.txt +1 -0
  29. data/gems/gems/code-cleaner-0.8.1/bin/code-cleaner +143 -0
  30. data/gems/gems/code-cleaner-0.8.1/code-cleaner-0.8.gem +0 -0
  31. data/gems/gems/code-cleaner-0.8.1/code-cleaner.gemspec +25 -0
  32. data/gems/gems/code-cleaner-0.8.1/support/pre-commit.erb +70 -0
  33. data/gems/gems/code-cleaner-0.8.1/tasks.rb +13 -0
  34. data/gems/gems/code-cleaner-0.8.1/tasks/code-cleaner.nake +49 -0
  35. data/gems/gems/code-cleaner-0.8.1/tasks/code-cleaner.rake +22 -0
  36. data/gems/gems/code-cleaner-0.8.1/tasks/code-cleaner.thor +35 -0
  37. data/gems/gems/nake-0.0.8/CHANGELOG +48 -0
  38. data/gems/gems/nake-0.0.8/LICENSE +20 -0
  39. data/gems/gems/nake-0.0.8/README.textile +39 -0
  40. data/gems/gems/nake-0.0.8/TODO.txt +23 -0
  41. data/gems/gems/nake-0.0.8/bin/nake +66 -0
  42. data/gems/gems/nake-0.0.8/bin/nrake +4 -0
  43. data/gems/gems/nake-0.0.8/bin/rake2nake +1 -0
  44. data/gems/gems/nake-0.0.8/bin/snake +41 -0
  45. data/gems/gems/nake-0.0.8/bm/Rakefile +28 -0
  46. data/gems/gems/nake-0.0.8/bm/bms.rb +56 -0
  47. data/gems/gems/nake-0.0.8/bm/output.txt +5 -0
  48. data/gems/gems/nake-0.0.8/bm/tasks.rb +21 -0
  49. data/gems/gems/nake-0.0.8/bm/tmp/test.c +6 -0
  50. data/gems/gems/nake-0.0.8/bm/tmp/www/index.html +1 -0
  51. data/gems/gems/nake-0.0.8/deps.rb +5 -0
  52. data/gems/gems/nake-0.0.8/deps.rip +5 -0
  53. data/gems/gems/nake-0.0.8/examples/arguments.rb +38 -0
  54. data/gems/gems/nake-0.0.8/examples/basic.rb +5 -0
  55. data/gems/gems/nake-0.0.8/examples/boot.rb +18 -0
  56. data/gems/gems/nake-0.0.8/examples/complex.rb +9 -0
  57. data/gems/gems/nake-0.0.8/examples/configuration.rb +15 -0
  58. data/gems/gems/nake-0.0.8/examples/default.rb +10 -0
  59. data/gems/gems/nake-0.0.8/examples/default_proc.rb +11 -0
  60. data/gems/gems/nake-0.0.8/examples/dependencies.rb +10 -0
  61. data/gems/gems/nake-0.0.8/examples/description.rb +33 -0
  62. data/gems/gems/nake-0.0.8/examples/file.rb +22 -0
  63. data/gems/gems/nake-0.0.8/examples/helpers.rb +3 -0
  64. data/gems/gems/nake-0.0.8/examples/invoking.rb +14 -0
  65. data/gems/gems/nake-0.0.8/examples/rules.rb +0 -0
  66. data/gems/gems/nake-0.0.8/examples/script.rb +20 -0
  67. data/gems/gems/nake-0.0.8/examples/task_arguments.rb +27 -0
  68. data/gems/gems/nake-0.0.8/features/arguments.feature +22 -0
  69. data/gems/gems/nake-0.0.8/features/basic.feature +6 -0
  70. data/gems/gems/nake-0.0.8/features/boot.feature +5 -0
  71. data/gems/gems/nake-0.0.8/features/builtin_arguments.feature +14 -0
  72. data/gems/gems/nake-0.0.8/features/complex.feature +6 -0
  73. data/gems/gems/nake-0.0.8/features/configuration.feature +10 -0
  74. data/gems/gems/nake-0.0.8/features/default.feature +10 -0
  75. data/gems/gems/nake-0.0.8/features/default_proc.feature +6 -0
  76. data/gems/gems/nake-0.0.8/features/dependencies.feature +16 -0
  77. data/gems/gems/nake-0.0.8/features/description.feature +0 -0
  78. data/gems/gems/nake-0.0.8/features/env.rb +11 -0
  79. data/gems/gems/nake-0.0.8/features/executable.feature +29 -0
  80. data/gems/gems/nake-0.0.8/features/file.feature +23 -0
  81. data/gems/gems/nake-0.0.8/features/helpers.feature +6 -0
  82. data/gems/gems/nake-0.0.8/features/invoking.feature +14 -0
  83. data/gems/gems/nake-0.0.8/features/rules.feature +0 -0
  84. data/gems/gems/nake-0.0.8/features/script.feature +10 -0
  85. data/gems/gems/nake-0.0.8/features/steps.rb +39 -0
  86. data/gems/gems/nake-0.0.8/features/task_arguments.feature +10 -0
  87. data/gems/gems/nake-0.0.8/lib/nake.rb +103 -0
  88. data/gems/gems/nake-0.0.8/lib/nake/abstract_task.rb +175 -0
  89. data/gems/gems/nake-0.0.8/lib/nake/args.rb +65 -0
  90. data/gems/gems/nake-0.0.8/lib/nake/argv.rb +47 -0
  91. data/gems/gems/nake-0.0.8/lib/nake/colors.rb +22 -0
  92. data/gems/gems/nake-0.0.8/lib/nake/dsl.rb +70 -0
  93. data/gems/gems/nake-0.0.8/lib/nake/file_task.rb +62 -0
  94. data/gems/gems/nake-0.0.8/lib/nake/helpers.rb +65 -0
  95. data/gems/gems/nake-0.0.8/lib/nake/rake.rb +38 -0
  96. data/gems/gems/nake-0.0.8/lib/nake/rule.rb +35 -0
  97. data/gems/gems/nake-0.0.8/lib/nake/struct_hash.rb +22 -0
  98. data/gems/gems/nake-0.0.8/lib/nake/task.rb +6 -0
  99. data/gems/gems/nake-0.0.8/lib/nake/tasks/bundle.rb +30 -0
  100. data/gems/gems/nake-0.0.8/lib/nake/tasks/clean.rb +12 -0
  101. data/gems/gems/nake-0.0.8/lib/nake/tasks/gem.rb +29 -0
  102. data/gems/gems/nake-0.0.8/lib/nake/tasks/release.rb +43 -0
  103. data/gems/gems/nake-0.0.8/lib/nake/tasks/rip.rb +33 -0
  104. data/gems/gems/nake-0.0.8/lib/nake/tasks/spec.rb +20 -0
  105. data/gems/gems/nake-0.0.8/lib/nake/template.rb +51 -0
  106. data/gems/gems/nake-0.0.8/nake-0.0.8.pre.gem +0 -0
  107. data/gems/gems/nake-0.0.8/nake.gemspec +42 -0
  108. data/gems/gems/nake-0.0.8/nake.pre.gemspec +8 -0
  109. data/gems/gems/nake-0.0.8/spec/nake/abstract_task_spec.rb +0 -0
  110. data/gems/gems/nake-0.0.8/spec/nake/args_spec.rb +0 -0
  111. data/gems/gems/nake-0.0.8/spec/nake/argv_spec.rb +51 -0
  112. data/gems/gems/nake-0.0.8/spec/nake/colors_spec.rb +0 -0
  113. data/gems/gems/nake-0.0.8/spec/nake/dsl_spec.rb +35 -0
  114. data/gems/gems/nake-0.0.8/spec/nake/file_task_spec.rb +0 -0
  115. data/gems/gems/nake-0.0.8/spec/nake/helpers_spec.rb +14 -0
  116. data/gems/gems/nake-0.0.8/spec/nake/rake_spec.rb +0 -0
  117. data/gems/gems/nake-0.0.8/spec/nake/rule_spec.rb +72 -0
  118. data/gems/gems/nake-0.0.8/spec/nake/struct_hash_spec.rb +0 -0
  119. data/gems/gems/nake-0.0.8/spec/nake/task_spec.rb +72 -0
  120. data/gems/gems/nake-0.0.8/spec/nake/tasks/bundle_spec.rb +28 -0
  121. data/gems/gems/nake-0.0.8/spec/nake/tasks/clean_spec.rb +0 -0
  122. data/gems/gems/nake-0.0.8/spec/nake/tasks/gem_spec.rb +0 -0
  123. data/gems/gems/nake-0.0.8/spec/nake/tasks/release_spec.rb +0 -0
  124. data/gems/gems/nake-0.0.8/spec/nake/tasks/rip_spec.rb +0 -0
  125. data/gems/gems/nake-0.0.8/spec/nake/tasks/spec_spec.rb +0 -0
  126. data/gems/gems/nake-0.0.8/spec/nake/tasks_spec.rb +48 -0
  127. data/gems/gems/nake-0.0.8/spec/nake/template_spec.rb +84 -0
  128. data/gems/gems/nake-0.0.8/spec/nake_spec.rb +9 -0
  129. data/gems/gems/nake-0.0.8/spec/spec.opts +5 -0
  130. data/gems/gems/nake-0.0.8/spec/spec_helper.rb +29 -0
  131. data/gems/gems/nake-0.0.8/spec/stubs/database.yml.erb +9 -0
  132. data/gems/gems/nake-0.0.8/spec/stubs/database.yml.tt +9 -0
  133. data/gems/gems/nake-0.0.8/tasks.rb +42 -0
  134. data/gems/gems/term-ansicolor-1.0.4/CHANGES +22 -0
  135. data/gems/gems/term-ansicolor-1.0.4/COPYING +340 -0
  136. data/gems/gems/term-ansicolor-1.0.4/README +31 -0
  137. data/gems/gems/term-ansicolor-1.0.4/Rakefile +86 -0
  138. data/gems/gems/term-ansicolor-1.0.4/VERSION +1 -0
  139. data/gems/gems/term-ansicolor-1.0.4/doc-main.txt +119 -0
  140. data/gems/gems/term-ansicolor-1.0.4/examples/cdiff.rb +19 -0
  141. data/gems/gems/term-ansicolor-1.0.4/examples/example.rb +89 -0
  142. data/gems/gems/term-ansicolor-1.0.4/install.rb +15 -0
  143. data/gems/gems/term-ansicolor-1.0.4/lib/term/ansicolor.rb +102 -0
  144. data/gems/gems/term-ansicolor-1.0.4/lib/term/ansicolor/version.rb +10 -0
  145. data/gems/gems/term-ansicolor-1.0.4/term-ansicolor.gemspec +20 -0
  146. data/gems/specifications/bacon-1.1.0.gemspec +30 -0
  147. data/gems/specifications/code-cleaner-0.8.1.gemspec +31 -0
  148. data/gems/specifications/nake-0.0.8.gemspec +35 -0
  149. data/gems/specifications/term-ansicolor-1.0.4.gemspec +30 -0
  150. data/lib/do_riak.rb +10 -0
  151. data/lib/do_riak/errors.rb +11 -0
  152. data/lib/do_riak/transaction.rb +24 -0
  153. data/lib/do_riak/version.rb +7 -0
  154. data/script/bacon +3 -0
  155. data/script/code-cleaner +3 -0
  156. data/script/nake +3 -0
  157. data/spec/command_spec.rb +8 -0
  158. data/spec/connection_spec.rb +17 -0
  159. data/spec/reader_spec.rb +8 -0
  160. data/spec/result_spec.rb +12 -0
  161. data/spec/spec_helper.rb +19 -0
  162. data/spec/typecast/array_spec.rb +8 -0
  163. data/spec/typecast/bigdecimal_spec.rb +8 -0
  164. data/spec/typecast/boolean_spec.rb +8 -0
  165. data/spec/typecast/byte_array_spec.rb +8 -0
  166. data/spec/typecast/class_spec.rb +8 -0
  167. data/spec/typecast/date_spec.rb +8 -0
  168. data/spec/typecast/datetime_spec.rb +8 -0
  169. data/spec/typecast/float_spec.rb +12 -0
  170. data/spec/typecast/integer_spec.rb +8 -0
  171. data/spec/typecast/nil_spec.rb +16 -0
  172. data/spec/typecast/other_spec.rb +8 -0
  173. data/spec/typecast/range_spec.rb +8 -0
  174. data/spec/typecast/string_spec.rb +8 -0
  175. data/spec/typecast/time_spec.rb +8 -0
  176. data/tasks.rb +37 -0
  177. metadata +238 -0
@@ -0,0 +1,374 @@
1
+ $-w,w = nil, $-w
2
+ require File.join(File.dirname(__FILE__), '../lib/bacon')
3
+ $-w = w
4
+
5
+ # Hooray for meta-testing.
6
+ module MetaTests
7
+ def succeed
8
+ lambda { |block|
9
+ block.should.not.raise Bacon::Error
10
+ true
11
+ }
12
+ end
13
+
14
+ def fail
15
+ lambda { |block|
16
+ block.should.raise Bacon::Error
17
+ true
18
+ }
19
+ end
20
+
21
+ def equal_string(x)
22
+ lambda { |s|
23
+ x == s.to_s
24
+ }
25
+ end
26
+ end
27
+
28
+ describe "Bacon" do
29
+ extend MetaTests
30
+
31
+ it "should have should.satisfy" do
32
+ lambda { should.satisfy { 1 == 1 } }.should succeed
33
+ lambda { should.satisfy { 1 } }.should succeed
34
+
35
+ lambda { should.satisfy { 1 != 1 } }.should fail
36
+ lambda { should.satisfy { false } }.should fail
37
+ lambda { should.satisfy { false } }.should fail
38
+
39
+ lambda { 1.should.satisfy { |n| n % 2 == 0 } }.should fail
40
+ lambda { 2.should.satisfy { |n| n % 2 == 0 } }.should succeed
41
+ end
42
+
43
+ it "should have should.equal" do
44
+ lambda { "string1".should == "string1" }.should succeed
45
+ lambda { "string1".should == "string2" }.should fail
46
+ lambda { "1".should == 1 }.should fail
47
+
48
+ lambda { "string1".should.equal "string1" }.should succeed
49
+ lambda { "string1".should.equal "string2" }.should fail
50
+ lambda { "1".should.equal 1 }.should fail
51
+ end
52
+
53
+ it "should have should.raise" do
54
+ lambda { lambda { raise "Error" }.should.raise }.should succeed
55
+ lambda { lambda { raise "Error" }.should.raise RuntimeError }.should succeed
56
+ lambda { lambda { raise "Error" }.should.not.raise }.should fail
57
+ lambda { lambda { raise "Error" }.should.not.raise(RuntimeError) }.should fail
58
+
59
+ lambda { lambda { 1 + 1 }.should.raise }.should fail
60
+ lambda {
61
+ lambda { raise "Error" }.should.raise(Interrupt)
62
+ }.should.raise
63
+ end
64
+
65
+ it "should have should.raise with a block" do
66
+ lambda { should.raise { raise "Error" } }.should succeed
67
+ lambda { should.raise(RuntimeError) { raise "Error" } }.should succeed
68
+ lambda { should.not.raise { raise "Error" } }.should fail
69
+ lambda { should.not.raise(RuntimeError) { raise "Error" } }.should fail
70
+
71
+ lambda { should.raise { 1 + 1 } }.should fail
72
+ lambda {
73
+ should.raise(Interrupt) { raise "Error" }
74
+ }.should.raise
75
+ end
76
+
77
+ it "should have a should.raise should return the exception" do
78
+ ex = lambda { raise "foo!" }.should.raise
79
+ ex.should.be.kind_of RuntimeError
80
+ ex.message.should =~ /foo/
81
+ end
82
+
83
+ it "should have should.be.an.instance_of" do
84
+ lambda { "string".should.be.instance_of String }.should succeed
85
+ lambda { "string".should.be.instance_of Hash }.should fail
86
+
87
+ lambda { "string".should.be.an.instance_of String }.should succeed
88
+ lambda { "string".should.be.an.instance_of Hash }.should fail
89
+ end
90
+
91
+ it "should have should.be.nil" do
92
+ lambda { nil.should.be.nil }.should succeed
93
+ lambda { nil.should.not.be.nil }.should fail
94
+ lambda { "foo".should.be.nil }.should fail
95
+ lambda { "foo".should.not.be.nil }.should succeed
96
+ end
97
+
98
+ it "should have should.include" do
99
+ lambda { [1,2,3].should.include 2 }.should succeed
100
+ lambda { [1,2,3].should.include 4 }.should fail
101
+
102
+ lambda { {1=>2, 3=>4}.should.include 1 }.should succeed
103
+ lambda { {1=>2, 3=>4}.should.include 2 }.should fail
104
+ end
105
+
106
+ it "should have should.be.a.kind_of" do
107
+ lambda { Array.should.be.kind_of Module }.should succeed
108
+ lambda { "string".should.be.kind_of Object }.should succeed
109
+ lambda { 1.should.be.kind_of Comparable }.should succeed
110
+
111
+ lambda { Array.should.be.a.kind_of Module }.should succeed
112
+
113
+ lambda { "string".should.be.a.kind_of Class }.should fail
114
+ end
115
+
116
+ it "should have should.match" do
117
+ lambda { "string".should.match(/strin./) }.should succeed
118
+ lambda { "string".should =~ /strin./ }.should succeed
119
+
120
+ lambda { "string".should.match(/slin./) }.should fail
121
+ lambda { "string".should =~ /slin./ }.should fail
122
+ end
123
+
124
+ it "should have should.not.raise" do
125
+ lambda { lambda { 1 + 1 }.should.not.raise }.should succeed
126
+ lambda { lambda { 1 + 1 }.should.not.raise(Interrupt) }.should succeed
127
+
128
+ lambda {
129
+ lambda {
130
+ lambda {
131
+ Kernel.raise ZeroDivisionError.new("ArgumentError")
132
+ }.should.not.raise(RuntimeError, Comparable)
133
+ }.should.raise ZeroDivisionError
134
+ }.should succeed
135
+
136
+ lambda { lambda { raise "Error" }.should.not.raise }.should fail
137
+ end
138
+
139
+ it "should have should.throw" do
140
+ lambda { lambda { throw :foo }.should.throw(:foo) }.should succeed
141
+ lambda { lambda { :foo }.should.throw(:foo) }.should fail
142
+
143
+ should.throw(:foo) { throw :foo }
144
+ end
145
+
146
+ it "should have should.not.satisfy" do
147
+ lambda { should.not.satisfy { 1 == 2 } }.should succeed
148
+ lambda { should.not.satisfy { 1 == 1 } }.should fail
149
+ end
150
+
151
+ it "should have should.not.equal" do
152
+ lambda { "string1".should.not == "string2" }.should succeed
153
+ lambda { "string1".should.not == "string1" }.should fail
154
+ end
155
+
156
+ it "should have should.not.match" do
157
+ lambda { "string".should.not.match(/sling/) }.should succeed
158
+ lambda { "string".should.not.match(/string/) }.should fail
159
+ # lambda { "string".should.not.match("strin") }.should fail
160
+
161
+ lambda { "string".should.not =~ /sling/ }.should succeed
162
+ lambda { "string".should.not =~ /string/ }.should fail
163
+ # lambda { "string".should.not =~ "strin" }.should fail
164
+ end
165
+
166
+ it "should have should.be.identical_to/same_as" do
167
+ lambda { s = "string"; s.should.be.identical_to s }.should succeed
168
+ lambda { "string".should.be.identical_to "string" }.should fail
169
+
170
+ lambda { s = "string"; s.should.be.same_as s }.should succeed
171
+ lambda { "string".should.be.same_as "string" }.should fail
172
+ end
173
+
174
+ it "should have should.respond_to" do
175
+ lambda { "foo".should.respond_to :to_s }.should succeed
176
+ lambda { 5.should.respond_to :to_str }.should fail
177
+ lambda { :foo.should.respond_to :nx }.should fail
178
+ end
179
+
180
+ it "should have should.be.close" do
181
+ lambda { 1.4.should.be.close 1.4, 0 }.should succeed
182
+ lambda { 0.4.should.be.close 0.5, 0.1 }.should succeed
183
+
184
+ lambda { 0.4.should.be.close 0.5, 0.05 }.should fail
185
+ lambda { 0.4.should.be.close Object.new, 0.1 }.should fail
186
+ lambda { 0.4.should.be.close 0.5, -0.1 }.should fail
187
+ end
188
+
189
+ it "should support multiple negation" do
190
+ lambda { 1.should.equal 1 }.should succeed
191
+ lambda { 1.should.not.equal 1 }.should fail
192
+ lambda { 1.should.not.not.equal 1 }.should succeed
193
+ lambda { 1.should.not.not.not.equal 1 }.should fail
194
+
195
+ lambda { 1.should.equal 2 }.should fail
196
+ lambda { 1.should.not.equal 2 }.should succeed
197
+ lambda { 1.should.not.not.equal 2 }.should fail
198
+ lambda { 1.should.not.not.not.equal 2 }.should succeed
199
+ end
200
+
201
+ it "should have should.<predicate>" do
202
+ lambda { [].should.be.empty }.should succeed
203
+ lambda { [1,2,3].should.not.be.empty }.should succeed
204
+
205
+ lambda { [].should.not.be.empty }.should fail
206
+ lambda { [1,2,3].should.be.empty }.should fail
207
+
208
+ lambda { {1=>2, 3=>4}.should.has_key 1 }.should succeed
209
+ lambda { {1=>2, 3=>4}.should.not.has_key 2 }.should succeed
210
+
211
+ lambda { nil.should.bla }.should.raise(NoMethodError)
212
+ lambda { nil.should.not.bla }.should.raise(NoMethodError)
213
+ end
214
+
215
+ it "should have should <operator> (>, >=, <, <=, ===)" do
216
+ lambda { 2.should.be > 1 }.should succeed
217
+ lambda { 1.should.be > 2 }.should fail
218
+
219
+ lambda { 1.should.be < 2 }.should succeed
220
+ lambda { 2.should.be < 1 }.should fail
221
+
222
+ lambda { 2.should.be >= 1 }.should succeed
223
+ lambda { 2.should.be >= 2 }.should succeed
224
+ lambda { 2.should.be >= 2.1 }.should fail
225
+
226
+ lambda { 2.should.be <= 1 }.should fail
227
+ lambda { 2.should.be <= 2 }.should succeed
228
+ lambda { 2.should.be <= 2.1 }.should succeed
229
+
230
+ lambda { Array.should === [1,2,3] }.should succeed
231
+ lambda { Integer.should === [1,2,3] }.should fail
232
+
233
+ lambda { /foo/.should === "foobar" }.should succeed
234
+ lambda { "foobar".should === /foo/ }.should fail
235
+ end
236
+
237
+ it "should allow for custom shoulds" do
238
+ lambda { (1+1).should equal_string("2") }.should succeed
239
+ lambda { (1+2).should equal_string("2") }.should fail
240
+
241
+ lambda { (1+1).should.be equal_string("2") }.should succeed
242
+ lambda { (1+2).should.be equal_string("2") }.should fail
243
+
244
+ lambda { (1+1).should.not equal_string("2") }.should fail
245
+ lambda { (1+2).should.not equal_string("2") }.should succeed
246
+ lambda { (1+2).should.not.not equal_string("2") }.should fail
247
+
248
+ lambda { (1+1).should.not.be equal_string("2") }.should fail
249
+ lambda { (1+2).should.not.be equal_string("2") }.should succeed
250
+ end
251
+
252
+ it "should have should.flunk" do
253
+ lambda { should.flunk }.should fail
254
+ lambda { should.flunk "yikes" }.should fail
255
+ end
256
+ end
257
+
258
+ describe "before/after" do
259
+ before do
260
+ @a = 1
261
+ @b = 2
262
+ end
263
+
264
+ before do
265
+ @a = 2
266
+ end
267
+
268
+ after do
269
+ @a.should.equal 2
270
+ @a = 3
271
+ end
272
+
273
+ after do
274
+ @a.should.equal 3
275
+ end
276
+
277
+ it "should run in the right order" do
278
+ @a.should.equal 2
279
+ @b.should.equal 2
280
+ end
281
+
282
+ describe "when nested" do
283
+ before do
284
+ @c = 5
285
+ end
286
+
287
+ it "should run from higher level" do
288
+ @a.should.equal 2
289
+ @b.should.equal 2
290
+ end
291
+
292
+ it "should run at the nested level" do
293
+ @c.should.equal 5
294
+ end
295
+
296
+ before do
297
+ @a = 5
298
+ end
299
+
300
+ it "should run in the right order" do
301
+ @a.should.equal 5
302
+ @a = 2
303
+ end
304
+ end
305
+
306
+ it "should not run from lower level" do
307
+ @c.should.be.nil
308
+ end
309
+
310
+ describe "when nested at a sibling level" do
311
+ it "should not run from sibling level" do
312
+ @c.should.be.nil
313
+ end
314
+ end
315
+ end
316
+
317
+ shared "a shared context" do
318
+ it "gets called where it is included" do
319
+ true.should.be.true
320
+ end
321
+ end
322
+
323
+ shared "another shared context" do
324
+ it "can access data" do
325
+ @magic.should.be.equal 42
326
+ end
327
+ end
328
+
329
+ describe "shared/behaves_like" do
330
+ behaves_like "a shared context"
331
+
332
+ ctx = self
333
+ it "raises NameError when the context is not found" do
334
+ lambda {
335
+ ctx.behaves_like "whoops"
336
+ }.should.raise NameError
337
+ end
338
+
339
+ behaves_like "a shared context"
340
+
341
+ before {
342
+ @magic = 42
343
+ }
344
+ behaves_like "another shared context"
345
+ end
346
+
347
+ describe 'describe arguments' do
348
+
349
+ def check(ctx,name)
350
+ ctx.should.be.an.instance_of Bacon::Context
351
+ ctx.instance_variable_get('@name').should == name
352
+ end
353
+
354
+ it 'should work with string' do
355
+ check(describe('string') {},'string')
356
+ end
357
+
358
+ it 'should work with symbols' do
359
+ check(describe(:behaviour) {},'behaviour')
360
+ end
361
+
362
+ it 'should work with modules' do
363
+ check(describe(Bacon) {},'Bacon')
364
+ end
365
+
366
+ it 'should work with namespaced modules' do
367
+ check(describe(Bacon::Context) {},'Bacon::Context')
368
+ end
369
+
370
+ it 'should work with multiple arguments' do
371
+ check(describe(Bacon::Context, :empty) {},'Bacon::Context empty')
372
+ end
373
+
374
+ end
@@ -0,0 +1,32 @@
1
+ require File.join(File.dirname(__FILE__), '../lib/bacon')
2
+
3
+ describe "#should shortcut for #it('should')" do
4
+
5
+ should "be called" do
6
+ @called = true
7
+ @called.should.be == true
8
+ end
9
+
10
+ should "save some characters by typing should" do
11
+ lambda { should.satisfy { 1 == 1 } }.should.not.raise
12
+ end
13
+
14
+ should "save characters even on failure" do
15
+ lambda { should.satisfy { 1 == 2 } }.should.raise Bacon::Error
16
+ end
17
+
18
+ should "work nested" do
19
+ should.satisfy {1==1}
20
+ end
21
+
22
+ count = Bacon::Counter[:specifications]
23
+ should "add new specifications" do
24
+ # XXX this should +=1 but it's +=2
25
+ (count+1).should == Bacon::Counter[:specifications]
26
+ end
27
+
28
+ should "have been called" do
29
+ @called.should.be == true
30
+ end
31
+
32
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 – 2010 Jakub Šťastný aka Botanicus
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,87 @@
1
+ h1. About
2
+
3
+ Remove trailing whitespace, append missing \n and replace tabs by two spaces.
4
+
5
+ h1. Usage
6
+
7
+ <pre>
8
+ # edit script.rb and all Ruby scripts in lib directory
9
+ code-cleaner script.rb lib
10
+
11
+ # normalize standard input and print output to standard output
12
+ cat script.rb | code-cleaner
13
+
14
+ # add encoding declaration if missing
15
+ code-cleaner --encoding=utf-8
16
+ </pre>
17
+
18
+ h2. Blacklisting & Whitelisting
19
+
20
+ Of course you don't want to remove spaces from other files like PDF documents, images etc. You don't even want to remove spaces from all Ruby scripts, you probably want to ignore vendored files and locally installed gems. And this is where blacklisting and whitelisting comes handy.
21
+
22
+ Default behaviour is to ignore everything from vendor and gems directories and from other directories just files ending with .rb, .rake, .task and .thor are normalized.
23
+
24
+ You can change this behaviour by setting environment variables @BLACKLIST@ and @WHITELIST@. What you pass to these variables will be treated as a regular expression. The default behaviour respond to @BLACKLIST='/(vendor|gems)/'@ and @WHITELIST='(^bin/[^/]+|Rakefile|Thorfile|Gemfile$)|(^.+\.(rb|rake|nake|thor|task|gemspec)$)'@. Here's an example how you can use it:
25
+
26
+ <pre>
27
+ WHITELIST=''^(Rakefile|Thorfile|Gemfile|.+\.(rb|rake|nake|thor|task|gemspec))$'' BLACKLIST='/(vendor|gems)/' code-cleaner .
28
+ </pre>
29
+
30
+ Note that these rules aren't applied for explicit arguments, so if you run @code-cleaner README.textile@, your readme actually will be normalized. It's because blacklisting and whitelisting rules are applied just on directories, so if you run @code-cleaner .@, your readme will stay untouched. Because of this reason @code-cleaner .@ and @code-cleaner *@ will be different.
31
+
32
+ If you want to force blacklisting resp. whitelisting even for explicitly specified files, use @--apply-rules@ switch. If you want just try it, use @--try-apply-rules@ which will tell you which files will be skipped and exit without any editing. If some files left in ARGV, the exit status will be 0, otherwise it will be 1.
33
+
34
+ In your Ruby projects, you might add all files in your @bin@ and @script@ directories into whitelist: @WHITELIST='(^bin/[^/]+|Rakefile|Thorfile|Gemfile$)|(^.+\.(rb|rake|nake|thor|task|gemspec)$)'@
35
+
36
+ h2. Exit statuses
37
+
38
+ If code-cleaner does any changes, the exit status will be 0, otherwise it will be 10. It means you can use it in commands like:
39
+
40
+ <pre>
41
+ if code-cleaner "$file" --apply-rules; then # code-cleaner exits with 0 if some changes were made
42
+ git add "$file" # so the changes will be committed immediately
43
+ fi
44
+ </pre>
45
+
46
+ Or, better and more safe way is to directly check exit status of last command via @$?@ as is used in the default @pre-commit@ hook:
47
+
48
+ <pre>
49
+ code-cleaner .
50
+
51
+ if [ $? -eq 10 ]; then
52
+ echo Any modifications were made
53
+ else
54
+ echo File was changed
55
+ fi
56
+ </pre>
57
+
58
+ h2. Pre-commit hook
59
+
60
+ The best way how you can ensure your sources are clean is to use pre-commit hook, if your SCM provides this function. Plus, if you are using git, just use @load "code-cleaner.rake"@ in your Rakefile and then run @rake hooks:whitespace:install@. There are also alternatives for "Nake":http://github.com/botanicus/nake (@code-cleaner.nake@) and "Thor":http://github.com/wycats/thor (@code-cleaner.thor@). Second way is to use @rake --rakefile /path/to/code-cleaner/tasks/code-cleaner.rake hooks:whitespace:install@ resp. @nake /path/to/code-cleaner/tasks/code-cleaner.nake hooks:whitespace:install@ directly.
61
+
62
+ It might force you to remove your @.git/hooks/pre-commit@ if this file exist. If you haven't done any editation in this file, it's safe to do so and if you done some, then you will need to merge your changes manually. You can do it manually, or, if you are using Nake or Thor, just use @--force@ option.
63
+
64
+ Here's an example how you can integrate code-cleaner to your tasks:
65
+
66
+ <pre>
67
+ begin
68
+ load "code-cleaner.nake"
69
+ rescue LoadError
70
+ warn "If you want to contribute to nake, you have to install code-cleaner gem and then run ./tasks.rb hooks:whitespace:install"
71
+ end
72
+ </pre>
73
+
74
+ Also, if you project run in bundled environment, make sure you have your @bin@ or @script@ directory in your @$PATH@ or change the pre-commit hook to point to the right path to the @code-cleaner@. If you are using Nake or Thor, just specify @--path=bin@ resp. @--path=script@ as an option for the @hooks:whitespace:install@ If you are using Rake, you will have to do it manually.
75
+
76
+
77
+ --encoding=utf-8
78
+ --whitelist=pattern & --blacklist=pattern
79
+
80
+ <pre>
81
+ Nake::Task["hooks:whitespace:install"].tap do |task|
82
+ task.config[:path] = "bin"
83
+ task.config[:encoding] = "utf-8"
84
+ task.config[:whitelist] = '(^bin/[^/]+|Rakefile|Thorfile|Gemfile$)|(^.+\.(rb|rake|nake|thor|task|gemspec)$)'
85
+ #task.config[:blacklist]
86
+ end
87
+ </pre>