mint 0.8.0 → 0.10.0

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 (87) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -26
  3. data/README.md +138 -95
  4. data/bin/mint +2 -81
  5. data/config/templates/base/navigation.css +136 -0
  6. data/config/templates/base/print.css +152 -0
  7. data/config/templates/{reset.css → base/reset.css} +1 -1
  8. data/config/templates/base/style.css +117 -137
  9. data/config/templates/base/utilities.css +136 -0
  10. data/config/templates/base/variables.css +124 -0
  11. data/config/templates/basic/style.css +151 -0
  12. data/config/templates/default/layout.erb +33 -3
  13. data/config/templates/default/style.css +95 -164
  14. data/config/templates/magazine/style.css +383 -0
  15. data/config/templates/nord/style.css +105 -220
  16. data/config/templates/nord-dark/style.css +82 -263
  17. data/lib/mint/commandline/parse.rb +144 -0
  18. data/lib/mint/commandline/publish.rb +46 -0
  19. data/lib/mint/commandline/run.rb +30 -0
  20. data/lib/mint/config.rb +162 -0
  21. data/lib/mint/{css.rb → css_dsl.rb} +9 -9
  22. data/lib/mint/css_parser.rb +96 -0
  23. data/lib/mint/document.rb +251 -348
  24. data/lib/mint/document_tree.rb +163 -0
  25. data/lib/mint/exceptions.rb +2 -3
  26. data/lib/mint/helpers.rb +23 -180
  27. data/lib/mint/layout.rb +26 -9
  28. data/lib/mint/renderers/css_renderer.rb +32 -0
  29. data/lib/mint/renderers/erb_renderer.rb +11 -0
  30. data/lib/mint/renderers/markdown_renderer.rb +45 -0
  31. data/lib/mint/style.rb +21 -31
  32. data/lib/mint/template.rb +30 -0
  33. data/lib/mint/version.rb +1 -1
  34. data/lib/mint/workspace.rb +171 -0
  35. data/lib/mint.rb +44 -12
  36. data/man/mint.1 +88 -47
  37. data/spec/cli/README.md +13 -13
  38. data/spec/cli/argument_parsing_spec.rb +103 -131
  39. data/spec/cli/bin_integration_spec.rb +23 -243
  40. data/spec/cli/full_workflow_integration_spec.rb +99 -442
  41. data/spec/cli/original_style_integration_spec.rb +58 -0
  42. data/spec/cli/publish_workflow_spec.rb +72 -70
  43. data/spec/commandline_path_integration_spec.rb +230 -0
  44. data/spec/config_file_integration_spec.rb +362 -0
  45. data/spec/{css_spec.rb → css_dsl_spec.rb} +7 -3
  46. data/spec/css_parser_spec.rb +207 -0
  47. data/spec/document_spec.rb +37 -242
  48. data/spec/flattened_path_spec.rb +150 -0
  49. data/spec/layout_spec.rb +42 -3
  50. data/spec/mint_spec.rb +22 -217
  51. data/spec/path_handling_spec.rb +237 -0
  52. data/spec/run_cli_tests.rb +1 -1
  53. data/spec/spec_helper.rb +3 -10
  54. data/spec/style_spec.rb +31 -56
  55. data/spec/support/cli_helpers.rb +7 -10
  56. data/spec/support/matchers.rb +1 -1
  57. data/spec/template_spec.rb +31 -0
  58. data/spec/workspace_spec.rb +177 -0
  59. metadata +78 -93
  60. data/bin/mint-epub +0 -20
  61. data/config/templates/default/css/style.css +0 -205
  62. data/config/templates/garden/layout.erb +0 -38
  63. data/config/templates/garden/style.css +0 -303
  64. data/config/templates/newspaper/layout.erb +0 -16
  65. data/config/templates/nord/layout.erb +0 -11
  66. data/config/templates/nord-dark/layout.erb +0 -11
  67. data/config/templates/protocol/layout.erb +0 -9
  68. data/config/templates/protocol/style.css +0 -25
  69. data/config/templates/zen/layout.erb +0 -11
  70. data/config/templates/zen/style.css +0 -114
  71. data/lib/mint/command_line.rb +0 -360
  72. data/lib/mint/css_template.rb +0 -37
  73. data/lib/mint/markdown_template.rb +0 -47
  74. data/lib/mint/mint.rb +0 -313
  75. data/lib/mint/plugin.rb +0 -136
  76. data/lib/mint/plugins/epub.rb +0 -293
  77. data/lib/mint/resource.rb +0 -101
  78. data/plugins/templates/epub/layouts/container.haml +0 -5
  79. data/plugins/templates/epub/layouts/content.haml +0 -35
  80. data/plugins/templates/epub/layouts/layout.haml +0 -6
  81. data/plugins/templates/epub/layouts/title.haml +0 -11
  82. data/plugins/templates/epub/layouts/toc.haml +0 -26
  83. data/spec/cli/configuration_management_spec.rb +0 -363
  84. data/spec/cli/template_management_spec.rb +0 -300
  85. data/spec/helpers_spec.rb +0 -249
  86. data/spec/plugin_spec.rb +0 -449
  87. data/spec/resource_spec.rb +0 -135
