mint 0.7.4 → 0.8.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 (70) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +23 -14
  3. data/LICENSE +22 -0
  4. data/README.md +68 -79
  5. data/bin/mint +47 -10
  6. data/bin/mint-epub +1 -4
  7. data/config/templates/base/style.css +187 -0
  8. data/config/templates/default/layout.erb +10 -0
  9. data/config/templates/default/style.css +237 -0
  10. data/config/templates/garden/layout.erb +38 -0
  11. data/config/templates/garden/style.css +303 -0
  12. data/config/templates/nord/layout.erb +11 -0
  13. data/config/templates/nord/style.css +339 -0
  14. data/config/templates/nord-dark/layout.erb +11 -0
  15. data/config/templates/nord-dark/style.css +339 -0
  16. data/config/templates/zen/layout.erb +11 -0
  17. data/config/templates/zen/style.css +114 -0
  18. data/lib/mint/command_line.rb +253 -111
  19. data/lib/mint/css.rb +11 -4
  20. data/lib/mint/css_parser.rb +76 -0
  21. data/lib/mint/css_template.rb +37 -0
  22. data/lib/mint/document.rb +203 -43
  23. data/lib/mint/helpers.rb +50 -10
  24. data/lib/mint/layout.rb +2 -3
  25. data/lib/mint/markdown_template.rb +47 -0
  26. data/lib/mint/mint.rb +181 -114
  27. data/lib/mint/plugin.rb +3 -3
  28. data/lib/mint/plugins/epub.rb +1 -2
  29. data/lib/mint/resource.rb +19 -9
  30. data/lib/mint/style.rb +10 -14
  31. data/lib/mint/version.rb +1 -1
  32. data/lib/mint.rb +1 -0
  33. data/man/mint.1 +135 -0
  34. data/spec/cli/README.md +99 -0
  35. data/spec/cli/argument_parsing_spec.rb +237 -0
  36. data/spec/cli/bin_integration_spec.rb +348 -0
  37. data/spec/cli/configuration_management_spec.rb +363 -0
  38. data/spec/cli/full_workflow_integration_spec.rb +527 -0
  39. data/spec/cli/publish_workflow_spec.rb +368 -0
  40. data/spec/cli/template_management_spec.rb +300 -0
  41. data/spec/css_parser_spec.rb +149 -0
  42. data/spec/css_spec.rb +1 -1
  43. data/spec/document_spec.rb +102 -69
  44. data/spec/helpers_spec.rb +42 -42
  45. data/spec/mint_spec.rb +104 -80
  46. data/spec/plugin_spec.rb +141 -143
  47. data/spec/run_cli_tests.rb +95 -0
  48. data/spec/spec_helper.rb +8 -1
  49. data/spec/style_spec.rb +18 -16
  50. data/spec/support/cli_helpers.rb +169 -0
  51. data/spec/support/fixtures/content-2.md +16 -0
  52. data/spec/support/matchers.rb +1 -1
  53. metadata +116 -224
  54. data/config/syntax.yaml +0 -71
  55. data/config/templates/base/style.sass +0 -144
  56. data/config/templates/default/css/style.css +0 -158
  57. data/config/templates/default/layout.haml +0 -8
  58. data/config/templates/default/style.sass +0 -36
  59. data/config/templates/protocol/layout.haml +0 -7
  60. data/config/templates/protocol/style.sass +0 -20
  61. data/config/templates/zen/css/style.css +0 -145
  62. data/config/templates/zen/layout.haml +0 -7
  63. data/config/templates/zen/style.sass +0 -24
  64. data/features/config.feature +0 -21
  65. data/features/plugins/epub.feature +0 -23
  66. data/features/publish.feature +0 -73
  67. data/features/support/env.rb +0 -15
  68. data/features/templates.feature +0 -79
  69. data/spec/command_line_spec.rb +0 -87
  70. data/spec/plugins/epub_spec.rb +0 -242
data/spec/plugin_spec.rb CHANGED
@@ -9,11 +9,11 @@ describe Mint do
9
9
  describe ".plugins" do
10
10
  it "returns all registered plugins" do
11
11
  plugin = Class.new(Mint::Plugin)
12
- Mint.plugins.should == [plugin]
12
+ expect(Mint.plugins).to eq([plugin])
13
13
  end
14
14
 
