mint 0.8.1 → 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.
- checksums.yaml +4 -4
- data/Gemfile +1 -26
- data/README.md +117 -37
- data/bin/mint +2 -81
- data/config/templates/base/navigation.css +136 -0
- data/config/templates/base/print.css +152 -0
- data/config/templates/{reset.css → base/reset.css} +1 -1
- data/config/templates/base/style.css +117 -137
- data/config/templates/base/utilities.css +136 -0
- data/config/templates/base/variables.css +124 -0
- data/config/templates/basic/style.css +151 -0
- data/config/templates/default/layout.erb +33 -3
- data/config/templates/default/style.css +95 -164
- data/config/templates/magazine/style.css +383 -0
- data/config/templates/nord/style.css +105 -220
- data/config/templates/nord-dark/style.css +82 -263
- data/lib/mint/commandline/parse.rb +144 -0
- data/lib/mint/commandline/publish.rb +46 -0
- data/lib/mint/commandline/run.rb +30 -0
- data/lib/mint/config.rb +162 -0
- data/lib/mint/{css.rb → css_dsl.rb} +9 -9
- data/lib/mint/css_parser.rb +45 -25
- data/lib/mint/document.rb +250 -365
- data/lib/mint/document_tree.rb +163 -0
- data/lib/mint/exceptions.rb +2 -3
- data/lib/mint/helpers.rb +23 -180
- data/lib/mint/layout.rb +26 -9
- data/lib/mint/renderers/css_renderer.rb +32 -0
- data/lib/mint/renderers/erb_renderer.rb +11 -0
- data/lib/mint/renderers/markdown_renderer.rb +45 -0
- data/lib/mint/style.rb +21 -31
- data/lib/mint/template.rb +30 -0
- data/lib/mint/version.rb +1 -1
- data/lib/mint/workspace.rb +171 -0
- data/lib/mint.rb +44 -12
- data/man/mint.1 +85 -44
- data/spec/cli/README.md +2 -2
- data/spec/cli/argument_parsing_spec.rb +89 -147
- data/spec/cli/bin_integration_spec.rb +23 -243
- data/spec/cli/full_workflow_integration_spec.rb +99 -442
- data/spec/cli/original_style_integration_spec.rb +58 -0
- data/spec/cli/publish_workflow_spec.rb +72 -70
- data/spec/commandline_path_integration_spec.rb +230 -0
- data/spec/config_file_integration_spec.rb +362 -0
- data/spec/{css_spec.rb → css_dsl_spec.rb} +7 -3
- data/spec/css_parser_spec.rb +59 -1
- data/spec/document_spec.rb +37 -242
- data/spec/flattened_path_spec.rb +150 -0
- data/spec/layout_spec.rb +42 -3
- data/spec/mint_spec.rb +22 -217
- data/spec/path_handling_spec.rb +237 -0
- data/spec/run_cli_tests.rb +1 -1
- data/spec/spec_helper.rb +3 -10
- data/spec/style_spec.rb +31 -56
- data/spec/support/cli_helpers.rb +7 -10
- data/spec/support/matchers.rb +1 -1
- data/spec/template_spec.rb +31 -0
- data/spec/workspace_spec.rb +177 -0
- metadata +75 -89
- data/bin/mint-epub +0 -20
- data/config/templates/garden/layout.erb +0 -38
- data/config/templates/garden/style.css +0 -303
- data/config/templates/nord/layout.erb +0 -11
- data/config/templates/nord-dark/layout.erb +0 -11
- data/config/templates/zen/layout.erb +0 -11
- data/config/templates/zen/style.css +0 -114
- data/lib/mint/command_line.rb +0 -360
- data/lib/mint/css_template.rb +0 -37
- data/lib/mint/markdown_template.rb +0 -47
- data/lib/mint/mint.rb +0 -313
- data/lib/mint/plugin.rb +0 -136
- data/lib/mint/plugins/epub.rb +0 -293
- data/lib/mint/resource.rb +0 -101
- data/plugins/templates/epub/layouts/container.haml +0 -5
- data/plugins/templates/epub/layouts/content.haml +0 -35
- data/plugins/templates/epub/layouts/layout.haml +0 -6
- data/plugins/templates/epub/layouts/title.haml +0 -11
- data/plugins/templates/epub/layouts/toc.haml +0 -26
- data/spec/cli/configuration_management_spec.rb +0 -363
- data/spec/cli/template_management_spec.rb +0 -300
- data/spec/helpers_spec.rb +0 -249
- data/spec/plugin_spec.rb +0 -449
- data/spec/resource_spec.rb +0 -135
@@ -1,237 +1,179 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "CLI Argument Parsing" do
|
4
|
-
describe "Mint::
|
4
|
+
describe "Mint::Commandline.parse!" do
|
5
5
|
context "with no arguments" do
|
6
|
-
it "returns
|
7
|
-
|
6
|
+
it "returns nil command and default config" do
|
7
|
+
command, config, files, help = Mint::Commandline.parse!([])
|
8
8
|
|
9
|
-
expect(
|
10
|
-
expect(
|
11
|
-
expect(
|
12
|
-
expect(
|
13
|
-
expect(
|
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
|
-
|
20
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--template", "basic", "file.md"])
|
20
21
|
|
21
|
-
expect(
|
22
|
-
expect(
|
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
|
-
|
29
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--layout", "custom", "file.md"])
|
27
30
|
|
28
|
-
expect(
|
29
|
-
expect(
|
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")
|
30
34
|
end
|
31
35
|
|
32
36
|
it "parses -l option for layout" do
|
33
|
-
|
37
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "-l", "custom", "file.md"])
|
34
38
|
|
35
|
-
expect(
|
36
|
-
expect(
|
39
|
+
expect(command).to eq("publish")
|
40
|
+
expect(config.layout_name).to eq("custom")
|
37
41
|
end
|
38
42
|
|
39
43
|
it "parses --style option" do
|
40
|
-
|
44
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--style", "minimal", "file.md"])
|
41
45
|
|
42
|
-
expect(
|
43
|
-
expect(
|
46
|
+
expect(command).to eq("publish")
|
47
|
+
expect(config.style_name).to eq("minimal")
|
44
48
|
end
|
45
49
|
|
46
50
|
it "handles short flags for templates" do
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
expect(
|
52
|
-
|
53
|
-
result = Mint::CommandLine.parse(["-s", "clean", "file.md"])
|
54
|
-
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")
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
58
59
|
context "with path options" do
|
59
|
-
it "parses --
|
60
|
-
|
60
|
+
it "parses --working-dir option" do
|
61
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--working-dir", "/custom/path", "file.md"])
|
61
62
|
|
62
|
-
expect(
|
63
|
+
expect(config.working_directory).to eq(Pathname.new("/custom/path"))
|
63
64
|
end
|
64
65
|
|
65
66
|
it "parses --destination option" do
|
66
|
-
|
67
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--destination", "output", "file.md"])
|
67
68
|
|
68
|
-
expect(
|
69
|
+
expect(config.destination_directory).to eq(Pathname.new("output"))
|
69
70
|
end
|
70
71
|
|
71
72
|
it "parses --style-destination option" do
|
72
|
-
|
73
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--style-destination", "css", "file.md"])
|
73
74
|
|
74
|
-
expect(
|
75
|
+
expect(config.style_mode).to eq(:external)
|
76
|
+
expect(config.style_destination_directory).to eq("css")
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
78
80
|
context "with output options" do
|
79
81
|
it "parses --output-file option" do
|
80
|
-
|
82
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--output-file", "%{name}_custom.%{ext}", "file.md"])
|
81
83
|
|
82
|
-
expect(
|
84
|
+
expect(config.output_file_format).to eq("%{name}_custom.%{ext}")
|
83
85
|
end
|
84
86
|
|
85
87
|
it "has default output file format" do
|
86
|
-
|
88
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "file.md"])
|
87
89
|
|
88
|
-
expect(
|
90
|
+
expect(config.output_file_format).to eq("%{name}.%{ext}")
|
89
91
|
end
|
90
92
|
end
|
91
93
|
|
92
|
-
context "with
|
93
|
-
it "parses --
|
94
|
-
|
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"])
|
95
97
|
|
96
|
-
expect(
|
98
|
+
expect(config.style_mode).to eq(:inline)
|
97
99
|
end
|
98
100
|
|
99
|
-
it "parses --
|
100
|
-
|
101
|
+
it "parses --style-mode external" do
|
102
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--style-mode", "external", "file.md"])
|
101
103
|
|
102
|
-
expect(
|
104
|
+
expect(config.style_mode).to eq(:external)
|
103
105
|
end
|
106
|
+
end
|
104
107
|
|
105
|
-
|
106
|
-
|
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"])
|
107
111
|
|
108
|
-
expect(
|
109
|
-
|
110
|
-
|
111
|
-
it "handles short scope flags" do
|
112
|
-
result = Mint::CommandLine.parse(["-g"])
|
113
|
-
expect(result[:options][:scope]).to eq(:global)
|
114
|
-
|
115
|
-
result = Mint::CommandLine.parse(["-u"])
|
116
|
-
expect(result[:options][:scope]).to eq(:user)
|
112
|
+
expect(files.length).to eq(3)
|
113
|
+
expect(files.map(&:basename).map(&:to_s)).to eq(["file1.md", "file2.md", "file3.md"])
|
117
114
|
end
|
118
115
|
end
|
119
116
|
|
120
|
-
context "
|
121
|
-
it "
|
122
|
-
|
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"])
|
123
120
|
|
124
|
-
expect(
|
121
|
+
expect(config.style_mode).to eq(:external)
|
122
|
+
expect(config.style_destination_directory).to eq("css")
|
125
123
|
end
|
124
|
+
end
|
126
125
|
|
127
|
-
|
128
|
-
|
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"])
|
129
129
|
|
130
|
-
expect(
|
130
|
+
expect(config.preserve_structure).to be true
|
131
131
|
end
|
132
132
|
|
133
|
-
it "
|
134
|
-
|
133
|
+
it "parses --navigation flag" do
|
134
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--navigation", "file.md"])
|
135
135
|
|
136
|
-
expect(
|
136
|
+
expect(config.navigation).to be true
|
137
137
|
end
|
138
|
-
end
|
139
138
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
"--root", "/custom",
|
145
|
-
"--destination", "out",
|
146
|
-
"--recursive",
|
147
|
-
"--global",
|
148
|
-
"file1.md", "file2.md"
|
149
|
-
]
|
150
|
-
|
151
|
-
result = Mint::CommandLine.parse(args)
|
152
|
-
|
153
|
-
expect(result[:argv]).to eq(["file1.md", "file2.md"])
|
154
|
-
expect(result[:options][:layout_or_style_or_template]).to eq([:template, "zen"])
|
155
|
-
expect(result[:options][:root]).to eq("/custom")
|
156
|
-
expect(result[:options][:destination]).to eq("out")
|
157
|
-
expect(result[:options][:recursive]).to be true
|
158
|
-
expect(result[:options][:scope]).to eq(:global)
|
139
|
+
it "parses --insert-title-heading flag" do
|
140
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--insert-title-heading", "file.md"])
|
141
|
+
|
142
|
+
expect(config.insert_title_heading).to be true
|
159
143
|
end
|
160
|
-
end
|
161
144
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
'#{basename}.html',
|
167
|
-
'document.md'
|
168
|
-
)
|
169
|
-
|
170
|
-
expect(result).to eq('document.html')
|
171
|
-
end
|
172
|
-
|
173
|
-
it "processes original_extension substitution" do
|
174
|
-
result = Mint::CommandLine.process_output_format(
|
175
|
-
'#{basename}.#{original_extension}.bak',
|
176
|
-
'document.md'
|
177
|
-
)
|
178
|
-
|
179
|
-
expect(result).to eq('document.md.bak')
|
180
|
-
end
|
181
|
-
|
182
|
-
it "processes new_extension substitution" do
|
183
|
-
result = Mint::CommandLine.process_output_format(
|
184
|
-
'#{basename}.#{new_extension}',
|
185
|
-
'document.md'
|
186
|
-
)
|
187
|
-
|
188
|
-
expect(result).to eq('document.html')
|
189
|
-
end
|
190
|
-
|
191
|
-
it "processes complex format strings" do
|
192
|
-
result = Mint::CommandLine.process_output_format(
|
193
|
-
'output/#{basename}-converted.#{new_extension}',
|
194
|
-
'docs/readme.md'
|
195
|
-
)
|
196
|
-
|
197
|
-
expect(result).to eq('output/readme-converted.html')
|
198
|
-
end
|
199
|
-
|
200
|
-
it "handles files without extensions" do
|
201
|
-
result = Mint::CommandLine.process_output_format(
|
202
|
-
'#{basename}.#{new_extension}',
|
203
|
-
'README'
|
204
|
-
)
|
205
|
-
|
206
|
-
expect(result).to eq('README.html')
|
207
|
-
end
|
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
|
208
149
|
end
|
209
150
|
end
|
210
151
|
|
211
|
-
context "
|
212
|
-
it "parses --
|
213
|
-
|
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"])
|
214
155
|
|
215
|
-
expect(
|
156
|
+
expect(config.preserve_structure).to be false
|
216
157
|
end
|
217
158
|
|
218
|
-
it "parses --
|
219
|
-
|
159
|
+
it "parses --no-navigation flag" do
|
160
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--no-navigation", "file.md"])
|
220
161
|
|
221
|
-
expect(
|
162
|
+
expect(config.navigation).to be false
|
222
163
|
end
|
223
164
|
|
224
|
-
it "parses --
|
225
|
-
|
165
|
+
it "parses --no-insert-title-heading flag" do
|
166
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--no-insert-title-heading", "file.md"])
|
226
167
|
|
227
|
-
expect(
|
168
|
+
expect(config.insert_title_heading).to be false
|
228
169
|
end
|
229
170
|
|
230
|
-
it "
|
231
|
-
|
171
|
+
it "parses --no-autodrop flag" do
|
172
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--no-autodrop", "file.md"])
|
232
173
|
|
233
|
-
expect(
|
174
|
+
expect(config.autodrop).to be false
|
234
175
|
end
|
235
176
|
end
|
177
|
+
|
236
178
|
end
|
237
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({
|
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
|
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({
|
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
|
-
|
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
|
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", "
|
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.
|
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({
|
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
|
-
|
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
|
-
|
339
|
-
expect(
|
340
|
-
|
341
|
-
|
342
|
-
|
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
|