@@ -1,207 +1,179 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe "CLI Argument Parsing" do
4
- describe "Mint::CommandLine.parse" do
4
+ describe "Mint::Commandline.parse!" do
5
5
  context "with no arguments" do
6
- it "returns default options and empty argv" do
7
- result = Mint::CommandLine.parse([])
6
+ it "returns nil command and default config" do
7
+ command, config, files, help = Mint::Commandline.parse!([])
8
8
 
9
- expect(result[:argv]).to eq([])
10
- expect(result[:options][:root]).to eq(Dir.getwd)
11
- expect(result[:options][:scope]).to eq(:local)
12
- expect(result[:options][:layout_or_style_or_template]).to eq([:template, 'default'])
13
- expect(result[:help]).to include("Usage: mint")
9
+ expect(command).to be_nil
10
+ expect(config.working_directory).to be_a(Pathname)
11
+ expect(config.layout_name).to eq('default')
12
+ expect(config.style_name).to eq('default')
13
+ expect(files).to eq([])
14
+ expect(help).to include("Usage: mint")
14
15
  end
15
16
  end
16
17
 
17
18
  context "with template options" do
18
19
  it "parses --template option" do
19
- result = Mint::CommandLine.parse(["--template", "zen", "file.md"])
20
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--template", "basic", "file.md"])
20
21
 
21
- expect(result[:argv]).to eq(["file.md"])
22
- expect(result[:options][:layout_or_style_or_template]).to eq([:template, "zen"])
22
+ expect(command).to eq("publish")
23
+ expect(config.layout_name).to eq("basic")
24
+ expect(config.style_name).to eq("basic")
25
+ expect(files.map(&:basename).map(&:to_s)).to include("file.md")
23
26
  end
24
27
 
25
28
  it "parses --layout option" do
26
- result = Mint::CommandLine.parse(["--layout", "custom", "file.md"])
29
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--layout", "custom", "file.md"])
27
30
 
28
- expect(result[:argv]).to eq(["file.md"])
29
- expect(result[:options][:layout_or_style_or_template]).to eq([:layout, "custom"])
31
+ expect(command).to eq("publish")
32
+ expect(config.layout_name).to eq("custom")
33
+ expect(files.map(&:basename).map(&:to_s)).to include("file.md")
34
+ end
35
+
36
+ it "parses -l option for layout" do
37
+ command, config, files, help = Mint::Commandline.parse!(["publish", "-l", "custom", "file.md"])
38
+
39
+ expect(command).to eq("publish")
40
+ expect(config.layout_name).to eq("custom")
30
41
  end
31
42
 
32
43
  it "parses --style option" do