15
15
  it "returns an empty array if there are no registered plugins" do
16
- Mint.plugins.should == []
16
+ expect(Mint.plugins).to eq([])
17
17
  end
18
18
  end
19
19
 
@@ -22,13 +22,13 @@ describe Mint do
22
22
 
23
23
  it "registers a plugin once" do
24
24
  Mint.register_plugin! plugin
25
- Mint.plugins.should == [plugin]
25
+ expect(Mint.plugins).to eq([plugin])
26
26
  end
27
27
 
28
28
  it "does not register a plugin more than once" do
29
29
  Mint.register_plugin! plugin
30
- lambda { Mint.register_plugin! plugin }.should_not change { Mint.plugins }
31
- Mint.plugins.should == [plugin]
30
+ expect { Mint.register_plugin! plugin }.not_to change { Mint.plugins }
31
+ expect(Mint.plugins).to eq([plugin])
32
32
  end
33
33
  end
34
34
 
@@ -37,13 +37,13 @@ describe Mint do
37
37
 
38
38
  it "activates a plugin once" do
39
39
  Mint.activate_plugin! plugin
40
- Mint.activated_plugins.should == [plugin]
40
+ expect(Mint.activated_plugins).to eq [plugin]
41
41
  end
42
42
 
43
43
  it "does not register a plugin more than once" do
44
44
  Mint.activate_plugin! plugin
45
- lambda { Mint.activate_plugin! plugin }.should_not change { Mint.activated_plugins }
46
- Mint.activated_plugins.should == [plugin]
45
+ expect { Mint.activate_plugin! plugin }.not_to change { Mint.activated_plugins }
46
+ expect(Mint.activated_plugins).to eq [plugin]
47
47
  end
48
48
  end
49
49
 
@@ -51,17 +51,17 @@ describe Mint do
51
51
  let(:plugin) { Class.new }
52
52
 
53
53
  it "does nothing if no plugins are registered" do
54
- lambda { Mint.clear_plugins! }.should_not raise_error
54
+ expect { Mint.clear_plugins! }.not_to raise_error
55
55
  end
56
56
 
57
57
  it "removes all registered plugins" do
58
58
  Mint.register_plugin! plugin
59
- lambda { Mint.clear_plugins! }.should change { Mint.plugins.length }.by(-1)
59
+ expect { Mint.clear_plugins! }.to change { Mint.plugins.length }.by(-1)
60
60
  end
61
61
 
62
62
  it "removes all activated plugins" do
63
63
  Mint.activate_plugin! plugin
64
- lambda { Mint.clear_plugins! }.should change { Mint.activated_plugins.length }.by(-1)
64
+ expect { Mint.clear_plugins! }.to change { Mint.activated_plugins.length }.by(-1)
65
65
  end
66
66
  end
67
67
 
@@ -69,9 +69,9 @@ describe Mint do
69
69
  let(:plugin) { Class.new(Mint::Plugin) }
70
70
 
71
71
  it "gives access to a directory where template files can be stored" do
72
- plugin.should_receive(:name).and_return("DocBook")
73
- Mint.template_directory(plugin).should ==
74
- Mint.root + "/plugins/templates/doc_book"
72
+ expect(plugin).to receive(:name).and_return("DocBook")
73
+ expect(Mint.template_directory(plugin)).to eq(
74
+ Mint::ROOT + "/plugins/templates/doc_book")
75
75
  end
76
76
  end
77
77
 
@@ -79,9 +79,9 @@ describe Mint do
79
79
  let(:plugin) { Class.new(Mint::Plugin) }
80
80
 
81
81
  it "gives access to a directory where template files can be stored" do
82
- plugin.should_receive(:name).and_return("DocBook")
83
- Mint.config_directory(plugin).should ==
84
- Mint.root + "/plugins/config/doc_book"
82
+ expect(plugin).to receive(:name).and_return("DocBook")
83
+ expect(Mint.config_directory(plugin)).to eq(
84
+ Mint::ROOT + "/plugins/config/doc_book")
85
85
  end
86
86
  end
87
87
 
@@ -89,9 +89,9 @@ describe Mint do
89
89
  let(:plugin) { Class.new(Mint::Plugin) }
90
90
 
91
91
  it "gives access to a directory where template files can be stored" do
