mofo 0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/CHANGELOG +4 -0
  2. data/lib/microformat.rb +11 -1
  3. data/lib/microformat/simple.rb +21 -17
  4. data/lib/mofo/hentry.rb +1 -1
  5. data/lib/mofo/hreview.rb +0 -2
  6. data/lib/mofo/rel_tag.rb +0 -1
  7. data/tests/fixtures/bob.html +69 -0
  8. data/tests/fixtures/chowhound.html +1052 -0
  9. data/tests/fixtures/corkd.html +403 -0
  10. data/tests/fixtures/events.html +39 -0
  11. data/tests/fixtures/fake.html +1 -0
  12. data/tests/fixtures/fauxtank.html +535 -0
  13. data/tests/fixtures/hatom.html +1101 -0
  14. data/tests/fixtures/simple.html +5 -0
  15. data/tests/fixtures/upcoming.html +335 -0
  16. data/tests/format_test.rb +230 -0
  17. data/tests/hatom_test.rb +39 -0
  18. data/tests/test_helper.rb +6 -0
  19. data/tests/xoxo_test.rb +49 -0
  20. data/vendor/testspec-0.2.0/ChangeLog +120 -0
  21. data/vendor/testspec-0.2.0/README +206 -0
  22. data/vendor/testspec-0.2.0/ROADMAP +3 -0
  23. data/vendor/testspec-0.2.0/Rakefile +86 -0
  24. data/vendor/testspec-0.2.0/SPECS +101 -0
  25. data/vendor/testspec-0.2.0/TODO +1 -0
  26. data/vendor/testspec-0.2.0/bin/specrb +103 -0
  27. data/vendor/testspec-0.2.0/examples/stack.rb +38 -0
  28. data/vendor/testspec-0.2.0/examples/stack_spec.rb +119 -0
  29. data/vendor/testspec-0.2.0/lib/test/spec.rb +366 -0
  30. data/vendor/testspec-0.2.0/lib/test/spec/dox.rb +114 -0
  31. data/vendor/testspec-0.2.0/lib/test/spec/rdox.rb +25 -0
  32. data/vendor/testspec-0.2.0/lib/test/spec/should-output.rb +48 -0
  33. data/vendor/testspec-0.2.0/rdoc/classes/Kernel.html +105 -0
  34. data/vendor/testspec-0.2.0/rdoc/classes/Object.html +154 -0
  35. data/vendor/testspec-0.2.0/rdoc/classes/Test/Spec.html +132 -0
  36. data/vendor/testspec-0.2.0/rdoc/classes/Test/Spec/DefinitionError.html +111 -0
  37. data/vendor/testspec-0.2.0/rdoc/classes/Test/Spec/Should.html +863 -0
  38. data/vendor/testspec-0.2.0/rdoc/classes/Test/Spec/ShouldNot.html +411 -0
  39. data/vendor/testspec-0.2.0/rdoc/classes/Test/Spec/TestCase.html +220 -0
  40. data/vendor/testspec-0.2.0/rdoc/classes/Test/Spec/TestCase/ClassMethods.html +290 -0
  41. data/vendor/testspec-0.2.0/rdoc/classes/Test/Spec/TestCase/InstanceMethods.html +195 -0
  42. data/vendor/testspec-0.2.0/rdoc/classes/Test/Unit/UI/RDox/TestRunner.html +222 -0
  43. data/vendor/testspec-0.2.0/rdoc/classes/Test/Unit/UI/SpecDox/TestRunner.html +468 -0
  44. data/vendor/testspec-0.2.0/rdoc/created.rid +1 -0
  45. data/vendor/testspec-0.2.0/rdoc/files/README.html +409 -0
  46. data/vendor/testspec-0.2.0/rdoc/files/ROADMAP.html +112 -0
  47. data/vendor/testspec-0.2.0/rdoc/files/SPECS.html +365 -0
  48. data/vendor/testspec-0.2.0/rdoc/files/lib/test/spec/dox_rb.html +108 -0
  49. data/vendor/testspec-0.2.0/rdoc/files/lib/test/spec/rdox_rb.html +108 -0
  50. data/vendor/testspec-0.2.0/rdoc/files/lib/test/spec/should-output_rb.html +114 -0
  51. data/vendor/testspec-0.2.0/rdoc/files/lib/test/spec_rb.html +123 -0
  52. data/vendor/testspec-0.2.0/rdoc/fr_class_index.html +37 -0
  53. data/vendor/testspec-0.2.0/rdoc/fr_file_index.html +33 -0
  54. data/vendor/testspec-0.2.0/rdoc/fr_method_index.html +95 -0
  55. data/vendor/testspec-0.2.0/rdoc/index.html +24 -0
  56. data/vendor/testspec-0.2.0/rdoc/rdoc-style.css +208 -0
  57. data/vendor/testspec-0.2.0/test/spec_dox.rb +39 -0
  58. data/vendor/testspec-0.2.0/test/spec_flexmock.rb +210 -0
  59. data/vendor/testspec-0.2.0/test/spec_mocha.rb +118 -0
  60. data/vendor/testspec-0.2.0/test/spec_nestedcontexts.rb +26 -0
  61. data/vendor/testspec-0.2.0/test/spec_should-output.rb +26 -0
  62. data/vendor/testspec-0.2.0/test/spec_testspec.rb +311 -0
  63. data/vendor/testspec-0.2.0/test/spec_testspec_order.rb +26 -0
  64. data/vendor/testspec-0.2.0/test/test_testunit.rb +21 -0
  65. metadata +81 -2