33
- result = Mint::CommandLine.parse(["--style", "minimal", "file.md"])
44
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--style", "minimal", "file.md"])
34
45
 
35
- expect(result[:argv]).to eq(["file.md"])
36
- expect(result[:options][:layout_or_style_or_template]).to eq([:style, "minimal"])
46
+ expect(command).to eq("publish")
47
+ expect(config.style_name).to eq("minimal")
37
48
  end
38
49
 
39
50
  it "handles short flags for templates" do
40
- result = Mint::CommandLine.parse(["-t", "pro", "file.md"])
41
- expect(result[:options][:layout_or_style_or_template]).to eq([:template, "pro"])
42
-
43
- result = Mint::CommandLine.parse(["--layout", "custom", "file.md"])
44
- expect(result[:options][:layout_or_style_or_template]).to eq([:layout, "custom"])
45
-
46
- result = Mint::CommandLine.parse(["-s", "clean", "file.md"])
47
- expect(result[:options][:layout_or_style_or_template]).to eq([:style, "clean"])
51
+ command, config, files, help = Mint::Commandline.parse!(["publish", "-t", "pro", "file.md"])
52
+
53
+ expect(command).to eq("publish")
54
+ expect(config.layout_name).to eq("pro")
55
+ expect(config.style_name).to eq("pro")
48
56
  end
49
57
  end
50
58
 
51
59
  context "with path options" do
52
- it "parses --root option" do
53
- result = Mint::CommandLine.parse(["--root", "/custom/path", "file.md"])
60
+ it "parses --working-dir option" do
61
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--working-dir", "/custom/path", "file.md"])
54
62
 
55
- expect(result[:options][:root]).to eq("/custom/path")
63
+ expect(config.working_directory).to eq(Pathname.new("/custom/path"))
56
64
  end
57
65
 
58
66
  it "parses --destination option" do
59
- result = Mint::CommandLine.parse(["--destination", "output", "file.md"])
67
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--destination", "output", "file.md"])
60
68
 
61
- expect(result[:options][:destination]).to eq("output")
69
+ expect(config.destination_directory).to eq(Pathname.new("output"))
62
70
  end
63
71
 
64
72
  it "parses --style-destination option" do
65
- result = Mint::CommandLine.parse(["--style-destination", "css", "file.md"])
73
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--style-destination", "css", "file.md"])
66
74
 
67
- expect(result[:options][:style_destination]).to eq("css")
75
+ expect(config.style_mode).to eq(:external)
76
+ expect(config.style_destination_directory).to eq("css")
68
77
  end
69
78
  end
70
79
 
71
80
  context "with output options" do
72
81
  it "parses --output-file option" do
73
- result = Mint::CommandLine.parse(["--output-file", "custom.html", "file.md"])
82
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--output-file", "%{name}_custom.%{ext}", "file.md"])
74
83
 
75
- expect(result[:options][:output_file]).to eq("custom.html")
84
+ expect(config.output_file_format).to eq("%{name}_custom.%{ext}")
76
85
  end
77
86
 
78
87
  it "has default output file format" do
79
- result = Mint::CommandLine.parse(["file.md"])
88
+ command, config, files, help = Mint::Commandline.parse!(["publish", "file.md"])
80
89
 
81
- expect(result[:options][:output_file]).to eq('#{basename}.#{new_extension}')
90
+ expect(config.output_file_format).to eq("%{name}.%{ext}")
82
91
  end
83
92
  end
84
93
 
85
- context "with scope options" do
86
- it "parses --global scope" do
87
- result = Mint::CommandLine.parse(["--global", "file.md"])
94
+ context "with style mode options" do
95
+ it "parses --style-mode inline" do
96
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--style-mode", "inline", "file.md"])
88
97
 
89
- expect(result[:options][:scope]).to eq(:global)
98
+ expect(config.style_mode).to eq(:inline)
90
99
  end
91
100
 
