toto 0.1.0 → 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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -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 (markdown = @config[:markdown])
212
- Markdown.new(text.to_s.strip, *(markdown unless markdown.eql?(true))).to_html
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
@@ -1,5 +1,6 @@
1
- require 'riot'
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
- module AssertionMacros
11
- def includes(expected)
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
- def includes_html(expected)
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
- def includes_elements(selector, count)
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
- def within(expected)
28
+ assertion(:within) do |actual, expected|
28
29
  expected.include?(actual) || fail("expected #{actual} to be within #{expected}")
29
30
  end
30
31
  end
@@ -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 (75..80)
124
+ should("create a valid summary") { topic.summary.size }.within 75..80
125
125
  end
126
126
  end
127
127
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{toto}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["cloudhead"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - cloudhead