92
- plugin.should_receive(:name).and_return("DocBook")
93
- Mint.commandline_options_file(plugin).should ==
94
- Mint.root + "/plugins/config/doc_book/syntax.yml"
92
+ expect(plugin).to receive(:name).and_return("DocBook")
93
+ expect(Mint.commandline_options_file(plugin)).to eq(
94
+ Mint::ROOT + "/plugins/config/doc_book/syntax.yml")
95
95
  end
96
96
  end
97
97
 
@@ -103,40 +103,40 @@ describe Mint do
103
103
 
104
104
  context "when plugins are specified" do
105
105
  before do
106
- first_plugin.should_receive(callback).ordered.and_return("first")
107
- second_plugin.should_receive(callback).ordered.and_return("second")
108
- third_plugin.should_receive(callback).never
106
+ expect(first_plugin).to receive(callback).ordered.and_return("first")
107
+ expect(second_plugin).to receive(callback).ordered.and_return("second")
108
+ expect(third_plugin).to receive(callback).never
109
109
  end
110
110
 
111
111
  it "reduces .#{callback} across all specified plugins in order" do
112
112
  plugins = [first_plugin, second_plugin]
113
- Mint.send(callback, "text", :plugins => plugins).should == "second"
113
+ expect(Mint.send(callback, "text", :plugins => plugins)).to eq("second")
114
114
  end
115
115
  end
116
116
 
117
117
  context "when plugins are activated, but no plugins are specified" do
118
118
  before do
119
- first_plugin.should_receive(callback).ordered.and_return("first")
120
- second_plugin.should_receive(callback).ordered.and_return("second")
121
- third_plugin.should_receive(callback).never
119
+ expect(first_plugin).to receive(callback).ordered.and_return("first")
120
+ expect(second_plugin).to receive(callback).ordered.and_return("second")
121
+ expect(third_plugin).to receive(callback).never
122
122
  end
123
123
 
124
124
  it "reduces .#{callback} across all activated plugins in order" do
125
125
  Mint.activate_plugin! first_plugin
126
126
  Mint.activate_plugin! second_plugin
127
- Mint.send(callback, "text").should == "second"
127
+ expect(Mint.send(callback, "text")).to eq("second")
128
128
  end
129
129
  end
130
130
 
131
131
  context "when plugins are not specified" do
132
132
  before do
133
- first_plugin.should_receive(callback).never
134
- second_plugin.should_receive(callback).never
135
- third_plugin.should_receive(callback).never
133
+ expect(first_plugin).to receive(callback).never
134
+ expect(second_plugin).to receive(callback).never
135
+ expect(third_plugin).to receive(callback).never
136
136
  end
137
137
 
138
138
  it "returns the parameter text" do
139
- Mint.send(callback, "text").should == "text"
139
+ expect(Mint.send(callback, "text")).to eq("text")
140
140
  end
141
141
  end
142
142
  end
@@ -149,9 +149,9 @@ describe Mint do
149
149
 
150
150
  context "when plugins are specified" do
151
151
  before do
152
- first_plugin.should_receive(:after_publish).ordered
153
- second_plugin.should_receive(:after_publish).ordered
154
- third_plugin.should_receive(:after_publish).never
152
+ expect(first_plugin).to receive(:after_publish).ordered
153
+ expect(second_plugin).to receive(:after_publish).ordered
154
+ expect(third_plugin).to receive(:after_publish).never
155
155
  end
156
156
 
157
157
  it "iterates across all specified plugins in order" do
@@ -162,9 +162,9 @@ describe Mint do
162
162
 
163
163
  context "when plugins are activated, but no plugins are specified" do
164
164
  before do
165
- first_plugin.should_receive(:after_publish).ordered
166
- second_plugin.should_receive(:after_publish).ordered
167
- third_plugin.should_receive(:after_publish).never
165
+ expect(first_plugin).to receive(:after_publish).ordered
166
+ expect(second_plugin).to receive(:after_publish).ordered
167
+ expect(third_plugin).to receive(:after_publish).never
168
168
  end
169
169
 
170
170
  it "iterates across all activated plugins in order" do
@@ -176,9 +176,9 @@ describe Mint do
176
176
 
177
177
  context "when plugins are not specified" do
178
178
  before do