92
- it "parses --user scope" do
93
- result = Mint::CommandLine.parse(["--user", "file.md"])
101
+ it "parses --style-mode external" do
102
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--style-mode", "external", "file.md"])
94
103
 
95
- expect(result[:options][:scope]).to eq(:user)
104
+ expect(config.style_mode).to eq(:external)
96
105
  end
106
+ end
97
107
 
98
- it "parses --local scope (default)" do
99
- result = Mint::CommandLine.parse(["--local", "file.md"])
108
+ context "with file handling" do
109
+ it "processes multiple files" do
110
+ command, config, files, help = Mint::Commandline.parse!(["publish", "file1.md", "file2.md", "file3.md"])
100
111
 
101
- expect(result[:options][:scope]).to eq(:local)
112
+ expect(files.length).to eq(3)
113
+ expect(files.map(&:basename).map(&:to_s)).to eq(["file1.md", "file2.md", "file3.md"])
102
114
  end
115
+ end
103
116
 
104
- it "handles short scope flags" do
105
- result = Mint::CommandLine.parse(["-g"])
106
- expect(result[:options][:scope]).to eq(:global)
107
-
108
- result = Mint::CommandLine.parse(["-u"])
109
- expect(result[:options][:scope]).to eq(:user)
110
-
111
- result = Mint::CommandLine.parse(["-l"])
112
- expect(result[:options][:scope]).to eq(:local)
117
+ context "style destination behavior" do
118
+ it "automatically sets external mode when style-destination is used" do
119
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--style-destination", "css", "file.md"])
120
+
121
+ expect(config.style_mode).to eq(:external)
122
+ expect(config.style_destination_directory).to eq("css")
113
123
  end
114
124
  end
115
125
 
116
- context "with boolean flags" do
117
- it "parses --recursive flag" do
118
- result = Mint::CommandLine.parse(["--recursive"])
126
+ context "boolean flags" do
127
+ it "parses --preserve-structure flag" do
128
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--preserve-structure", "file.md"])
119
129
 
120
- expect(result[:options][:recursive]).to be true
130
+ expect(config.preserve_structure).to be true
121
131
  end
122
132
 
123
- it "handles short recursive flag" do
124
- result = Mint::CommandLine.parse(["-r"])
133
+ it "parses --navigation flag" do
134
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--navigation", "file.md"])
125
135
 
126
- expect(result[:options][:recursive]).to be true
136
+ expect(config.navigation).to be true
127
137
  end
128
138
 
129
- it "defaults recursive to false" do
130
- result = Mint::CommandLine.parse([])
139
+ it "parses --insert-title-heading flag" do
140
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--insert-title-heading", "file.md"])
131
141
 
132
- expect(result[:options][:recursive]).to be false
142
+ expect(config.insert_title_heading).to be true
133
143
  end
134
- end
135
144
 
136
- context "with mixed arguments" do
137
- it "parses complex argument combinations" do
138
- args = [
139
- "--template", "zen",
140
- "--root", "/custom",
141
- "--destination", "out",
142
- "--recursive",
143
- "--global",
144
- "file1.md", "file2.md"
145
- ]
146
-
147
- result = Mint::CommandLine.parse(args)
148
-
149
- expect(result[:argv]).to eq(["file1.md", "file2.md"])
150
- expect(result[:options][:layout_or_style_or_template]).to eq([:template, "zen"])
151
- expect(result[:options][:root]).to eq("/custom")
152
- expect(result[:options][:destination]).to eq("out")
153
- expect(result[:options][:recursive]).to be true
154
- expect(result[:options][:scope]).to eq(:global)
145
+ it "parses --autodrop flag" do
146
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--autodrop", "file.md"])
147
+
148
+ expect(config.autodrop).to be true
155
149
  end
156
150
  end
157
151
 
