toto 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/toto.rb +5 -4
- data/test/test_helper.rb +8 -7
- data/test/toto_test.rb +1 -1
- data/toto.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/toto.rb
CHANGED
@@ -157,6 +157,7 @@ module Toto
|
|
157
157
|
|
158
158
|
def initialize obj, config = {}
|
159
159
|
@obj, @config = obj, config
|
160
|
+
self.load if obj.is_a? Hash
|
160
161
|
end
|
161
162
|
|
162
163
|
def load
|
@@ -169,7 +170,7 @@ module Toto
|
|
169
170
|
|
170
171
|
self.taint
|
171
172
|
self.update data
|
172
|
-
self[:date] = Time.parse(self[:date]) rescue Time.now
|
173
|
+
self[:date] = Time.parse(self[:date].gsub('/', '-')) rescue Time.now
|
173
174
|
self
|
174
175
|
end
|
175
176
|
|
@@ -208,8 +209,8 @@ module Toto
|
|
208
209
|
private
|
209
210
|
|
210
211
|
def markdown text
|
211
|
-
if (
|
212
|
-
Markdown.new(text.to_s.strip, *(
|
212
|
+
if (options = @config[:markdown])
|
213
|
+
Markdown.new(text.to_s.strip, *(options.eql?(true) ? [] : options)).to_html
|
213
214
|
else
|
214
215
|
text.strip
|
215
216
|
end
|
@@ -258,7 +259,7 @@ module Toto
|
|
258
259
|
path, mime = @request.path_info.split('.')
|
259
260
|
route = path.split('/').reject {|i| i.empty? }
|
260
261
|
|
261
|
-
response = Toto::Site.new(@config).go(route, *mime)
|
262
|
+
response = Toto::Site.new(@config).go(route, *(mime ? mime : []))
|
262
263
|
|
263
264
|
@response.body = [response[:body]]
|
264
265
|
@response['Content-Length'] = response[:body].length.to_s
|
data/test/test_helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
2
|
require 'hpricot'
|
3
|
+
require 'riot'
|
3
4
|
|
4
5
|
$:.unshift File.dirname(__FILE__)
|
5
6
|
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
@@ -7,24 +8,24 @@ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
|
7
8
|
require 'toto'
|
8
9
|
|
9
10
|
module Riot
|
10
|
-
|
11
|
-
|
11
|
+
class Assertion
|
12
|
+
assertion(:includes) do |actual, expected|
|
12
13
|
actual.include?(expected) || fail("expected #{actual} to include #{expected}")
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
+
assertion(:includes_html) do |actual, expected|
|
16
17
|
doc = Hpricot.parse(actual)
|
17
|
-
expected = expected.flatten
|
18
|
+
expected = expected.to_a.flatten
|
18
19
|
!(doc/expected.first).empty? || fail("expected #{actual} to contain a <#{expected.first}>")
|
19
20
|
(doc/expected.first).inner_html.match(expected.last) || fail("expected <#{expected.first}> to contain #{expected.last}")
|
20
21
|
end
|
21
22
|
|
22
|
-
|
23
|
+
assertion(:includes_elements) do |actual, selector, count|
|
23
24
|
doc = Hpricot.parse(actual)
|
24
25
|
(doc/selector).size == count || fail("expected #{actual} to contain #{count} #{selector}(s)")
|
25
26
|
end
|
26
27
|
|
27
|
-
|
28
|
+
assertion(:within) do |actual, expected|
|
28
29
|
expected.include?(actual) || fail("expected #{actual} to be within #{expected}")
|
29
30
|
end
|
30
31
|
end
|
data/test/toto_test.rb
CHANGED
@@ -121,7 +121,7 @@ context Toto do
|
|
121
121
|
Toto::Article.new({:body => "there ain't such thing as a free lunch\n" * 10}, @config)
|
122
122
|
end
|
123
123
|
|
124
|
-
should("create a valid summary") { topic.summary.size }.within
|
124
|
+
should("create a valid summary") { topic.summary.size }.within 75..80
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
data/toto.gemspec
CHANGED