179
- first_plugin.should_receive(:after_publish).never
180
- second_plugin.should_receive(:after_publish).never
181
- third_plugin.should_receive(:after_publish).never
179
+ expect(first_plugin).to receive(:after_publish).never
180
+ expect(second_plugin).to receive(:after_publish).never
181
+ expect(third_plugin).to receive(:after_publish).never
182
182
  end
183
183
 
184
184
  it "does not iterate over any plugins" do
@@ -188,21 +188,21 @@ describe Mint do
188
188
  end
189
189
 
190
190
  # TODO: Document expected document functionality changes related to plugins
191
- describe Mint::Document do
192
- context "when plugins are registered with Mint" do
193
- describe "#content=" do
194
- it "applies each registered plugin's before_render filter"
195
- end
196
-
197
- describe "#render" do
198
- it "applies each registered plugin's after_render filter"
199
- end
200
-
201
- describe "#publish!" do
202
- it "applies each registered plugin's after_publish filter"
203
- end
204
- end
205
- end
191
+ # describe Mint::Document do
192
+ # context "when plugins are registered with Mint" do
193
+ # describe "#content=" do
194
+ # it "applies each registered plugin's before_render filter"
195
+ # end
196
+
197
+ # describe "#render" do
198
+ # it "applies each registered plugin's after_render filter"
199
+ # end
200
+
201
+ # describe "#publish!" do
202
+ # it "applies each registered plugin's after_publish filter"
203
+ # end
204
+ # end
205
+ # end
206
206
 
207
207
  describe Mint::Plugin do
208
208
  # We have to instantiate these plugins in a before block,
@@ -217,32 +217,32 @@ describe Mint do
217
217
  describe ".underscore" do
218
218
  let(:plugin) { Class.new(Mint::Plugin) }
219
219
 
220
- it "when anonymous, returns a random identifier"
220
+ # it "when anonymous, returns a random identifier"
221
221
 
222
222
  it "when named, returns its name, underscored" do
223
- plugin.should_receive(:name).and_return("EPub")
224
- plugin.underscore.should == "epub"
223
+ expect(plugin).to receive(:name).and_return("EPub")
224
+ expect(plugin.underscore).to eq("epub")
225
225
  end
226
226
  end
227
227
 
228
228
  describe ".inherited" do
229
229
  it "registers the subclass with Mint as a plugin" do
230
- lambda do
230
+ expect do
231
231
  Class.new(Mint::Plugin)
232
- end.should change { Mint.plugins.length }.by(1)
232
+ end.to change { Mint.plugins.length }.by(1)
233
233
  end
234
234
 
235
235
  it "preserves the order of subclassing" do
236
- Mint.plugins.should == [@first_plugin, @second_plugin]
236
+ expect(Mint.plugins).to eq([@first_plugin, @second_plugin])
237
237
  end
238
238
 
239
239
  it "does not change the order of a plugin when it is monkey-patched" do
240
- lambda do
240
+ expect do
241
241
  @first_plugin.instance_eval do
242
242
  def monkey_patch
243
243
  end
244
244
  end
245
- end.should_not change { Mint.plugins }
245
+ end.not_to change { Mint.plugins }
246
246
  end
247
247
  end
248
248
 
@@ -255,7 +255,7 @@ describe Mint do
255
255
  end
256
256
  end
257
257
 
258
- it "returns a hash of options the plugin can take, including constraints"
258
+ # it "returns a hash of options the plugin can take, including constraints"
259
259
  end
260
260
 
261
261
  context "plugin callbacks" do
@@ -269,7 +269,7 @@ describe Mint do
269
269
  end
270
270
  end
271
271
 
272
- plugin.before_render("text").should == "base"
272
+ expect(plugin.before_render("text")).to eq("base")
273
273
  end
274
274
  end
275
275
 
@@ -281,7 +281,7 @@ describe Mint do
281
281
  end
282
282
  end
283
283
 
284
- plugin.after_render("<html></html>").should == "<!doctype html>"
284
+ expect(plugin.after_render("<html></html>")).to eq("<!doctype html>")
285
285
  end
286
286
  end
287
287
 
@@ -289,20 +289,20 @@ describe Mint do
289
289
  let(:document) { Mint::Document.new "content.md" }
290
290
 
291
291
  it "allows changes to the document extension" do