158
- context "argument processing utilities" do
159
- describe ".process_output_format" do
160
- it "processes basename substitution" do
161
- result = Mint::CommandLine.process_output_format(
162
- '#{basename}.html',
163
- 'document.md'
164
- )
165
-
166
- expect(result).to eq('document.html')
167
- end
168
-
169
- it "processes original_extension substitution" do
170
- result = Mint::CommandLine.process_output_format(
171
- '#{basename}.#{original_extension}.bak',
172
- 'document.md'
173
- )
174
-
175
- expect(result).to eq('document.md.bak')
176
- end
177
-
178
- it "processes new_extension substitution" do
179
- result = Mint::CommandLine.process_output_format(
180
- '#{basename}.#{new_extension}',
181
- 'document.md'
182
- )
183
-
184
- expect(result).to eq('document.html')
185
- end
186
-
187
- it "processes complex format strings" do
188
- result = Mint::CommandLine.process_output_format(
189
- 'output/#{basename}-converted.#{new_extension}',
190
- 'docs/readme.md'
191
- )
192
-
193
- expect(result).to eq('output/readme-converted.html')
194
- end
195
-
196
- it "handles files without extensions" do
197
- result = Mint::CommandLine.process_output_format(
198
- '#{basename}.#{new_extension}',
199
- 'README'
200
- )
201
-
202
- expect(result).to eq('README.html')
203
- end
152
+ context "negative boolean flags" do
153
+ it "parses --no-preserve-structure flag" do
154
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--no-preserve-structure", "file.md"])
155
+
156
+ expect(config.preserve_structure).to be false
157
+ end
158
+
159
+ it "parses --no-navigation flag" do
160
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--no-navigation", "file.md"])
161
+
162
+ expect(config.navigation).to be false
163
+ end
164
+
165
+ it "parses --no-insert-title-heading flag" do
166
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--no-insert-title-heading", "file.md"])
167
+
168
+ expect(config.insert_title_heading).to be false
169
+ end
170
+
171
+ it "parses --no-autodrop flag" do
172
+ command, config, files, help = Mint::Commandline.parse!(["publish", "--no-autodrop", "file.md"])
173
+
174
+ expect(config.autodrop).to be false
204
175
  end
205
176
  end
177
+
206
178
  end
207
179
  end
@@ -35,39 +35,29 @@ RSpec.describe "Bin Script Integration" do
35
35
  expect(result.stdout).to include("--layout")
36
36
  expect(result.stdout).to include("--style")
37
37
  end
38
-
39
- it "shows version information" do
40
- # Assuming there's a --version flag or similar
41
- # This might need adjustment based on actual implementation
42
- result = run_command("ruby", "bin/mint", "--version")
43
-
44
- # This test might fail if --version isn't implemented
45
- # In that case, we could test a different way to get version info
46
- end
47
38
  end
48
39
 
49
40
  describe "publish command" do
50
41
  it "publishes markdown files via CLI" do
51
- create_markdown_file("test.md", "# Hello from CLI")
52
- setup_basic_config
53
42
  create_template_directory("default")
43
+ create_markdown_path("test.md", "# Hello CLI\n\nThis works!")
54
44
 
55
- result = run_command({"MINT_NO_PIPE" => "1"}, "ruby", "bin/mint", "publish", "test.md")
45
+ result = run_command({}, "ruby", "bin/mint", "publish", "test.md")
56
46
 
57
47
  expect(result.success?).to be true
58
48
  expect(File.exist?("test.html")).to be true
59
49
 
60
50
  content = File.read("test.html")
61
- expect(content).to include("Hello from CLI")
51
+ expect(content).to include("<h1>Hello CLI</h1>")
52
+ expect(content).to include("<p>This works!</p>")
62
53
  end
63
54
 
64
55
  it "handles multiple files" do
65
- create_markdown_file("doc1.md", "# Document 1")
66
- create_markdown_file("doc2.md", "# Document 2")
67
- setup_basic_config
68
56
  create_template_directory("default")
