inversion 0.12.3 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -1
- data.tar.gz.sig +0 -0
- data/ChangeLog +305 -9
- data/Examples.rdoc +134 -0
- data/GettingStarted.rdoc +44 -0
- data/Guide.rdoc +47 -0
- data/History.rdoc +15 -0
- data/Manifest.txt +7 -2
- data/README.rdoc +9 -10
- data/Rakefile +23 -10
- data/Tags.rdoc +561 -0
- data/lib/inversion.rb +2 -2
- data/lib/inversion/renderstate.rb +46 -11
- data/lib/inversion/template.rb +85 -7
- data/lib/inversion/template/attrtag.rb +1 -1
- data/lib/inversion/template/begintag.rb +8 -8
- data/lib/inversion/template/fragmenttag.rb +60 -0
- data/lib/inversion/template/rescuetag.rb +1 -1
- data/spec/{lib/helpers.rb → helpers.rb} +7 -30
- data/spec/inversion/mixins_spec.rb +55 -65
- data/spec/inversion/monkeypatches_spec.rb +2 -12
- data/spec/inversion/parser_spec.rb +34 -44
- data/spec/inversion/renderstate_spec.rb +123 -69
- data/spec/inversion/sinatra_spec.rb +6 -19
- data/spec/inversion/template/attrtag_spec.rb +56 -76
- data/spec/inversion/template/begintag_spec.rb +24 -41
- data/spec/inversion/template/calltag_spec.rb +1 -18
- data/spec/inversion/template/codetag_spec.rb +6 -24
- data/spec/inversion/template/commenttag_spec.rb +9 -27
- data/spec/inversion/template/configtag_spec.rb +5 -16
- data/spec/inversion/template/containertag_spec.rb +4 -21
- data/spec/inversion/template/defaulttag_spec.rb +6 -23
- data/spec/inversion/template/elsetag_spec.rb +9 -26
- data/spec/inversion/template/elsiftag_spec.rb +7 -24
- data/spec/inversion/template/endtag_spec.rb +6 -23
- data/spec/inversion/template/escapetag_spec.rb +10 -25
- data/spec/inversion/template/fortag_spec.rb +20 -37
- data/spec/inversion/template/fragmenttag_spec.rb +40 -0
- data/spec/inversion/template/iftag_spec.rb +23 -40
- data/spec/inversion/template/importtag_spec.rb +8 -25
- data/spec/inversion/template/includetag_spec.rb +27 -42
- data/spec/inversion/template/node_spec.rb +6 -15
- data/spec/inversion/template/pptag_spec.rb +10 -23
- data/spec/inversion/template/publishtag_spec.rb +4 -21
- data/spec/inversion/template/rescuetag_spec.rb +12 -29
- data/spec/inversion/template/subscribetag_spec.rb +8 -25
- data/spec/inversion/template/tag_spec.rb +24 -37
- data/spec/inversion/template/textnode_spec.rb +8 -24
- data/spec/inversion/template/timedeltatag_spec.rb +31 -43
- data/spec/inversion/template/unlesstag_spec.rb +7 -24
- data/spec/inversion/template/uriencodetag_spec.rb +6 -23
- data/spec/inversion/template/yieldtag_spec.rb +3 -20
- data/spec/inversion/template_spec.rb +155 -108
- data/spec/inversion/tilt_spec.rb +7 -16
- data/spec/inversion_spec.rb +7 -22
- metadata +63 -40
- metadata.gz.sig +0 -0
- data/spec/lib/constants.rb +0 -9
@@ -1,36 +1,19 @@
|
|
1
1
|
#!/usr/bin/env rspec -cfd -b
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname( __FILE__ ).dirname.parent.parent.parent
|
7
|
-
libdir = basedir + 'lib'
|
4
|
+
require_relative '../../helpers'
|
8
5
|
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
12
|
-
|
13
|
-
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
require 'inversion/template'
|
16
7
|
require 'inversion/template/textnode'
|
17
8
|
require 'inversion/template/subscribetag'
|
18
9
|
|
19
10
|
describe Inversion::Template::SubscribeTag do
|
20
11
|
|
21
|
-
before( :all ) do
|
22
|
-
setup_logging( :fatal )
|
23
|
-
end
|
24
|
-
|
25
|
-
after( :all ) do
|
26
|
-
reset_logging()
|
27
|
-
end
|
28
|
-
|
29
12
|
|
30
13
|
it "raises a parse error if the key isn't a simple attribute" do
|
31
14
|
expect {
|
32
15
|
Inversion::Template::SubscribeTag.new( 'a.non-identifier' )
|
33
|
-
}.to
|
16
|
+
}.to raise_error( Inversion::ParseError, /malformed subscribe/i )
|
34
17
|
end
|
35
18
|
|
36
19
|
it "renders the nodes published by an immediate subtemplate with the same key" do
|
@@ -39,7 +22,7 @@ describe Inversion::Template::SubscribeTag do
|
|
39
22
|
|
40
23
|
template.subtemplate = subtemplate
|
41
24
|
|
42
|
-
template.render.
|
25
|
+
expect( template.render ).to eq( '--a style--(subtemplate)' )
|
43
26
|
end
|
44
27
|
|
45
28
|
it "renders nodes published by an immediate subtemplate that's rendered before it" do
|
@@ -48,7 +31,7 @@ describe Inversion::Template::SubscribeTag do
|
|
48
31
|
|
49
32
|
template.subtemplate = subtemplate
|
50
33
|
|
51
|
-
template.render.
|
34
|
+
expect( template.render ).to eq( '--(subtemplate)--a style' )
|
52
35
|
end
|
53
36
|
|
54
37
|
it "doesn't render anything if there are no publications with its key" do
|
@@ -57,12 +40,12 @@ describe Inversion::Template::SubscribeTag do
|
|
57
40
|
|
58
41
|
template.subtemplate = subtemplate
|
59
42
|
|
60
|
-
template.render.
|
43
|
+
expect( template.render ).to eq( '----(subtemplate)' )
|
61
44
|
end
|
62
45
|
|
63
46
|
it "renders a default value if one is supplied" do
|
64
47
|
template = Inversion::Template.new( "<?subscribe not_here || default value! ?>" )
|
65
|
-
template.render.
|
48
|
+
expect( template.render ).to eq( "default value!" )
|
66
49
|
end
|
67
50
|
|
68
51
|
it "doesn't retain published nodes across renders" do
|
@@ -71,8 +54,8 @@ describe Inversion::Template::SubscribeTag do
|
|
71
54
|
|
72
55
|
template.subtemplate = subtemplate
|
73
56
|
|
74
|
-
template.render.
|
75
|
-
template.render.
|
57
|
+
expect( template.render ).to eq( '--a style--(subtemplate)' )
|
58
|
+
expect( template.render ).to eq( '--a style--(subtemplate)' )
|
76
59
|
end
|
77
60
|
|
78
61
|
end
|
@@ -1,23 +1,13 @@
|
|
1
1
|
#!/usr/bin/env rspec -cfd -b
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname( __FILE__ ).dirname.parent.parent.parent
|
7
|
-
libdir = basedir + 'lib'
|
4
|
+
require_relative '../../helpers'
|
8
5
|
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
12
|
-
|
13
|
-
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
require 'inversion/template/tag'
|
16
7
|
|
17
8
|
describe Inversion::Template::Tag do
|
18
9
|
|
19
10
|
before( :all ) do
|
20
|
-
setup_logging( :fatal )
|
21
11
|
@real_derivatives = Inversion::Template::Tag.derivatives.dup
|
22
12
|
@real_types = Inversion::Template::Tag.types.dup
|
23
13
|
end
|
@@ -30,46 +20,43 @@ describe Inversion::Template::Tag do
|
|
30
20
|
after( :all ) do
|
31
21
|
Inversion::Template::Tag.instance_variable_set( :@derivatives, @real_derivatives )
|
32
22
|
Inversion::Template::Tag.instance_variable_set( :@types, @real_types )
|
33
|
-
reset_logging()
|
34
23
|
end
|
35
24
|
|
36
25
|
|
37
26
|
it "loads pluggable types via Rubygems" do
|
38
27
|
pluginfile = '/usr/lib/ruby/gems/1.8/gems/inversion-extra-1.0.8/lib/inversion/template/zebratag.rb'
|
39
|
-
Gem.
|
28
|
+
expect( Gem ).to receive( :find_files ).
|
40
29
|
with( Inversion::Template::Tag::TAG_PLUGIN_PATTERN ).
|
41
30
|
and_return([ pluginfile ])
|
42
|
-
Inversion::Template::Tag.
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}
|
31
|
+
expect( Inversion::Template::Tag ).to receive( :require ) do |filename|
|
32
|
+
expect( filename ).to eq( 'inversion/template/zebratag' )
|
33
|
+
Class.new( Inversion::Template::Tag ) do
|
34
|
+
def self::name; "ZebraTag"; end
|
35
|
+
end
|
36
|
+
end
|
49
37
|
result = Inversion::Template::Tag.load_all
|
50
|
-
result.
|
51
|
-
result.
|
52
|
-
result.
|
53
|
-
result[:zebra].
|
54
|
-
result[:zebra].
|
38
|
+
expect( result ).to be_a( Hash )
|
39
|
+
expect( result.size ).to eq( 1 )
|
40
|
+
expect( result ).to have_key( :zebra )
|
41
|
+
expect( result[:zebra] ).to be_a( Class )
|
42
|
+
expect( result[:zebra] ).to be < Inversion::Template::Tag
|
55
43
|
end
|
56
44
|
|
57
45
|
it "doesn't include abstract tag types in its loading mechanism" do
|
58
46
|
pluginfile = '/usr/lib/ruby/gems/1.8/gems/inversion-extra-1.0.8/lib/inversion/template/zebratag.rb'
|
59
|
-
Gem.
|
47
|
+
expect( Gem ).to receive( :find_files ).
|
60
48
|
with( Inversion::Template::Tag::TAG_PLUGIN_PATTERN ).
|
61
49
|
and_return([ pluginfile ])
|
62
|
-
Inversion::Template::Tag.
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
}
|
50
|
+
expect( Inversion::Template::Tag ).to receive( :require ) do |filename|
|
51
|
+
expect( filename ).to eq( 'inversion/template/zebratag' )
|
52
|
+
Class.new( Inversion::Template::Tag ) do
|
53
|
+
include Inversion::AbstractClass
|
54
|
+
def self::name; "ZebraTag"; end
|
55
|
+
end
|
56
|
+
end
|
70
57
|
result = Inversion::Template::Tag.load_all
|
71
|
-
result.
|
72
|
-
result.
|
58
|
+
expect( result ).to be_a( Hash )
|
59
|
+
expect( result ).to eq( {} )
|
73
60
|
end
|
74
61
|
|
75
62
|
|
@@ -90,7 +77,7 @@ describe Inversion::Template::Tag do
|
|
90
77
|
|
91
78
|
|
92
79
|
it "can render itself as a comment for template debugging" do
|
93
|
-
@tag.as_comment_body.
|
80
|
+
expect( @tag.as_comment_body ).to eq( %{Concrete "the body" at line ??, column ??} )
|
94
81
|
end
|
95
82
|
|
96
83
|
end
|
@@ -1,41 +1,24 @@
|
|
1
1
|
#!/usr/bin/env rspec -cfd -b
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname( __FILE__ ).dirname.parent.parent.parent
|
7
|
-
libdir = basedir + 'lib'
|
4
|
+
require_relative '../../helpers'
|
8
5
|
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
12
|
-
|
13
|
-
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
require 'inversion/template/textnode'
|
16
7
|
|
17
8
|
describe Inversion::Template::TextNode do
|
18
9
|
|
19
|
-
before( :all ) do
|
20
|
-
setup_logging( :fatal )
|
21
|
-
end
|
22
|
-
|
23
10
|
before( :each ) do
|
24
11
|
@state = Inversion::RenderState.new
|
25
12
|
@node = Inversion::Template::TextNode.new( "unto thee" )
|
26
13
|
end
|
27
14
|
|
28
|
-
after( :all ) do
|
29
|
-
reset_logging()
|
30
|
-
end
|
31
|
-
|
32
15
|
|
33
16
|
it "renders itself unchanged" do
|
34
|
-
@node.render( @state ).
|
17
|
+
expect( @node.render( @state ) ).to eq( "unto thee" )
|
35
18
|
end
|
36
19
|
|
37
20
|
it "renders a brief description when rendered as a comment" do
|
38
|
-
@node.as_comment_body.
|
21
|
+
expect( @node.as_comment_body ).to eq( %{Text (9 bytes): "unto thee"} )
|
39
22
|
end
|
40
23
|
|
41
24
|
|
@@ -47,12 +30,12 @@ describe Inversion::Template::TextNode do
|
|
47
30
|
|
48
31
|
it "strips the leading newline if :strip_tag_lines is set" do
|
49
32
|
@state.options[:strip_tag_lines] = true
|
50
|
-
@node.render( @state ).
|
33
|
+
expect( @node.render( @state ) ).to eq( "\tSome stuff\nAnd some other stuff.\n " )
|
51
34
|
end
|
52
35
|
|
53
36
|
it "renders as-is if :strip_tag_lines is not set" do
|
54
37
|
@state.options[:strip_tag_lines] = false
|
55
|
-
@node.render( @state ).
|
38
|
+
expect( @node.render( @state ) ).to eq( @text )
|
56
39
|
end
|
57
40
|
|
58
41
|
end
|
@@ -76,8 +59,9 @@ describe Inversion::Template::TextNode do
|
|
76
59
|
expected_content = LONGER_CONTENT[0,40].dump
|
77
60
|
expected_content[-1,0] = '...'
|
78
61
|
|
79
|
-
|
80
|
-
|
62
|
+
expect(
|
63
|
+
@node.as_comment_body
|
64
|
+
).to eq( %Q{Text (488 bytes): "\\t\\t<p>Lorem ipsum dolor sit amet, consect..."} )
|
81
65
|
end
|
82
66
|
|
83
67
|
end
|
@@ -1,17 +1,8 @@
|
|
1
1
|
#!/usr/bin/env rspec -cfd -b
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname( __FILE__ ).dirname.parent.parent.parent
|
7
|
-
libdir = basedir + 'lib'
|
4
|
+
require_relative '../../helpers'
|
8
5
|
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
12
|
-
|
13
|
-
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
require 'inversion/template/timedeltatag'
|
16
7
|
|
17
8
|
describe Inversion::Template::TimeDeltaTag do
|
@@ -32,8 +23,6 @@ describe Inversion::Template::TimeDeltaTag do
|
|
32
23
|
ENV['TZ'] = 'US/Pacific'
|
33
24
|
ENV['TZ'] = 'PST8PDT' if Time.now.utc_offset.zero?
|
34
25
|
|
35
|
-
setup_logging( :fatal )
|
36
|
-
|
37
26
|
@past = "Fri Aug 20 08:21:35.1876455 -0700 2010"
|
38
27
|
@pasttime = Time.parse( @past )
|
39
28
|
@pastsecs = @pasttime.to_i
|
@@ -49,63 +38,62 @@ describe Inversion::Template::TimeDeltaTag do
|
|
49
38
|
|
50
39
|
before( :each ) do
|
51
40
|
@tag = Inversion::Template::TimeDeltaTag.new( "foo" )
|
52
|
-
Time.
|
41
|
+
allow( Time ).to receive( :now ).and_return( @now )
|
53
42
|
end
|
54
43
|
|
55
44
|
after( :all ) do
|
56
|
-
reset_logging()
|
57
45
|
ENV['TZ'] = @real_tz
|
58
46
|
end
|
59
47
|
|
60
48
|
|
61
49
|
it "renders the attribute as an approximate interval of time if it's a future Time object" do
|
62
50
|
renderstate = Inversion::RenderState.new( :foo => @futuretime )
|
63
|
-
@tag.render( renderstate ).
|
51
|
+
expect( @tag.render( renderstate ) ).to eq( "about a day from now" )
|
64
52
|
end
|
65
53
|
|
66
54
|
it "renders the attribute as an approximate interval of time if it's a past Time object" do
|
67
55
|
renderstate = Inversion::RenderState.new( :foo => @pasttime )
|
68
|
-
@tag.render( renderstate ).
|
56
|
+
expect( @tag.render( renderstate ) ).to eq( "about a day ago" )
|
69
57
|
end
|
70
58
|
|
71
59
|
it "renders the attribute as an approximate interval of time if it's a future Date object" do
|
72
60
|
renderstate = Inversion::RenderState.new( :foo => @futuredate )
|
73
|
-
@tag.render( renderstate ).
|
61
|
+
expect( @tag.render( renderstate ) ).to eq( "16 hours from now" )
|
74
62
|
end
|
75
63
|
|
76
64
|
it "renders the attribute as an approximate interval of time if it's a past Date object" do
|
77
65
|
renderstate = Inversion::RenderState.new( :foo => @pastdate )
|
78
|
-
@tag.render( renderstate ).
|
66
|
+
expect( @tag.render( renderstate ) ).to eq( "2 days ago" )
|
79
67
|
end
|
80
68
|
|
81
69
|
it "renders the attribute as an approximate interval of time if it's a future DateTime object" do
|
82
70
|
renderstate = Inversion::RenderState.new( :foo => @futuredatetime )
|
83
|
-
@tag.render( renderstate ).
|
71
|
+
expect( @tag.render( renderstate ) ).to eq( "about a day from now" )
|
84
72
|
end
|
85
73
|
|
86
74
|
it "renders the attribute as an approximate interval of time if it's a past DateTime object" do
|
87
75
|
renderstate = Inversion::RenderState.new( :foo => @pastdatetime )
|
88
|
-
@tag.render( renderstate ).
|
76
|
+
expect( @tag.render( renderstate ) ).to eq( "about a day ago" )
|
89
77
|
end
|
90
78
|
|
91
79
|
it "renders the attribute as an approximate interval of time if it's a future String object" do
|
92
80
|
renderstate = Inversion::RenderState.new( :foo => @future )
|
93
|
-
@tag.render( renderstate ).
|
81
|
+
expect( @tag.render( renderstate ) ).to eq( "about a day from now" )
|
94
82
|
end
|
95
83
|
|
96
84
|
it "renders the attribute as an approximate interval of time if it's a past String object" do
|
97
85
|
renderstate = Inversion::RenderState.new( :foo => @past )
|
98
|
-
@tag.render( renderstate ).
|
86
|
+
expect( @tag.render( renderstate ) ).to eq( "about a day ago" )
|
99
87
|
end
|
100
88
|
|
101
89
|
it "renders the attribute as an approximate interval of time if it's a future epoch Numeric" do
|
102
90
|
renderstate = Inversion::RenderState.new( :foo => @futuresecs )
|
103
|
-
@tag.render( renderstate ).
|
91
|
+
expect( @tag.render( renderstate ) ).to eq( "about a day from now" )
|
104
92
|
end
|
105
93
|
|
106
94
|
it "renders the attribute as an approximate interval of time if it's a past epoch Numeric" do
|
107
95
|
renderstate = Inversion::RenderState.new( :foo => @pastsecs )
|
108
|
-
@tag.render( renderstate ).
|
96
|
+
expect( @tag.render( renderstate ) ).to eq( "about a day ago" )
|
109
97
|
end
|
110
98
|
|
111
99
|
|
@@ -117,97 +105,97 @@ describe Inversion::Template::TimeDeltaTag do
|
|
117
105
|
|
118
106
|
it "renders a period of a minute or less as 'less than a minute'" do
|
119
107
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 44 )
|
120
|
-
@tag.render( renderstate ).
|
108
|
+
expect( @tag.render( renderstate ) ).to eq( "less than a minute from now" )
|
121
109
|
end
|
122
110
|
|
123
111
|
it "renders a period of 58 seconds as 'a minute'" do
|
124
112
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 58 )
|
125
|
-
@tag.render( renderstate ).
|
113
|
+
expect( @tag.render( renderstate ) ).to eq( "a minute from now" )
|
126
114
|
end
|
127
115
|
|
128
116
|
it "renders a period of 60 seconds as 'a minute'" do
|
129
117
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 60 )
|
130
|
-
@tag.render( renderstate ).
|
118
|
+
expect( @tag.render( renderstate ) ).to eq( "a minute from now" )
|
131
119
|
end
|
132
120
|
|
133
121
|
it "renders a period of 68 seconds as 'a minute'" do
|
134
122
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 68 )
|
135
|
-
@tag.render( renderstate ).
|
123
|
+
expect( @tag.render( renderstate ) ).to eq( "a minute from now" )
|
136
124
|
end
|
137
125
|
|
138
126
|
it "renders a period of 93 seconds as '2 minutes'" do
|
139
127
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 93 )
|
140
|
-
@tag.render( renderstate ).
|
128
|
+
expect( @tag.render( renderstate ) ).to eq( "2 minutes from now" )
|
141
129
|
end
|
142
130
|
|
143
131
|
it "renders a period of 30 minutes as '30 minutes'" do
|
144
132
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 30 * MINUTES )
|
145
|
-
@tag.render( renderstate ).
|
133
|
+
expect( @tag.render( renderstate ) ).to eq( "30 minutes from now" )
|
146
134
|
end
|
147
135
|
|
148
136
|
it "renders a period of 58 minutes as 'about an hour'" do
|
149
137
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 58 * MINUTES )
|
150
|
-
@tag.render( renderstate ).
|
138
|
+
expect( @tag.render( renderstate ) ).to eq( "about an hour from now" )
|
151
139
|
end
|
152
140
|
|
153
141
|
it "renders a period of 89 minutes as 'about an hour'" do
|
154
142
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 89 * MINUTES )
|
155
|
-
@tag.render( renderstate ).
|
143
|
+
expect( @tag.render( renderstate ) ).to eq( "about an hour from now" )
|
156
144
|
end
|
157
145
|
|
158
146
|
it "renders a period of 95 minutes as '2 hours'" do
|
159
147
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 95 * MINUTES )
|
160
|
-
@tag.render( renderstate ).
|
148
|
+
expect( @tag.render( renderstate ) ).to eq( "2 hours from now" )
|
161
149
|
end
|
162
150
|
|
163
151
|
it "renders a period of 17 hours as '17 hours'" do
|
164
152
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 17 * HOURS )
|
165
|
-
@tag.render( renderstate ).
|
153
|
+
expect( @tag.render( renderstate ) ).to eq( "17 hours from now" )
|
166
154
|
end
|
167
155
|
|
168
156
|
it "renders a period of 20 hours as 'about a day'" do
|
169
157
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 20 * HOURS )
|
170
|
-
@tag.render( renderstate ).
|
158
|
+
expect( @tag.render( renderstate ) ).to eq( "about a day from now" )
|
171
159
|
end
|
172
160
|
|
173
161
|
it "renders a period of 6 days as '6 days'" do
|
174
162
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 6 * DAYS )
|
175
|
-
@tag.render( renderstate ).
|
163
|
+
expect( @tag.render( renderstate ) ).to eq( "6 days from now" )
|
176
164
|
end
|
177
165
|
|
178
166
|
it "renders a period of 11 days as 'about a week'" do
|
179
167
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 11 * DAYS )
|
180
|
-
@tag.render( renderstate ).
|
168
|
+
expect( @tag.render( renderstate ) ).to eq( "about a week from now" )
|
181
169
|
end
|
182
170
|
|
183
171
|
it "renders a period of 18 days as '3 weeks'" do
|
184
172
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 18 * DAYS )
|
185
|
-
@tag.render( renderstate ).
|
173
|
+
expect( @tag.render( renderstate ) ).to eq( "3 weeks from now" )
|
186
174
|
end
|
187
175
|
|
188
176
|
it "renders a period of 10 weeks as '10 weeks'" do
|
189
177
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 10 * WEEKS )
|
190
|
-
@tag.render( renderstate ).
|
178
|
+
expect( @tag.render( renderstate ) ).to eq( "10 weeks from now" )
|
191
179
|
end
|
192
180
|
|
193
181
|
it "renders a period of 4 months as '4 months'" do
|
194
182
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 4 * MONTHS )
|
195
|
-
@tag.render( renderstate ).
|
183
|
+
expect( @tag.render( renderstate ) ).to eq( "4 months from now" )
|
196
184
|
end
|
197
185
|
|
198
186
|
it "renders a period of 14 months as '14 months'" do
|
199
187
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 14 * MONTHS )
|
200
|
-
@tag.render( renderstate ).
|
188
|
+
expect( @tag.render( renderstate ) ).to eq( "14 months from now" )
|
201
189
|
end
|
202
190
|
|
203
191
|
it "renders a period of 20 months as '2 years'" do
|
204
192
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 20 * MONTHS )
|
205
|
-
@tag.render( renderstate ).
|
193
|
+
expect( @tag.render( renderstate ) ).to eq( "2 years from now" )
|
206
194
|
end
|
207
195
|
|
208
196
|
it "renders a period of 120 years as '120 years'" do
|
209
197
|
renderstate = Inversion::RenderState.new( :foo => @now_epoch + 120 * YEARS )
|
210
|
-
@tag.render( renderstate ).
|
198
|
+
expect( @tag.render( renderstate ) ).to eq( "120 years from now" )
|
211
199
|
end
|
212
200
|
|
213
201
|
end
|