292
- plugin.instance_eval do
293
- def after_publish(document)
292
+ plugin.class_eval do
293
+ def self.after_publish(document)
294
294
  document.name.gsub! /html$/, "htm"
295
295
  end
296
296
  end
297
297
 
298
- lambda do
298
+ expect do
299
299
  plugin.after_publish(document)
300
- end.should change { document.name.length }.by(-1)
300
+ end.to change { document.name.length }.by(-1)
301
301
  end
302
302
 
303
303
  it "allows splitting up the document into two, without garbage" do
304
- plugin.instance_eval do
305
- def after_publish(document)
304
+ plugin.class_eval do
305
+ def self.after_publish(document)
306
306
  content = document.content
307
307
  fake_splitting_point = content.length / 2
308
308
 
@@ -323,58 +323,58 @@ describe Mint do
323
323
 
324
324
  document.publish! :plugins => [plugin]
325
325
 
326
- File.exist?(document.destination_file).should be_false
327
- File.exist?("first-half.html").should be_true
328
- File.exist?("second-half.html").should be_true
329
- end
330
-
331
- it "allows changes to the style file" do
332
- pending "figure out a better strategy for style manipulation"
333
- document = Mint::Document.new "content.md", :style => "style.css"
334
-
335
- plugin.instance_eval do
336
- def after_publish(document)
337
- # I'd like to take document.style_destination_file,
338
- # but the current Mint API doesn't allow for this
339
- # if we're setting the style via a concrete
340
- # stylesheet in our current directory
341
- style_source = document.style.source_file
342
- style = File.read style_source
343
- File.open style_source, "w" do |file|
344
- file << style.gsub(/#/, ".")
345
- end
346
- end
347
- end
348
-
349
- document.publish! :plugins => [plugin]
350
-
351
- File.read(document.style.source_file).should =~ /\#container/
326
+ expect(File.exist?(document.destination_file)).to be_falsy
327
+ expect(File.exist?("first-half.html")).to be_truthy
328
+ expect(File.exist?("second-half.html")).to be_truthy
352
329
  end
353
330
 
354
- context "when the output is in the default directory" do
355
- it "doesn't allow changes to the document directory" do
356
- pending "figuring out the best way to prevent directory manipulation"
357
- document = Mint::Document.new "content.md"
358
- plugin.instance_eval do
359
- def after_publish
360
- original = document.destination_directory
361
- new = File.expand_path "invalid"
362
- FileUtils.mv original, new
363
- document.destination = "invalid"
364
- end
365
-
366
- lambda do
367
- document.publish! :plugins => [plugin]
368
- end.should raise_error(InvalidPluginAction)
369
- end
370
- end
371
- end
331
+ # it "allows changes to the style file" do
332
+ # pending "figure out a better strategy for style manipulation"
333
+ # document = Mint::Document.new "content.md", style: "style.css"
334
+
335
+ # plugin.instance_eval do
336
+ # def after_publish(document)
337
+ # # I'd like to take document.style_destination_file,
338
+ # # but the current Mint API doesn't allow for this
339
+ # # if we're setting the style via a concrete
340
+ # # stylesheet in our current directory
341
+ # style_source = document.style.source_file
342
+ # style = File.read style_source
343
+ # File.open style_source, "w" do |file|
344
+ # file << style.gsub(/#/, ".")
345
+ # end
346
+ # end
347
+ # end
348
+
349
+ # document.publish! :plugins => [plugin]
350
+
351
+ # File.read(document.style.source_file).should =~ /\#container/
352
+ # end
353
+
354
+ # context "when the output is in the default directory" do
355
+ # it "doesn't allow changes to the document directory" do
356
+ # pending "figuring out the best way to prevent directory manipulation"
357
+ # document = Mint::Document.new "content.md"
358
+ # plugin.instance_eval do
359
+ # def after_publish
360
+ # original = document.destination_directory
361
+ # new = File.expand_path "invalid"
362
+ # FileUtils.mv original, new
363
+ # document.destination = "invalid"
364
+ # end
365
+
366
+ # expect do
367
+ # document.publish! :plugins => [plugin]
368
+ # end.to raise_error(InvalidPluginAction)
369
+ # end
370
+ # end
371
+ # end
372
372
 
373
373
  context "when the output is a new directory" do
374
374
  it "allows changes to the document directory" do
375
- document = Mint::Document.new "content.md", :destination => "destination"
376
- plugin.instance_eval do
377
- def after_publish(document)
375
+ document = Mint::Document.new "content.md", destination: "destination"
376
+ plugin.class_eval do
377
+ def self.after_publish(document)
378
378
  original = document.destination_directory
379
379
  new = File.expand_path "book"
380
380
  FileUtils.mv original, new
@@ -383,22 +383,20 @@ describe Mint do
383
383
  end
384
384
 
385
385
  document.publish! :plugins => [plugin]
386
- File.exist?("destination").should be_false
387
- File.exist?("book").should be_true
388
- document.destination_directory.should == File.expand_path("book")
386
+ expect(File.exist?("destination")).to be_falsy
387
+ expect(File.exist?("book")).to be_truthy
388
+ expect(document.destination_directory).to eq(File.expand_path("book"))
389
389
  end
390
390
 
391
391
  it "allows compression of the final output" do
392
- require "zip/zip"
393
- require "zip/zipfilesystem"
394
-
395
- document = Mint::Document.new "content.md", :destination => "destination"
396
- plugin.instance_eval do
397
- def after_publish(document)
398
- Zip::ZipOutputStream.open "book.zip" do |zos|
399
- # zos.put_next_entry("mimetype", nil, nil, Zip::ZipEntry::STORED)
400
- # zos.puts "text/epub"
401
- zos.put_next_entry("chapter-1", nil, nil, Zip::ZipEntry::DEFLATED)
392
+ require "zip"
393
+ require "zip/filesystem"
394
+
395
+ document = Mint::Document.new "content.md", destination: "destination"
396
+ plugin.class_eval do
397
+ def self.after_publish(document)
398
+ Zip::OutputStream.open("book.zip") do |zos|
399
+ zos.put_next_entry("chapter-1.html")
402
400
  zos.puts File.read(document.destination_file)
403
401
  end
404
402
 
@@ -408,9 +406,9 @@ describe Mint do
408
406
 
409
407
  document.publish! :plugins => [plugin]
410
408
 
411
- File.exist?("destination").should be_true
412
- File.exist?("book.zip").should be_false
413
- File.exist?("book.epub").should be_true
409
+ expect(File.exist?("destination")).to be_truthy
410
+ expect(File.exist?("book.zip")).to be_falsy
411
+ expect(File.exist?("book.epub")).to be_truthy
414
412
 
415
413
  directory_size =
416
414
  Dir["#{document.destination_directory}/**/*"].
@@ -418,15 +416,15 @@ describe Mint do
418
416
  map {|file| File.stat(file).size }.
419
417
  reduce(&:+)
420
418
  compressed_size = File.stat("book.epub").size
421
- directory_size.should > compressed_size
419
+ expect(directory_size).to be > compressed_size
422
420
  end
423
421
  end
424
422
 
425
423
  context "when the style output is a new directory" do
426
424
  it "allows changes to the style directory" do
427
- document = Mint::Document.new "content.md", :style_destination => "styles"
428
- plugin.instance_eval do
429
- def after_publish(document)
425
+ document = Mint::Document.new "content.md", style_destination: "styles"
426
+ plugin.class_eval do
427
+ def self.after_publish(document)
430
428
  original = document.style_destination_directory
431
429
  new = File.expand_path "looks"
432
430
  FileUtils.mv original, new
@@ -436,9 +434,9 @@ describe Mint do
436
434
 
437
435
  document.publish! :plugins => [plugin]
438
436
 
439
- File.exist?("styles").should be_false
440
- File.exist?("looks").should be_true
441
- document.style_destination_directory.should == File.expand_path("looks")
437
+ expect(File.exist?("styles")).to be_falsy
438
+ expect(File.exist?("looks")).to be_truthy
439
+ expect(document.style_destination_directory).to eq(File.expand_path("looks"))
442
440
  end
443
441
 
444
442
  after do
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # CLI Test Runner for Mint
4
+ # Runs the comprehensive CLI test suite with better output formatting
5
+
6
+ require 'colorize'
7
+ require 'benchmark'
8
+
9
+ def run_test_suite(pattern, description)
10
+ puts "\n#{'=' * 60}".cyan
11
+ puts " #{description}".cyan.bold
12
+ puts "#{'=' * 60}".cyan
13
+
14
+ time = Benchmark.measure do
15
+ system("rspec #{pattern} --format documentation --color")
16
+ end
17
+
18
+ puts "\n⏱️ Time: #{time.real.round(2)}s".yellow
19
+ $?.success?
20
+ end
21
+
22
+ def main
23
+ puts "🧪 Mint CLI Test Suite".green.bold
24
+ puts "Running comprehensive CLI tests...\n"
25
+
26
+ test_suites = [
27
+ ["spec/cli/argument_parsing_spec.rb", "CLI Argument Parsing"],
28
+ ["spec/cli/template_management_spec.rb", "Template Management"],
29
+ ["spec/cli/publish_workflow_spec.rb", "Publishing Workflows"],
30
+ ["spec/cli/configuration_management_spec.rb", "Configuration Management"],
31
+ ["spec/cli/bin_integration_spec.rb", "Binary Integration"],
32
+ ["spec/cli/full_workflow_integration_spec.rb", "Full Workflow Integration"]
33
+ ]
34
+
35
+ results = []
36
+ total_time = Benchmark.measure do
37
+ test_suites.each do |pattern, description|
38
+ if File.exist?(pattern)
39
+ success = run_test_suite(pattern, description)
40
+ results << { name: description, success: success }
41
+ else
42
+ puts "⚠️ Test file #{pattern} not found".yellow
43
+ results << { name: description, success: false }
44
+ end
45
+ end
46
+ end
47
+
48
+ # Summary
49
+ puts "\n#{'=' * 60}".cyan
50
+ puts " TEST SUMMARY".cyan.bold
51
+ puts "#{'=' * 60}".cyan
52
+
53
+ results.each do |result|
54
+ status = result[:success] ? "✅ PASS".green : "❌ FAIL".red
55
+ puts "#{status} #{result[:name]}"
56
+ end
57
+
58
+ passed = results.count {|r| r[:success] }
59
+ total = results.size
60
+
61
+ puts "\n📊 Results: #{passed}/#{total} test suites passed".cyan
62
+ puts "⏱️ Total time: #{total_time.real.round(2)}s".yellow
63
+
64
+ if passed == total
65
+ puts "\n🎉 All CLI tests passed!".green.bold
66
+ exit 0
67
+ else
68
+ puts "\n❌ Some CLI tests failed".red.bold
69
+ exit 1
70
+ end
71
+ end
72
+
73
+ # Run individual test suite if specified
74
+ if ARGV.length > 0
75
+ test_name = ARGV[0]
76
+ pattern = "spec/cli/#{test_name}*_spec.rb"
77
+
78
+ matching_files = Dir.glob(pattern)
79
+ if matching_files.empty?
80
+ puts "❌ No test files found matching: #{pattern}".red
81
+ puts "\nAvailable test suites:".yellow
82
+ Dir.glob("spec/cli/*_spec.rb").each do |file|
83
+ basename = File.basename(file, "_spec.rb")
84
+ puts " - #{basename}"
85
+ end
86
+ exit 1
87
+ end
88
+
89
+ matching_files.each do |file|
90
+ description = File.basename(file, "_spec.rb").split('_').map(&:capitalize).join(' ')
91
+ run_test_suite(file, description)
92
+ end
93
+ else
94
+ main
95
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require "pathname"
2
2
  require "mint"
3
+ require "rspec/its"
3
4
  require_relative "support/matchers"
5
+ require_relative "support/cli_helpers"
4
6
 
5
7
  RSpec.configure do |config|
6
8
  config.before(:all) do
@@ -9,11 +11,16 @@ RSpec.configure do |config|
9
11
  @tmp_dir = File.realpath "/tmp/mint-test"
10
12
 
11
13
  @content_file = "content.md"
14
+ @content_file_2 = "content-2.md"
12
15
  @layout_file = "layout.haml"
13
16
  @static_style_file = "static.css"
14
17
  @dynamic_style_file = "dynamic.sass"
15
18
 
16
- ["content.md", "layout.haml", "static.css", "dynamic.sass"].each do |file|
19
+ ["content.md",
20
+ "content-2.md",
21
+ "layout.haml",
22
+ "static.css",
23
+ "dynamic.sass"].each do |file|
17
24
  FileUtils.cp "spec/support/fixtures/#{file}", @tmp_dir
18
25
  end
19
26