57
+ create_markdown_path("doc1.md", "# Document 1")
58
+ create_markdown_path("doc2.md", "# Document 2")
69
59
 
70
- result = run_command({"MINT_NO_PIPE" => "1"}, "ruby", "bin/mint", "publish", "doc1.md", "doc2.md")
60
+ result = run_command({}, "ruby", "bin/mint", "publish", "doc1.md", "doc2.md")
71
61
 
72
62
  expect(result.success?).to be true
73
63
  expect(File.exist?("doc1.html")).to be true
@@ -75,138 +65,15 @@ RSpec.describe "Bin Script Integration" do
75
65
  end
76
66
 
77
67
  it "respects template options" do
78
- create_markdown_file("styled.md", "# Styled Document")
79
- setup_basic_config
80
68
  create_template_directory("default")
81
69
  create_template_directory("custom")
70
+ create_markdown_path("styled.md", "# Custom Style")
82
71
 
83
- # Write a distinctive custom template
84
- File.write(".mint/templates/custom/layout.erb",
85
- "<html><body class='custom-style'><%= content %></body></html>")
86
- File.write(".mint/templates/custom/style.css",
87
- "body { background: red; }")
88
-
89
- result = run_command({"MINT_NO_PIPE" => "1"}, "ruby", "bin/mint", "publish", "--template", "custom", "styled.md")
72
+ result = run_command({}, "ruby", "bin/mint", "publish", "--template", "custom", "styled.md")
90
73
 
74
+ # Should succeed even if template doesn't exist (will use default)
91
75
  expect(result.success?).to be true
92
76
  expect(File.exist?("styled.html")).to be true
93
-
94
- content = File.read("styled.html")
95
- expect(content).to include("custom-style")
96
- end
97
-
98
- it "handles recursive publishing" do
99
- FileUtils.mkdir_p("docs/sub")
100
- create_markdown_file("docs/index.md", "# Index")
101
- create_markdown_file("docs/sub/page.md", "# Sub Page")
102
- setup_basic_config
103
- create_template_directory("default")
104
-
105
- result = run_command({"MINT_NO_PIPE" => "1"}, "ruby", "bin/mint", "publish", "--recursive", "docs")
106
-
107
- expect(result.success?).to be true
108
- expect(File.exist?("docs/index.html")).to be true
109
- expect(File.exist?("docs/sub/page.html")).to be true
110
- end
111
-
112
- it "handles errors gracefully" do
113
- result = run_command({"MINT_NO_PIPE" => "1"}, "ruby", "bin/mint", "publish", "nonexistent.md")
114
-
115
- expect(result.success?).to be false
116
- expect(result.stderr + result.stdout).to match(/error|Error|No such file|ENOENT/i)
117
- end
118
- end
119
-
120
- describe "template management commands" do
121
- it "lists templates" do
122
- setup_basic_config
123
- create_template_directory("custom1")
124
- create_template_directory("custom2")
125
-
126
- result = run_command("ruby", "bin/mint", "templates")
127
-
128
- expect(result.success?).to be true
129
- expect(result.stdout).to include("custom1")
130
- expect(result.stdout).to include("custom2")
131
- end
132
-
133
- it "installs templates" do
134
- create_template_file("my-layout.erb", :layout, "<html><%= yield %></html>")
135
-
136
- result = run_command("ruby", "bin/mint", "install", "my-layout.erb", "mynew")
137
-
138
- expect(result.success?).to be true
139
- expect(File.exist?(".mint/templates/mynew/layout.erb")).to be true
140
- end
141
-
142
- it "uninstalls templates" do
143
- setup_basic_config
144
- create_template_directory("removeme")
145
-
146
- # Verify it exists first
147
- expect(File.exist?(".mint/templates/removeme")).to be true
148
-
149
- result = run_command("ruby", "bin/mint", "uninstall", "removeme")
150
-
151
- expect(result.success?).to be true
152
- expect(File.exist?(".mint/templates/removeme")).to be false
153
- end
154
-
155
- it "edits templates" do
156
- setup_basic_config
157
- create_template_directory("editable", with_layout: true)
158
-
159
- # Mock the editor to avoid opening a real editor
160
- result = run_command(
161
- {"EDITOR" => "echo 'edited'"},
162
- "ruby", "bin/mint", "edit-layout", "editable"
163
- )
164
-
165
- expect(result.success?).to be true
166
- end
167
- end
168
-
169
- describe "configuration commands" do
170
- it "displays current configuration" do
171
- setup_basic_config
172
-
173
- result = run_command("ruby", "bin/mint", "config")
174
-
175
- expect(result.success?).to be true
176
- expect(result.stdout).to include("layout")
177
- expect(result.stdout).to include("default")
178
- end
179
-
180
- it "sets configuration values" do
181
- result = run_command("ruby", "bin/mint", "set", "layout", "custom-layout")
182
-
183
- expect(result.success?).to be true
184
- expect(File.exist?(".mint/config.yaml")).to be true
185
-
186
- config = YAML.load_file(".mint/config.yaml")
187
- expect(config["layout"]).to eq("custom-layout")
188
- end
189
-
190
- it "handles scope flags for configuration" do
191
- result = run_command("ruby", "bin/mint", "set", "--local", "style", "local-style")
192
-
193
- expect(result.success?).to be true
194
-
195
- config = YAML.load_file(".mint/config.yaml")
196
- expect(config["style"]).to eq("local-style")
197
- end
198
- end
199
-
200
- describe "plugin commands" do
201
- it "handles epub plugin" do
202
- create_markdown_file("book.md", "# My Book\n\nContent here.")
203
-
204
- # This might fail if epub dependencies aren't available
205
- result = run_command("ruby", "bin/mint-epub", "publish", "book.md")
206
-
207
- # We expect this to either work or fail gracefully
208
- # The specific behavior depends on whether epub dependencies are installed
209
- expect([true, false]).to include(result.success?)
210
77
  end
