mango 0.1.1 → 0.5.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.yardopts +6 -0
- data/README.mdown +62 -29
- data/Rakefile +62 -0
- data/VERSION +1 -0
- data/bin/mango +5 -0
- data/doc/HISTORY.mdown +71 -0
- data/doc/ROAD-MAP.mdown +10 -0
- data/lib/mango.rb +7 -0
- data/lib/mango/application.rb +334 -0
- data/lib/mango/content_page.rb +193 -0
- data/lib/mango/dependencies.rb +125 -0
- data/lib/mango/flavored_markdown.rb +82 -0
- data/lib/mango/rack/debugger.rb +22 -0
- data/lib/mango/runner.rb +95 -0
- data/lib/mango/templates/Gemfile +4 -0
- data/lib/mango/templates/README.md +1 -0
- data/lib/mango/templates/config.ru +4 -0
- data/lib/mango/templates/content/index.md +5 -0
- data/lib/mango/templates/themes/default/public/images/particles.gif +0 -0
- data/lib/mango/templates/themes/default/public/javascripts/fireworks.js +546 -0
- data/lib/mango/templates/themes/default/public/javascripts/timer.js +5 -0
- data/lib/mango/templates/themes/default/public/robots.txt +5 -0
- data/lib/mango/templates/themes/default/public/styles/fireworks.css +55 -0
- data/lib/mango/templates/themes/default/public/styles/reset.css +54 -0
- data/lib/mango/templates/themes/default/styles/screen.sass +17 -0
- data/lib/mango/templates/themes/default/views/404.haml +21 -0
- data/lib/mango/templates/themes/default/views/layout.haml +20 -0
- data/lib/mango/templates/themes/default/views/page.haml +3 -0
- data/lib/mango/version.rb +6 -0
- data/mango.gemspec +35 -0
- data/spec/app_root/content/about/index.haml +1 -0
- data/spec/app_root/content/about/us.haml +1 -0
- data/spec/app_root/content/engines/haml.haml +7 -0
- data/spec/app_root/content/engines/markdown.markdown +7 -0
- data/spec/app_root/content/engines/md.md +7 -0
- data/spec/app_root/content/engines/mdown.mdown +7 -0
- data/spec/app_root/content/index.haml +1 -0
- data/spec/app_root/content/override.haml +1 -0
- data/spec/app_root/content/page_with_missing_view.haml +4 -0
- data/spec/app_root/content/turner+hooch.haml +1 -0
- data/spec/app_root/security_hole.haml +1 -0
- data/spec/app_root/themes/default/public/default.css +3 -0
- data/spec/app_root/themes/default/public/images/index.html +10 -0
- data/spec/app_root/themes/default/public/images/ripe-mango.jpg +0 -0
- data/spec/app_root/themes/default/public/override +10 -0
- data/spec/app_root/themes/default/public/robots.txt +2 -0
- data/spec/app_root/themes/default/public/styles/override.css +3 -0
- data/spec/app_root/themes/default/public/styles/reset.css +27 -0
- data/spec/app_root/themes/default/public/styles/subfolder/another.css +3 -0
- data/spec/app_root/themes/default/security_hole.sass +1 -0
- data/spec/app_root/themes/default/security_hole.txt +1 -0
- data/spec/app_root/themes/default/styles/override.sass +2 -0
- data/spec/app_root/themes/default/styles/screen.sass +13 -0
- data/spec/app_root/themes/default/styles/subfolder/screen.sass +12 -0
- data/spec/app_root/themes/default/views/404.haml +7 -0
- data/spec/app_root/themes/default/views/layout.haml +7 -0
- data/spec/app_root/themes/default/views/page.haml +4 -0
- data/spec/mango/application/routing_content_pages_spec.rb +357 -0
- data/spec/mango/application/routing_public_files_spec.rb +181 -0
- data/spec/mango/application/routing_style_sheets_spec.rb +286 -0
- data/spec/mango/application_spec.rb +34 -0
- data/spec/mango/content_page/finding_spec.rb +213 -0
- data/spec/mango/content_page/initializing_spec.rb +298 -0
- data/spec/mango/content_page_spec.rb +44 -0
- data/spec/mango/dependencies_spec.rb +189 -0
- data/spec/mango/flavored_markdown_spec.rb +52 -0
- data/spec/mango/rack/debugger_spec.rb +114 -0
- data/spec/mango/version_spec.rb +18 -0
- data/spec/quality_spec.rb +32 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/matchers/malformed_whitespace_matchers.rb +60 -0
- metadata +304 -17
@@ -0,0 +1,298 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Mango::ContentPage do
|
5
|
+
|
6
|
+
#################################################################################################
|
7
|
+
|
8
|
+
describe "initializing with attributes and Haml body" do
|
9
|
+
before(:all) do
|
10
|
+
@expected_data = <<-EOS
|
11
|
+
---
|
12
|
+
title: Delicious Cake!
|
13
|
+
view: blog
|
14
|
+
---
|
15
|
+
%p So delicious!
|
16
|
+
EOS
|
17
|
+
@expected_content_engine = :haml
|
18
|
+
@page = Mango::ContentPage.new(@expected_data, :content_engine => @expected_content_engine)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should save the data" do
|
22
|
+
@page.data.should == @expected_data
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should use default content engine" do
|
26
|
+
@page.content_engine.should == @expected_content_engine
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should load attributes" do
|
30
|
+
@page.attributes.should have(2).items
|
31
|
+
@page.attributes.should include("title" => "Delicious Cake!")
|
32
|
+
@page.attributes.should include("view" => "blog")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should load body" do
|
36
|
+
@page.body.should == "%p So delicious!\n"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should convert to HTML" do
|
40
|
+
@page.to_html.should == "<p>So delicious!</p>\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should determine the view template's base file name" do
|
44
|
+
@page.view.should == :blog
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
#################################################################################################
|
49
|
+
|
50
|
+
describe "initializing with attributes and Markdown body" do
|
51
|
+
before(:all) do
|
52
|
+
@expected_data = <<-EOS
|
53
|
+
---
|
54
|
+
title: Chocolate Pie!
|
55
|
+
view: blog
|
56
|
+
---
|
57
|
+
### Sweet and crumbly!
|
58
|
+
EOS
|
59
|
+
@expected_content_engine = :markdown
|
60
|
+
@page = Mango::ContentPage.new(@expected_data, :content_engine => @expected_content_engine)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should save the data" do
|
64
|
+
@page.data.should == @expected_data
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should use default content engine" do
|
68
|
+
@page.content_engine.should == @expected_content_engine
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should load attributes" do
|
72
|
+
@page.attributes.should have(2).items
|
73
|
+
@page.attributes.should include("title" => "Chocolate Pie!")
|
74
|
+
@page.attributes.should include("view" => "blog")
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should load body" do
|
78
|
+
@page.body.should == "### Sweet and crumbly!\n"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should convert to HTML" do
|
82
|
+
@page.to_html.should == "<h3>Sweet and crumbly!</h3>"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should determine the view template's base file name" do
|
86
|
+
@page.view.should == :blog
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
#################################################################################################
|
91
|
+
|
92
|
+
describe "initializing with just attributes" do
|
93
|
+
before(:all) do
|
94
|
+
@expected_data = <<-EOS
|
95
|
+
---
|
96
|
+
title: Delicious Cake!
|
97
|
+
view: blog.haml
|
98
|
+
---
|
99
|
+
EOS
|
100
|
+
@page = Mango::ContentPage.new(@expected_data)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should save the data" do
|
104
|
+
@page.data.should == @expected_data
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should use default content engine" do
|
108
|
+
@page.content_engine.should == Mango::ContentPage::DEFAULT[:content_engine]
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should load attributes" do
|
112
|
+
@page.attributes.should have(2).items
|
113
|
+
@page.attributes.should include("title" => "Delicious Cake!")
|
114
|
+
@page.attributes.should include("view" => "blog.haml")
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should load body" do
|
118
|
+
@page.body.should be_empty
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should convert to HTML" do
|
122
|
+
@page.to_html.should be_empty
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should determine the view template's base file name" do
|
126
|
+
@page.view.should == :blog
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
#################################################################################################
|
131
|
+
|
132
|
+
describe "initializing with just body using the default content engine" do
|
133
|
+
before(:all) do
|
134
|
+
@expected_data = <<-EOS
|
135
|
+
### So delicious!
|
136
|
+
EOS
|
137
|
+
@page = Mango::ContentPage.new(@expected_data)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should save the data" do
|
141
|
+
@page.data.should == @expected_data
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should use default content engine" do
|
145
|
+
@page.content_engine.should == Mango::ContentPage::DEFAULT[:content_engine]
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should load attributes" do
|
149
|
+
@page.attributes.should have(1).items
|
150
|
+
@page.attributes.should include("view" => :page)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should load body" do
|
154
|
+
@page.body.should == "### So delicious!\n"
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should convert to HTML" do
|
158
|
+
@page.to_html.should == "<h3>So delicious!</h3>"
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should determine the view template's base file name" do
|
162
|
+
@page.view.should == :page
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
#################################################################################################
|
167
|
+
|
168
|
+
describe "initializing with empty attributes and body" do
|
169
|
+
before(:all) do
|
170
|
+
@expected_data = <<-EOS
|
171
|
+
---
|
172
|
+
---
|
173
|
+
EOS
|
174
|
+
@page = Mango::ContentPage.new(@expected_data)
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should save the data" do
|
178
|
+
@page.data.should == @expected_data
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should use default content engine" do
|
182
|
+
@page.content_engine.should == Mango::ContentPage::DEFAULT[:content_engine]
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should load attributes" do
|
186
|
+
@page.attributes.should have(1).items
|
187
|
+
@page.attributes.should include("view" => :page)
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should load body" do
|
191
|
+
@page.body.should be_empty
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should convert to HTML" do
|
195
|
+
@page.to_html.should be_empty
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should determine the view template's base file name" do
|
199
|
+
@page.view.should == :page
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
#################################################################################################
|
204
|
+
|
205
|
+
describe "initializing with nil" do
|
206
|
+
before(:all) do
|
207
|
+
@expected_data = nil
|
208
|
+
@page = Mango::ContentPage.new(@expected_data)
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should save the data" do
|
212
|
+
@page.data.should == @expected_data
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should use default content engine" do
|
216
|
+
@page.content_engine.should == Mango::ContentPage::DEFAULT[:content_engine]
|
217
|
+
end
|
218
|
+
|
219
|
+
it "should load attributes" do
|
220
|
+
@page.attributes.should have(1).items
|
221
|
+
@page.attributes.should include("view" => :page)
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should load body" do
|
225
|
+
@page.body.should be_empty
|
226
|
+
end
|
227
|
+
|
228
|
+
it "should convert to HTML" do
|
229
|
+
@page.to_html.should be_empty
|
230
|
+
end
|
231
|
+
|
232
|
+
it "should determine the view template's base file name" do
|
233
|
+
@page.view.should == :page
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
#################################################################################################
|
238
|
+
|
239
|
+
describe "initializing with unknown content engine" do
|
240
|
+
before(:all) do
|
241
|
+
@expected_data = ""
|
242
|
+
@expected_content_engine = :unknown
|
243
|
+
@page = Mango::ContentPage.new(@expected_data, :content_engine => @expected_content_engine)
|
244
|
+
end
|
245
|
+
|
246
|
+
it "should save the data" do
|
247
|
+
@page.data.should == @expected_data
|
248
|
+
end
|
249
|
+
|
250
|
+
it "should use unknown content engine" do
|
251
|
+
@page.content_engine.should == @expected_content_engine
|
252
|
+
end
|
253
|
+
|
254
|
+
it "should load attributes" do
|
255
|
+
@page.attributes.should have(1).items
|
256
|
+
@page.attributes.should include("view" => :page)
|
257
|
+
end
|
258
|
+
|
259
|
+
it "should load body" do
|
260
|
+
@page.body.should be_empty
|
261
|
+
end
|
262
|
+
|
263
|
+
it "should raise an exception when converting to HTML" do
|
264
|
+
lambda { @page.to_html }.should raise_exception("Unknown content engine -- unknown")
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should determine the view template's base file name" do
|
268
|
+
@page.view.should == :page
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
#################################################################################################
|
273
|
+
|
274
|
+
describe "initializing with seasonable Markdown body" do
|
275
|
+
it "should season the rendered markup with Mango::FlavoredMarkdown" do
|
276
|
+
data = <<-EOS
|
277
|
+
Mango is like a drug.
|
278
|
+
You must have more_and_more and more of the Mango
|
279
|
+
until there is no Mango left.
|
280
|
+
Not even for Mango!
|
281
|
+
EOS
|
282
|
+
|
283
|
+
page = Mango::ContentPage.new(data, :content_engine => :markdown)
|
284
|
+
|
285
|
+
expected = <<-EOS
|
286
|
+
<p>Mango is like a drug.<br/>
|
287
|
+
You must have more_and_more and more of the Mango<br/>
|
288
|
+
until there is no Mango left.<br/>
|
289
|
+
Not even for Mango!<br/>
|
290
|
+
</p>
|
291
|
+
EOS
|
292
|
+
|
293
|
+
page.to_html.should == expected.strip
|
294
|
+
end
|
295
|
+
|
296
|
+
end
|
297
|
+
|
298
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Mango::ContentPage do
|
5
|
+
|
6
|
+
#################################################################################################
|
7
|
+
|
8
|
+
describe "class constants" do
|
9
|
+
it "should define CONTENT_ENGINES" do
|
10
|
+
Mango::ContentPage::CONTENT_ENGINES.should have(2).item
|
11
|
+
Mango::ContentPage::CONTENT_ENGINES.should include(:haml => ["haml"])
|
12
|
+
Mango::ContentPage::CONTENT_ENGINES.should include(:markdown => ["md", "mdown", "markdown"])
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should define DEFAULT" do
|
16
|
+
Mango::ContentPage::DEFAULT.should have(3).items
|
17
|
+
Mango::ContentPage::DEFAULT.should include(:body => "")
|
18
|
+
Mango::ContentPage::DEFAULT.should include(:content_engine => :markdown)
|
19
|
+
|
20
|
+
attributes = Mango::ContentPage::DEFAULT[:attributes]
|
21
|
+
attributes.should include("view" => :page)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#################################################################################################
|
26
|
+
|
27
|
+
describe "attribute syntactic sugar" do
|
28
|
+
before(:all) do
|
29
|
+
@page = Mango::ContentPage.new <<-EOS
|
30
|
+
---
|
31
|
+
title: Syntactic Sugar Makes Life Sweeter
|
32
|
+
---
|
33
|
+
EOS
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should make title sweeter" do
|
37
|
+
@page.title.should == @page.attributes["title"]
|
38
|
+
end
|
39
|
+
it "should not make unknown sweeter" do
|
40
|
+
lambda { @page.unknown }.should raise_exception(NoMethodError)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Mango::Dependencies do
|
5
|
+
|
6
|
+
#################################################################################################
|
7
|
+
|
8
|
+
describe "class constant and variable defaults" do
|
9
|
+
it "required ruby version should be correct" do
|
10
|
+
Mango::Dependencies::REQUIRED_RUBY_VERSION.should == "1.9.1"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "development gem names and versions should be correct" do
|
14
|
+
expected = {
|
15
|
+
:"rack-test" => "0.5.4",
|
16
|
+
:rspec => "1.3.0",
|
17
|
+
:yard => "0.5.8",
|
18
|
+
:"yard-sinatra" => "0.5.0",
|
19
|
+
:bluecloth => "2.0.7"
|
20
|
+
}
|
21
|
+
|
22
|
+
Mango::Dependencies::DEVELOPMENT_GEMS.should == expected
|
23
|
+
end
|
24
|
+
|
25
|
+
it "file name to gem name look-up table should be correct" do
|
26
|
+
expected = {
|
27
|
+
:"rack/test" => :"rack-test",
|
28
|
+
:"spec/rake/spectask" => :rspec,
|
29
|
+
:"yard/sinatra" => :"yard-sinatra"
|
30
|
+
}
|
31
|
+
Mango::Dependencies::FILE_NAME_TO_GEM_NAME.should == expected
|
32
|
+
end
|
33
|
+
|
34
|
+
it "warnings cache should be empty" do
|
35
|
+
Mango::Dependencies.class_variable_get(:@@warnings_cache).should be_empty
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
#################################################################################################
|
40
|
+
|
41
|
+
describe ".check_ruby_version (private)" do
|
42
|
+
before(:each) do
|
43
|
+
$stderr = StringIO.new
|
44
|
+
end
|
45
|
+
|
46
|
+
after(:each) do
|
47
|
+
$stderr = STDERR
|
48
|
+
end
|
49
|
+
|
50
|
+
def expected_message(version)
|
51
|
+
@expected_message = <<-ERROR
|
52
|
+
This library requires Ruby 1.9.1, but you're using #{version}.
|
53
|
+
Please visit http://www.ruby-lang.org/ for installation instructions.
|
54
|
+
ERROR
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should abort for ruby 1.8.6" do
|
58
|
+
version = "1.8.6"
|
59
|
+
lambda {
|
60
|
+
Mango::Dependencies.send(:check_ruby_version, version)
|
61
|
+
}.should raise_exception(SystemExit, expected_message(version))
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should abort for ruby 1.8.7" do
|
65
|
+
version = "1.8.7"
|
66
|
+
lambda {
|
67
|
+
Mango::Dependencies.send(:check_ruby_version, version)
|
68
|
+
}.should raise_exception(SystemExit, expected_message(version))
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should abort for ruby 1.9.0" do
|
72
|
+
version = "1.9.0"
|
73
|
+
lambda {
|
74
|
+
Mango::Dependencies.send(:check_ruby_version, version)
|
75
|
+
}.should raise_exception(SystemExit, expected_message(version))
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should not abort for ruby 1.9.1" do
|
79
|
+
version = "1.9.1"
|
80
|
+
lambda {
|
81
|
+
Mango::Dependencies.send(:check_ruby_version, version)
|
82
|
+
}.should_not raise_exception(SystemExit, expected_message(version))
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should abort for ruby 1.9.2" do
|
86
|
+
version = "1.9.2"
|
87
|
+
lambda {
|
88
|
+
Mango::Dependencies.send(:check_ruby_version, version)
|
89
|
+
}.should raise_exception(SystemExit, expected_message(version))
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
#################################################################################################
|
94
|
+
|
95
|
+
describe ".destroy_warnings" do
|
96
|
+
it "should empty the warnings cache" do
|
97
|
+
Mango::Dependencies.class_variable_get(:@@warnings_cache).should be_empty
|
98
|
+
|
99
|
+
Mango::Dependencies.create_warning_for(LoadError.new("no such file to load -- yard"))
|
100
|
+
Mango::Dependencies.class_variable_get(:@@warnings_cache).should_not be_empty
|
101
|
+
|
102
|
+
Mango::Dependencies.destroy_warnings
|
103
|
+
Mango::Dependencies.class_variable_get(:@@warnings_cache).should be_empty
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
#################################################################################################
|
108
|
+
|
109
|
+
describe ".create_warning_for" do
|
110
|
+
after(:each) do
|
111
|
+
Mango::Dependencies.destroy_warnings
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should create and cache one warning from a known development gem dependency" do
|
115
|
+
Mango::Dependencies.create_warning_for(LoadError.new("no such file to load -- yard"))
|
116
|
+
Mango::Dependencies.class_variable_get(:@@warnings_cache).should == ["yard --version '0.5.8'"]
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should create and cache warnings from all known development gem dependencies" do
|
120
|
+
Mango::Dependencies::DEVELOPMENT_GEMS.each_key do |file_name|
|
121
|
+
gem_name = if Mango::Dependencies::FILE_NAME_TO_GEM_NAME.has_key?(file_name)
|
122
|
+
Mango::Dependencies::FILE_NAME_TO_GEM_NAME[file_name]
|
123
|
+
else
|
124
|
+
file_name
|
125
|
+
end
|
126
|
+
load_error = LoadError.new("no such file to load -- #{gem_name}")
|
127
|
+
Mango::Dependencies.create_warning_for(load_error)
|
128
|
+
end
|
129
|
+
|
130
|
+
expected = [
|
131
|
+
"rack-test --version '0.5.4'",
|
132
|
+
"rspec --version '1.3.0'",
|
133
|
+
"yard --version '0.5.8'",
|
134
|
+
"yard-sinatra --version '0.5.0'",
|
135
|
+
"bluecloth --version '2.0.7'"
|
136
|
+
]
|
137
|
+
Mango::Dependencies.class_variable_get(:@@warnings_cache).should == expected
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should raise an exception when creating a warning from an unknown development gem dependency" do
|
141
|
+
lambda {
|
142
|
+
Mango::Dependencies.create_warning_for(LoadError.new("no such file to load -- _fakegem"))
|
143
|
+
}.should raise_exception(RuntimeError, "Cannot create a dependency warning for unknown development gem -- _fakegem")
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
#################################################################################################
|
148
|
+
|
149
|
+
describe ".render_warnings" do
|
150
|
+
before(:each) do
|
151
|
+
$stdout = StringIO.new
|
152
|
+
end
|
153
|
+
|
154
|
+
after(:each) do
|
155
|
+
$stdout = STDOUT
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should display a warning message to the user on the standard output channel" do
|
159
|
+
Mango::Dependencies.create_warning_for(LoadError.new("no such file to load -- spec/rake/spectask"))
|
160
|
+
Mango::Dependencies.create_warning_for(LoadError.new("no such file to load -- yard"))
|
161
|
+
Mango::Dependencies.create_warning_for(LoadError.new("no such file to load -- bluecloth"))
|
162
|
+
Mango::Dependencies.render_warnings
|
163
|
+
$stdout.string.should == <<-MESSAGE
|
164
|
+
|
165
|
+
The following development gem dependencies could not be found. Without them, some available development features are missing:
|
166
|
+
rspec --version '1.3.0'
|
167
|
+
yard --version '0.5.8'
|
168
|
+
bluecloth --version '2.0.7'
|
169
|
+
MESSAGE
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should not display a warning message to the user if there are no warnings in the cache" do
|
173
|
+
Mango::Dependencies.destroy_warnings
|
174
|
+
Mango::Dependencies.render_warnings
|
175
|
+
$stdout.string.should be_empty
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
#################################################################################################
|
180
|
+
|
181
|
+
describe ".warn_at_exit" do
|
182
|
+
it "should ensure Kernel#at_exit is invoked with a block" do
|
183
|
+
Mango::Dependencies.should_receive(:at_exit)
|
184
|
+
# TODO how to specify that #at_exit receives a block?
|
185
|
+
# maybe i can intercept the block, execute it and test the output?
|
186
|
+
Mango::Dependencies.warn_at_exit
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|