@@ -0,0 +1,118 @@
1
+ # Adapted from mocha (http://mocha.rubyforge.org/).
2
+ #
3
+ # Copyright (C) 2006 Revieworld Ltd.
4
+ #
5
+ # You may use, copy and redistribute this library under the same terms
6
+ # as Ruby itself (see www.ruby-lang.org/en/LICENSE.txt) or under the
7
+ # MIT license (see MIT-LICENSE file).
8
+
9
+ require 'test/spec'
10
+
11
+ $: << "/home/chris/src/mocha-0.3.2/lib"
12
+
13
+ begin
14
+ require 'mocha'
15
+ rescue LoadError
16
+ context "mocha" do
17
+ specify "can not be found. BAIL OUT!" do
18
+ end
19
+ end
20
+ else
21
+
22
+ context "mocha" do
23
+ specify "works with test/spec" do
24
+ object = mock()
25
+ object.expects(:expected_method).with(:p1, :p2).returns(:result)
26
+ object.expected_method(:p1, :p2).should.equal :result
27
+ end
28
+ end
29
+
30
+ class Enterprise
31
+ def initialize(dilithium)
32
+ @dilithium = dilithium
33
+ end
34
+
35
+ def go(warp_factor)
36
+ warp_factor.times { @dilithium.nuke(:anti_matter) }
37
+ end
38
+ end
39
+
40
+ context "mocha" do
41
+ specify "works with test/spec and Enterprise example" do
42
+ dilithium = mock()
43
+ dilithium.expects(:nuke).with(:anti_matter).at_least_once # auto-verified at end of test
44
+ enterprise = Enterprise.new(dilithium)
45
+ enterprise.go(2)
46
+ end
47
+ end
48
+
49
+ end # if not rescue LoadError
50
+
51
+
52
+ begin
53
+ require 'stubba'
54
+ rescue LoadError
55
+ context "stubba" do
56
+ specify "can not be found. BAIL OUT!" do
57
+ end
58
+ end
59
+ else
60
+
61
+ class Order
62
+ attr_accessor :shipped_on
63
+
64
+ def total_cost
65
+ line_items.inject(0) { |total, line_item| total + line_item.price } + shipping_cost
66
+ end
67
+
68
+ def total_weight
69
+ line_items.inject(0) { |total, line_item| total + line_item.weight }
70
+ end
71
+
72
+ def shipping_cost
73
+ total_weight * 5 + 10
74
+ end
75
+
76
+ class << self
77
+
78
+ def find_all
79
+ # Database.connection.execute('select * from orders...
80
+ end
81
+
82
+ def number_shipped_since(date)
83
+ find_all.select { |order| order.shipped_on > date }.size
84
+ end
85
+
86
+ def unshipped_value
87
+ find_all.inject(0) { |total, order| order.shipped_on ? total : total + order.total_cost }
88
+ end
89
+
90
+ end
91
+
92
+ end
93
+
94
+ context "stubba" do
95
+ specify "works with test/spec and instance method stubbing" do
96
+ order = Order.new
97
+ order.stubs(:total_weight).returns(10)
98
+ order.shipping_cost.should.equal 60
99
+ end
100
+
101
+ specify "works with test/spec and class method stubbing" do
102
+ now = Time.now; week_in_secs = 7 * 24 * 60 * 60
103
+ order_1 = Order.new; order_1.shipped_on = now - 1 * week_in_secs
104
+ order_2 = Order.new; order_2.shipped_on = now - 3 * week_in_secs
105
+ Order.stubs(:find_all).returns([order_1, order_2])
106
+ Order.number_shipped_since(now - 2 * week_in_secs).should.equal 1
107
+ end
108
+
109
+ specify "works with test/spec and global instance method stubbing" do
110
+ Order.stubs(:find_all).returns([Order.new, Order.new, Order.new])
111
+ Order.any_instance.stubs(:shipped_on).returns(nil)
112
+ Order.any_instance.stubs(:total_cost).returns(10)
113
+ Order.unshipped_value.should.equal 30
114
+ end
115
+ end
116
+
117
+ end # if not rescue LoadError
118
+
@@ -0,0 +1,26 @@
1
+ require 'test/spec'
2
+
3
+ context "Empty context" do
4
+ # should.not.raise
5
+ end
6
+
7
+ context "Outer context" do
8
+ context "Inner context" do
9
+ specify "is nested" do
10
+ end
11
+ specify "has multiple empty specifications" do
12
+ end
13
+ end
14
+ context "Second Inner context" do
15
+ context "Inmost context" do
16
+ specify "works too!" do
17
+ end
18
+ specify "whoo!" do
19
+ end
20
+ end
21
+ specify "is indented properly" do
22
+ end
23
+ specify "still runs in order of definition" do
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ $: << File.dirname(__FILE__) + '/../lib/'
2
+ require 'test/spec'
3
+ require 'test/spec/should-output'
4
+
5
+ context "should.output" do
6
+ specify "works for print" do
7
+ lambda { print "foo" }.should.output "foo"
8
+ lambda { print "foo" }.should.output(/oo/)
9
+ end
10
+
11
+ specify "works for puts" do
12
+ lambda { puts "foo" }.should.output "foo\n"
13
+ lambda { puts "foo" }.should.output(/foo/)
14
+ end
15
+
16
+ specify "works with readline" do
17
+ lambda { require 'readline' }.should.not.raise(LoadError)
18
+ lambda { puts "foo" }.should.output "foo\n"
19
+ lambda { puts "foo" }.should.output(/foo/)
20
+
21
+ File.should.not.exist("/tmp/should_output_#{$$}")
22
+ end
23
+ end
24
+
25
+
26
+
@@ -0,0 +1,311 @@
1
+ $: << File.dirname(__FILE__) + '/../lib/'
2
+ require 'test/spec'
3
+
4
+ class Test::Spec::Should
5
+ # Hooray for meta-testing.
6
+
7
+ def fail
8
+ _wrap_assertion { self._raise(Test::Unit::AssertionFailedError) }
9
+ end
10
+
11
+ def succeed
12
+ _wrap_assertion { self.not._raise(Test::Unit::AssertionFailedError) }
13
+ end
14
+ end
15
+
16
+ context "test/spec" do
17
+ specify "has should.satisfy" do
18
+ lambda { should.satisfy { 1 == 1 } }.should.succeed
19
+ lambda { should.satisfy { 1 } }.should.succeed
20
+
21
+ lambda { should.satisfy { 1 == 2 } }.should.fail
22
+ lambda { should.satisfy { false } }.should.fail
23
+ lambda { should.satisfy { false } }.should.fail
24
+
25
+ lambda { 1.should.satisfy { |n| n % 2 == 0 } }.should.fail
26
+ lambda { 2.should.satisfy { |n| n % 2 == 0 } }.should.succeed
27
+ end
28
+
29
+ specify "has should.equal" do
30
+ lambda { "string1".should.equal "string1" }.should.succeed
31
+ lambda { "string1".should.equal "string2" }.should.fail
32
+ lambda { "1".should.equal 1 }.should.fail
33
+
34
+ lambda { "string1".should == "string1" }.should.succeed
35
+ lambda { "string1".should == "string2" }.should.fail
36
+ lambda { "1".should == 1 }.should.fail
37
+ end
38
+
39
+ specify "has should.raise" do
40
+ lambda { lambda { raise "Error" }.should.raise }.should.succeed
41
+ lambda { lambda { raise "Error" }.should.raise RuntimeError }.should.succeed
42
+ lambda { lambda { raise "Error" }.should.not.raise }.should.fail
43
+ lambda { lambda { raise "Error" }.should.not.raise(RuntimeError) }.should.fail
44
+
45
+ lambda { lambda { 1 + 1 }.should.raise }.should.fail
46
+ lambda { lambda { raise "Error" }.should.raise(Interrupt) }.should.fail
47
+ end
48
+
49
+ specify "should.raise should return the exception" do
50
+ ex = lambda { raise "foo!" }.should.raise
51
+ ex.should.be.kind_of RuntimeError
52
+ ex.message.should.match(/foo/)
53
+ end
54
+
55
+ specify "has should.be_an_instance_of" do
56
+ lambda { "string".should.be_an_instance_of String }.should.succeed
57
+ lambda { "string".should.be_an_instance_of Hash }.should.fail
58
+
59
+ lambda { "string".should.be.instance_of String }.should.succeed
60
+ lambda { "string".should.be.instance_of Hash }.should.fail
61
+
62
+ lambda { "string".should.be.an.instance_of String }.should.succeed
63
+ lambda { "string".should.be.an.instance_of Hash }.should.fail
64
+ end
65
+
66
+ specify "has should.be_nil" do
67
+ lambda { nil.should.be_nil }.should.succeed
68
+ lambda { nil.should.be.nil }.should.succeed
69
+ lambda { nil.should.be nil }.should.succeed
70
+
71
+ lambda { nil.should.not.be_nil }.should.fail
72
+ lambda { nil.should.not.be.nil }.should.fail
73
+ lambda { nil.should.not.be nil }.should.fail
74
+
75
+ lambda { "foo".should.be.nil }.should.fail
76
+ lambda { "bar".should.be nil }.should.fail
77
+
78
+ lambda { "foo".should.not.be.nil }.should.succeed
79
+ lambda { "bar".should.not.be nil }.should.succeed
80
+ end
81
+
82
+ specify "has should.include" do
83
+ lambda { [1,2,3].should.include 2 }.should.succeed
84
+ lambda { [1,2,3].should.include 4 }.should.fail
85
+
86
+ lambda { {1=>2, 3=>4}.should.include 1 }.should.succeed
87
+ lambda { {1=>2, 3=>4}.should.include 2 }.should.fail
88
+ end
89
+
90
+ specify "has should.be_a_kind_of" do
91
+ lambda { Array.should.be_a_kind_of Module }.should.succeed
92
+ lambda { "string".should.be_a_kind_of Object }.should.succeed
93
+ lambda { 1.should.be_a_kind_of Comparable }.should.succeed
94
+
95
+ lambda { Array.should.be.kind_of Module }.should.succeed
96
+ lambda { "string".should.be.kind_of Object }.should.succeed
97
+ lambda { 1.should.be.kind_of Comparable }.should.succeed
98
+
99
+ lambda { Array.should.be.a.kind_of Module }.should.succeed
100
+
101
+ lambda { "string".should.be_a_kind_of Class }.should.fail
102
+ end
103
+
104
+ specify "has should.match" do
105
+ lambda { "string".should.match(/strin./) }.should.succeed
106
+ lambda { "string".should.match("strin") }.should.succeed
107
+ lambda { "string".should =~ /strin./ }.should.succeed
108
+ lambda { "string".should =~ "strin" }.should.succeed
109
+
110
+ lambda { "string".should.match(/slin./) }.should.fail
111
+ lambda { "string".should.match("slin") }.should.fail
112
+ lambda { "string".should =~ /slin./ }.should.fail
113
+ lambda { "string".should =~ "slin" }.should.fail
114
+ end
115
+
116
+ specify "has should.be" do
117
+ thing = "thing"
118
+ lambda { thing.should.be thing }.should.succeed
119
+ lambda { thing.should.be "thing" }.should.fail
120
+
121
+ lambda { 1.should.be(2, 3) }.should.raise(ArgumentError)
122
+ end
123
+
124
+ specify "has 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
+ begin
130
+ lambda {
131
+ raise ZeroDivisionError.new("ArgumentError")
132
+ }.should.not.raise(RuntimeError, StandardError, Comparable)
133
+ rescue ZeroDivisionError
134
+ end
135
+ }.should.succeed
136
+
137
+ lambda { lambda { raise "Error" }.should.not.raise }.should.fail
138
+ end
139
+
140
+ specify "has should.not.be" do
141
+ thing = "thing"
142
+ lambda { thing.should.not.be "thing" }.should.succeed
143
+ lambda { thing.should.not.be thing }.should.fail
144
+
145
+ lambda { thing.should.not.be thing, thing }.should.raise(ArgumentError)
146
+ end
147
+
148
+ specify "has should.not.equal" do
149
+ lambda { "string1".should.not.equal "string2" }.should.succeed
150
+ lambda { "string1".should.not.equal "string1" }.should.fail
151
+ end
152
+
153
+ specify "has should.not.match" do
154
+ lambda { "string".should.not.match(/sling/) }.should.succeed
155
+ lambda { "string".should.not.match(/string/) }.should.fail
156
+ lambda { "string".should.not.match("strin") }.should.fail
157
+
158
+ lambda { "string".should.not =~ /sling/ }.should.succeed
159
+ lambda { "string".should.not =~ /string/ }.should.fail
160
+ lambda { "string".should.not =~ "strin" }.should.fail
161
+ end
162
+
163
+ specify "has should.throw" do
164
+ lambda { lambda { throw :thing }.should.throw(:thing) }.should.succeed
165
+
166
+ lambda { lambda { throw :thing2 }.should.throw(:thing) }.should.fail
167
+ lambda { lambda { 1 + 1 }.should.throw(:thing) }.should.fail
168
+ end
169
+
170
+ specify "has should.not.throw" do
171
+ lambda { lambda { 1 + 1 }.should.not.throw }.should.succeed
172
+ lambda { lambda { throw :thing }.should.not.throw }.should.fail
173
+ end
174
+
175
+ specify "has should.respond_to" do
176
+ lambda { "foo".should.respond_to :to_s }.should.succeed
177
+ lambda { 5.should.respond_to :to_str }.should.fail
178
+ lambda { :foo.should.respond_to :nx }.should.fail
179
+ end
180
+
181
+ specify "has should.be_close" do
182
+ lambda { 1.4.should.be_close 1.4, 0 }.should.succeed
183
+ lambda { 0.4.should.be_close 0.5, 0.1 }.should.succeed
184
+
185
+ lambda { 1.4.should.be.close 1.4, 0 }.should.succeed
186
+ lambda { 0.4.should.be.close 0.5, 0.1 }.should.succeed
187
+
188
+ lambda {
189
+ float_thing = Object.new
190
+ def float_thing.to_f
191
+ 0.2
192
+ end
193
+ float_thing.should.be_close 0.1, 0.1
194
+ }.should.succeed
195
+
196
+ lambda { 0.4.should.be_close 0.5, 0.05 }.should.fail
197
+ lambda { 0.4.should.be_close Object.new, 0.1 }.should.fail
198
+ lambda { 0.4.should.be_close 0.5, -0.1 }.should.fail
199
+ end
200
+
201
+ specify "multiple negation works" do
202
+ lambda { 1.should.equal 1 }.should.succeed
203
+ lambda { 1.should.not.equal 1 }.should.fail
204
+ lambda { 1.should.not.not.equal 1 }.should.succeed
205
+ lambda { 1.should.not.not.not.equal 1 }.should.fail
206
+
207
+ lambda { 1.should.equal 2 }.should.fail
208
+ lambda { 1.should.not.equal 2 }.should.succeed
209
+ lambda { 1.should.not.not.equal 2 }.should.fail
210
+ lambda { 1.should.not.not.not.equal 2 }.should.succeed
211
+ end
212
+
213
+ specify "has should.<predicate>" do
214
+ lambda { [].should.be.empty }.should.succeed
215
+ lambda { [1,2,3].should.not.be.empty }.should.succeed
216
+
217
+ lambda { [].should.not.be.empty }.should.fail
218
+ lambda { [1,2,3].should.be.empty }.should.fail
219
+
220
+ lambda { {1=>2, 3=>4}.should.has_key 1 }.should.succeed
221
+ lambda { {1=>2, 3=>4}.should.not.has_key 2 }.should.succeed
222
+ end
223
+
224
+ specify "has should <operator> (>, >=, <, <=, ===)" do
225
+ lambda { 2.should.be > 1 }.should.succeed
226
+ lambda { 1.should.be > 2 }.should.fail
227
+
228
+ lambda { 1.should.be < 2 }.should.succeed
229
+ lambda { 2.should.be < 1 }.should.fail
230
+
231
+ lambda { 2.should.be >= 1 }.should.succeed
232
+ lambda { 2.should.be >= 2 }.should.succeed
233
+ lambda { 2.should.be >= 2.1 }.should.fail
234
+
235
+ lambda { 2.should.be <= 1 }.should.fail
236
+ lambda { 2.should.be <= 2 }.should.succeed
237
+ lambda { 2.should.be <= 2.1 }.should.succeed
238
+
239
+ lambda { Array.should === [1,2,3] }.should.succeed
240
+ lambda { Integer.should === [1,2,3] }.should.fail
241
+
242
+ lambda { /foo/.should === "foobar" }.should.succeed
243
+ lambda { "foobar".should === /foo/ }.should.fail
244
+ end
245
+
246
+ $contextscope = self
247
+ specify "is robust against careless users" do
248
+ lambda {
249
+ $contextscope.specify
250
+ }.should.raise(ArgumentError)
251
+ lambda {
252
+ $contextscope.specify "foo"
253
+ }.should.raise(ArgumentError)
254
+ lambda {
255
+ Kernel.send(:context, "foo")
256
+ }.should.raise(ArgumentError)
257
+ lambda {
258
+ context "foo" do
259
+ end
260
+ }.should.raise(Test::Spec::DefinitionError)
261
+ end
262
+ end
263
+
264
+ context "setup/teardown" do
265
+ setup do
266
+ @a = 1
267
+ @b = 2
268
+ end
269
+
270
+ setup do
271
+ @a = 2
272
+ end
273
+
274
+ teardown do
275
+ @a.should.equal 2
276
+ @a = 3
277
+ end
278
+
279
+ teardown do
280
+ @a.should.equal 3
281
+ end
282
+
283
+ specify "run in the right order" do
284
+ @a.should.equal 2
285
+ @b.should.equal 2
286
+ end
287
+ end
288
+
289
+ module ContextHelper
290
+ def foo
291
+ 42
292
+ end
293
+ end
294
+
295
+ context "contexts" do
296
+ include ContextHelper
297
+
298
+ FOO = 42
299
+ $class = self.class
300
+
301
+ specify "are defined in class scope" do
302
+ lambda { FOO }.should.not.raise(NameError)
303
+ FOO.should.equal 42
304
+ $class.should.equal Class
305
+ end
306
+
307
+ specify "can include modules" do
308
+ lambda { foo }.should.not.raise(NameError)
309
+ foo.should.equal 42
310
+ end
311
+ end