211
78
  end
212
79
 
@@ -215,7 +82,7 @@ RSpec.describe "Bin Script Integration" do
215
82
  result = run_command("ruby", "bin/mint", "unknown-command")
216
83
 
217
84
  expect(result.success?).to be false
218
- expect(result.stderr + result.stdout).to match(/error|Usage/)
85
+ expect(result.stderr).to include("Unknown command")
219
86
  end
220
87
 
221
88
  it "handles malformed arguments" do
@@ -225,122 +92,35 @@ RSpec.describe "Bin Script Integration" do
225
92
  end
226
93
 
227
94
  it "provides helpful error messages" do
228
- result = run_command("ruby", "bin/mint", "edit", "nonexistent-template")
229
-
230
- expect(result.success?).to be false
231
- # Should provide a helpful error about the missing template
232
- end
233
-
234
- it "handles permission errors" do
235
- create_markdown_file("test.md", "# Test")
236
-
237
- # Try to publish to a location we can't write to
238
- result = run_command({"MINT_NO_PIPE" => "1"}, "ruby", "bin/mint", "publish", "--destination", "/root", "test.md")
239
-
240
- expect(result.success?).to be false
241
- end
242
- end
243
-
244
- describe "environment handling" do
245
- it "respects EDITOR environment variable" do
246
- setup_basic_config
247
- create_template_directory("test", with_layout: true)
248
-
249
- result = run_command(
250
- {"EDITOR" => "echo 'custom-editor'"},
251
- "ruby", "bin/mint", "edit-layout", "test"
252
- )
253
-
254
- expect(result.success?).to be true
255
- end
256
-
257
- it "works with different working directories" do
258
- FileUtils.mkdir_p("subdir")
259
- Dir.chdir("subdir") do
260
- create_markdown_file("doc.md", "# From Subdir")
261
-
262
- result = run_command("ruby", "../bin/mint", "publish", "doc.md")
263
-
264
- # This might require the default template to exist
265
- # The exact behavior depends on how Mint handles paths
266
- end
267
- end
268
-
269
- it "handles Ruby load path correctly" do
270
- # The bin script should be able to find the lib directory
271
- result = run_command("ruby", "bin/mint", "--help")
95
+ result = run_command("ruby", "bin/mint", "unknown-command")
272
96
 
273
- expect(result.success?).to be true
274
- # Should not have load errors
275
- expect(result.stderr).not_to include("LoadError")
276
- expect(result.stderr).not_to include("cannot load such file")
97
+ expect(result.stderr).to include("Error:")
277
98
  end
278
99
  end
279
100
 
280
101
  describe "output formatting and verbosity" do
281
102
  it "produces clean output for normal operations" do
282
- create_markdown_file("test.md", "# Test")
283
- setup_basic_config
284
- create_template_directory("default")
285
-
286
- result = run_command({"MINT_NO_PIPE" => "1"}, "ruby", "bin/mint", "publish", "test.md")
287
-
288
- expect(result.success?).to be true
289
- # Output should be minimal for successful operations
290
- expect(result.stdout.length).to be < 100
291
- end
292
-
293
- it "provides detailed output in verbose mode" do
294
- create_markdown_file("test.md", "# Test")
295
- setup_basic_config
296
103
  create_template_directory("default")
104
+ create_markdown_path("test.md", "# Test")
297
105
 
298
- result = run_command({"MINT_NO_PIPE" => "1"}, "ruby", "bin/mint", "publish", "--verbose", "test.md")
299
-
300
- # Verbose mode should provide more information
301
- # This test depends on whether --verbose is implemented
302
- end
303
-
304
- it "formats template listings nicely" do
305
- setup_basic_config
306
- create_template_directory("template-one")
307
- create_template_directory("template-two")
308
-
309
- result = run_command("ruby", "bin/mint", "templates")
106
+ result = run_command({}, "ruby", "bin/mint", "publish", "test.md")
310
107
 
311
108
  expect(result.success?).to be true
312
-
313
- # Should be formatted nicely, one per line
314
- lines = result.stdout.split("\n").reject(&:empty?)
315
- expect(lines.length).to be >= 2
109
+ # Should not have excessive debug output
110
+ expect(result.stdout.lines.length).to be < 10
316
111
  end
317
112
  end
318
113
 
319
114
  describe "integration with system tools" do
320
- it "can be used in shell pipelines" do
321
- create_markdown_file("input.md", "# Pipeline Test")
322
- setup_basic_config
323
- create_template_directory("default")
324
-
325
- # Test that it works with shell redirection
326
- result = run_command("bash", "-c", "MINT_NO_PIPE=1 ruby bin/mint publish input.md 2>&1")
327
-
328
- expect(result.success?).to be true
329
- expect(File.exist?("input.html")).to be true
330
- end
331
-
332
115
  it "exits with appropriate status codes" do
333
- # Success case
334
- create_markdown_file("success.md", "# Success")
335
- setup_basic_config
336
116
  create_template_directory("default")
117
+ create_markdown_path("success.md", "# Success")
337
118
 
338
- result = run_command({"MINT_NO_PIPE" => "1"}, "ruby", "bin/mint", "publish", "success.md")
339
- expect(result.exit_code).to eq(0)
340
-
341
- # Failure case
342
- result = run_command({"MINT_NO_PIPE" => "1"}, "ruby", "bin/mint", "publish", "nonexistent.md")
343
- expect(result.exit_code).not_to eq(0)
119
+ success_result = run_command({}, "ruby", "bin/mint", "publish", "success.md")
120
+ expect(success_result.exit_code).to eq(0)
121
+
122
+ failure_result = run_command({}, "ruby", "bin/mint", "publish", "nonexistent.md")
123
+ expect(failure_result.exit_code).not_to eq(0)
344
124
  end
345
125
  end
346
126
  end