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.
- checksums.yaml +7 -0
- data/Gemfile +23 -14
- data/LICENSE +22 -0
- data/README.md +68 -79
- data/bin/mint +47 -10
- data/bin/mint-epub +1 -4
- data/config/templates/base/style.css +187 -0
- data/config/templates/default/layout.erb +10 -0
- data/config/templates/default/style.css +237 -0
- data/config/templates/garden/layout.erb +38 -0
- data/config/templates/garden/style.css +303 -0
- data/config/templates/nord/layout.erb +11 -0
- data/config/templates/nord/style.css +339 -0
- data/config/templates/nord-dark/layout.erb +11 -0
- data/config/templates/nord-dark/style.css +339 -0
- data/config/templates/zen/layout.erb +11 -0
- data/config/templates/zen/style.css +114 -0
- data/lib/mint/command_line.rb +253 -111
- data/lib/mint/css.rb +11 -4
- data/lib/mint/css_parser.rb +76 -0
- data/lib/mint/css_template.rb +37 -0
- data/lib/mint/document.rb +203 -43
- data/lib/mint/helpers.rb +50 -10
- data/lib/mint/layout.rb +2 -3
- data/lib/mint/markdown_template.rb +47 -0
- data/lib/mint/mint.rb +181 -114
- data/lib/mint/plugin.rb +3 -3
- data/lib/mint/plugins/epub.rb +1 -2
- data/lib/mint/resource.rb +19 -9
- data/lib/mint/style.rb +10 -14
- data/lib/mint/version.rb +1 -1
- data/lib/mint.rb +1 -0
- data/man/mint.1 +135 -0
- data/spec/cli/README.md +99 -0
- data/spec/cli/argument_parsing_spec.rb +237 -0
- data/spec/cli/bin_integration_spec.rb +348 -0
- data/spec/cli/configuration_management_spec.rb +363 -0
- data/spec/cli/full_workflow_integration_spec.rb +527 -0
- data/spec/cli/publish_workflow_spec.rb +368 -0
- data/spec/cli/template_management_spec.rb +300 -0
- data/spec/css_parser_spec.rb +149 -0
- data/spec/css_spec.rb +1 -1
- data/spec/document_spec.rb +102 -69
- data/spec/helpers_spec.rb +42 -42
- data/spec/mint_spec.rb +104 -80
- data/spec/plugin_spec.rb +141 -143
- data/spec/run_cli_tests.rb +95 -0
- data/spec/spec_helper.rb +8 -1
- data/spec/style_spec.rb +18 -16
- data/spec/support/cli_helpers.rb +169 -0
- data/spec/support/fixtures/content-2.md +16 -0
- data/spec/support/matchers.rb +1 -1
- metadata +116 -224
- data/config/syntax.yaml +0 -71
- data/config/templates/base/style.sass +0 -144
- data/config/templates/default/css/style.css +0 -158
- data/config/templates/default/layout.haml +0 -8
- data/config/templates/default/style.sass +0 -36
- data/config/templates/protocol/layout.haml +0 -7
- data/config/templates/protocol/style.sass +0 -20
- data/config/templates/zen/css/style.css +0 -145
- data/config/templates/zen/layout.haml +0 -7
- data/config/templates/zen/style.sass +0 -24
- data/features/config.feature +0 -21
- data/features/plugins/epub.feature +0 -23
- data/features/publish.feature +0 -73
- data/features/support/env.rb +0 -15
- data/features/templates.feature +0 -79
- data/spec/command_line_spec.rb +0 -87
- data/spec/plugins/epub_spec.rb +0 -242
data/spec/helpers_spec.rb
CHANGED
@@ -4,63 +4,63 @@ module Mint
|
|
4
4
|
describe Helpers do
|
5
5
|
describe ".underscore" do
|
6
6
|
it "underscores class names per ActiveSupport conventions" do
|
7
|
-
Helpers.underscore("ClassName").
|
7
|
+
expect(Helpers.underscore("ClassName")).to eq("class_name")
|
8
8
|
end
|
9
9
|
|
10
10
|
it "allows for camel case prefixes" do
|
11
|
-
Helpers.underscore("EPub").
|
12
|
-
Helpers.underscore("EPub", :ignore_prefix => true).
|
11
|
+
expect(Helpers.underscore("EPub")).to eq("e_pub")
|
12
|
+
expect(Helpers.underscore("EPub", :ignore_prefix => true)).to eq("epub")
|
13
13
|
end
|
14
14
|
|
15
15
|
it "allows for namespace removal" do
|
16
|
-
Helpers.underscore("Mint::EPub",
|
17
|
-
:namespaces => true).
|
18
|
-
Helpers.underscore("Mint::EPub",
|
19
|
-
:namespaces => false).
|
20
|
-
Helpers.underscore("Mint::EPub",
|
16
|
+
expect(Helpers.underscore("Mint::EPub",
|
17
|
+
:namespaces => true)).to eq("mint/e_pub")
|
18
|
+
expect(Helpers.underscore("Mint::EPub",
|
19
|
+
:namespaces => false)).to eq("e_pub")
|
20
|
+
expect(Helpers.underscore("Mint::EPub",
|
21
21
|
:namespaces => true,
|
22
|
-
:ignore_prefix => true).
|
22
|
+
:ignore_prefix => true)).to eq("mint/epub")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe ".slugize" do
|
27
27
|
it "downcases everything" do
|
28
|
-
Helpers.slugize("This could use FEWER CAPITALS").
|
29
|
-
"this-could-use-fewer-capitals"
|
28
|
+
expect(Helpers.slugize("This could use FEWER CAPITALS")).to eq(
|
29
|
+
"this-could-use-fewer-capitals")
|
30
30
|
end
|
31
31
|
|
32
32
|
it "parses 'and'" do
|
33
|
-
Helpers.slugize("You & me").
|
33
|
+
expect(Helpers.slugize("You & me")).to eq("you-and-me")
|
34
34
|
end
|
35
35
|
|
36
36
|
it "parses spaces" do
|
37
|
-
Helpers.slugize("You and me").
|
37
|
+
expect(Helpers.slugize("You and me")).to eq("you-and-me")
|
38
38
|
end
|
39
39
|
|
40
40
|
it "removes non-word/non-digits" do
|
41
|
-
Helpers.slugize("You // and :: me").
|
41
|
+
expect(Helpers.slugize("You // and :: me")).to eq("you-and-me")
|
42
42
|
end
|
43
43
|
|
44
44
|
it "condenses multiple hyphens" do
|
45
|
-
Helpers.slugize("You-----and me").
|
45
|
+
expect(Helpers.slugize("You-----and me")).to eq("you-and-me")
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
describe ".symbolize" do
|
50
50
|
it "converts hyphens to underscores" do
|
51
|
-
Helpers.symbolize("you-and-me").
|
51
|
+
expect(Helpers.symbolize("you-and-me")).to eq(:you_and_me)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
describe ".pathize" do
|
56
56
|
it "converts a String to a Pathname" do
|
57
|
-
Helpers.pathize("filename.md").
|
58
|
-
Pathname.new("filename.md").expand_path
|
57
|
+
expect(Helpers.pathize("filename.md")).to eq(
|
58
|
+
Pathname.new("filename.md").expand_path)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "does not convert a Pathname" do
|
62
62
|
pathname = Pathname.new("filename.md")
|
63
|
-
Helpers.pathize(pathname).
|
63
|
+
expect(Helpers.pathize(pathname)).to eq(pathname.expand_path)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -78,7 +78,7 @@ module Mint
|
|
78
78
|
key3: "value3"
|
79
79
|
}
|
80
80
|
|
81
|
-
Helpers.symbolize_keys(flat_map).
|
81
|
+
expect(Helpers.symbolize_keys(flat_map)).to eq(expected_map)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "recursively turns all string keys in a nested map into symbols" do
|
@@ -102,7 +102,7 @@ module Mint
|
|
102
102
|
}
|
103
103
|
}
|
104
104
|
|
105
|
-
Helpers.symbolize_keys(nested_map).
|
105
|
+
expect(Helpers.symbolize_keys(nested_map)).to eq(expected_map)
|
106
106
|
end
|
107
107
|
|
108
108
|
it "recursively downcases all keys if specified" do
|
@@ -126,22 +126,22 @@ module Mint
|
|
126
126
|
}
|
127
127
|
}
|
128
128
|
|
129
|
-
Helpers.symbolize_keys(capitalized_map, :downcase => true).
|
129
|
+
expect(Helpers.symbolize_keys(capitalized_map, :downcase => true)).to eq(expected_map)
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
133
|
describe ".listify" do
|
134
134
|
it "joins a list of three or more with an ampersand, without the Oxford comma" do
|
135
|
-
Helpers.listify(["Alex", "Chris", "John"]).
|
136
|
-
"Alex, Chris & John"
|
135
|
+
expect(Helpers.listify(["Alex", "Chris", "John"])).to eq(
|
136
|
+
"Alex, Chris & John")
|
137
137
|
end
|
138
138
|
|
139
139
|
it "joins a list of two with an ampersand" do
|
140
|
-
Helpers.listify(["Alex", "Chris"]).
|
140
|
+
expect(Helpers.listify(["Alex", "Chris"])).to eq("Alex & Chris")
|
141
141
|
end
|
142
142
|
|
143
143
|
it "does not do anything to a list of one" do
|
144
|
-
Helpers.listify(["Alex"]).
|
144
|
+
expect(Helpers.listify(["Alex"])).to eq("Alex")
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
@@ -169,18 +169,18 @@ module Mint
|
|
169
169
|
end
|
170
170
|
|
171
171
|
it "converts all nonstandard keys to standard ones" do
|
172
|
-
Helpers.standardize(@nonstandard,
|
173
|
-
:table => @table).
|
172
|
+
expect(Helpers.standardize(@nonstandard,
|
173
|
+
:table => @table)).to eq(@standard)
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
177
|
describe ".hashify" do
|
178
178
|
it "zips two lists of the same size into a Hash" do
|
179
|
-
Helpers.hashify([:one, :two, :three], [1, 2, 3]).
|
179
|
+
expect(Helpers.hashify([:one, :two, :three], [1, 2, 3])).to eq({
|
180
180
|
one: 1,
|
181
181
|
two: 2,
|
182
182
|
three: 3
|
183
|
-
}
|
183
|
+
})
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
@@ -188,28 +188,28 @@ module Mint
|
|
188
188
|
it "handles two files in the same directory" do
|
189
189
|
path1 = "~/file1"
|
190
190
|
path2 = "~/file2"
|
191
|
-
Helpers.normalize_path(path1, path2).
|
192
|
-
Pathname.new("../file1")
|
191
|
+
expect(Helpers.normalize_path(path1, path2)).to eq(
|
192
|
+
Pathname.new("../file1"))
|
193
193
|
end
|
194
194
|
|
195
195
|
it "handles two files one directory apart" do
|
196
196
|
path1 = "~/file1"
|
197
197
|
path2 = "~/subdir/file2"
|
198
|
-
Helpers.normalize_path(path1, path2).
|
199
|
-
Pathname.new("../../file1")
|
198
|
+
expect(Helpers.normalize_path(path1, path2)).to eq(
|
199
|
+
Pathname.new("../../file1"))
|
200
200
|
end
|
201
201
|
|
202
202
|
it "handles two files linked only at the directory root" do
|
203
203
|
path1 = "/home/david/file1"
|
204
204
|
path2 = "/usr/local/src/file2"
|
205
|
-
Helpers.normalize_path(path1, path2).
|
206
|
-
Pathname.new("/home/david/file1")
|
205
|
+
expect(Helpers.normalize_path(path1, path2)).to eq(
|
206
|
+
Pathname.new("/home/david/file1"))
|
207
207
|
end
|
208
208
|
|
209
209
|
it "returns nil for identical files" do
|
210
210
|
path1 = "~/file1"
|
211
211
|
path2 = "~/file1"
|
212
|
-
Helpers.normalize_path(path1, path2).
|
212
|
+
expect(Helpers.normalize_path(path1, path2)).to eq(Pathname.new("."))
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
@@ -222,7 +222,7 @@ module Mint
|
|
222
222
|
|
223
223
|
it "combines specified data with data in YAML file and updates file" do
|
224
224
|
Helpers.update_yaml! "example.yaml", "conflicting" => "baz"
|
225
|
-
YAML.load_file("example.yaml")["conflicting"].
|
225
|
+
expect(YAML.load_file("example.yaml")["conflicting"]).to eq("baz")
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
@@ -233,16 +233,16 @@ module Mint
|
|
233
233
|
end
|
234
234
|
|
235
235
|
it "creates a randomly named temp file" do
|
236
|
-
@path.
|
236
|
+
expect(@path).to exist
|
237
237
|
end
|
238
238
|
|
239
239
|
it "creates a temp file with the correct name and extension" do
|
240
|
-
@path.basename.to_s.
|
241
|
-
@path.extname.
|
240
|
+
expect(@path.basename.to_s).to match(/content/)
|
241
|
+
expect(@path.extname).to eq(".md")
|
242
242
|
end
|
243
243
|
|
244
244
|
it "fills the temp file with the specified content" do
|
245
|
-
@path.read.
|
245
|
+
expect(@path.read).to match(/This is just a test/)
|
246
246
|
end
|
247
247
|
end
|
248
248
|
end
|
data/spec/mint_spec.rb
CHANGED
@@ -3,21 +3,9 @@ require "spec_helper"
|
|
3
3
|
describe Mint do
|
4
4
|
subject { Mint }
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
style: "default",
|
10
|
-
destination: nil,
|
11
|
-
style_destination: nil
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
its(:directories) { should == { templates: "templates" } }
|
16
|
-
its(:files) { should == { syntax: "syntax.yaml", defaults: "defaults.yaml" } }
|
17
|
-
|
18
|
-
describe ".root" do
|
19
|
-
it "returns the root of the Mint gem as a string" do
|
20
|
-
Mint.root.should == File.expand_path("../../../mint", __FILE__)
|
6
|
+
describe "::ROOT" do
|
7
|
+
it "contains the root of the Mint gem as a string" do
|
8
|
+
expect(Mint::ROOT).to eq(File.expand_path("../..", __FILE__))
|
21
9
|
end
|
22
10
|
end
|
23
11
|
|
@@ -26,19 +14,19 @@ describe Mint do
|
|
26
14
|
files.map {|file| Pathname.new(file) }
|
27
15
|
end
|
28
16
|
|
29
|
-
it "
|
30
|
-
Mint.path.
|
31
|
-
|
32
|
-
|
17
|
+
it "returns the paths corresponding to all scopes as an array" do
|
18
|
+
expect(Mint.path).to eq([Pathname.new(".mint"),
|
19
|
+
Pathname.new("~/.config/mint").expand_path,
|
20
|
+
Pathname.new(Mint::ROOT + "/config").expand_path])
|
33
21
|
end
|
34
22
|
|
35
23
|
it "can filter paths by one scope" do
|
36
|
-
Mint.path(
|
24
|
+
expect(Mint.path([:user])).to eq([Pathname.new("~/.config/mint").expand_path])
|
37
25
|
end
|
38
26
|
|
39
27
|
it "can filter paths by many scopes" do
|
40
|
-
Mint.path(
|
41
|
-
|
28
|
+
expect(Mint.path([:local, :user])).to eq([Pathname.new(".mint"),
|
29
|
+
Pathname.new("~/.config/mint").expand_path])
|
42
30
|
end
|
43
31
|
end
|
44
32
|
|
@@ -46,23 +34,28 @@ describe Mint do
|
|
46
34
|
describe ".configuration" do
|
47
35
|
let(:defaults) do
|
48
36
|
{
|
49
|
-
|
50
|
-
style: "default",
|
37
|
+
root: Dir.getwd,
|
51
38
|
destination: nil,
|
52
|
-
|
39
|
+
style_mode: :inline,
|
40
|
+
style_destination: nil,
|
41
|
+
output_file: '#{basename}.#{new_extension}',
|
42
|
+
layout_or_style_or_template: [:template, 'default'],
|
43
|
+
scope: :local,
|
44
|
+
recursive: false,
|
45
|
+
verbose: false
|
53
46
|
}
|
54
47
|
end
|
55
48
|
|
56
|
-
context "when there is no
|
49
|
+
context "when there is no config.yaml file on the Mint path" do
|
57
50
|
it "returns a default set of options" do
|
58
|
-
Mint.configuration.
|
51
|
+
expect(Mint.configuration).to eq(defaults)
|
59
52
|
end
|
60
53
|
end
|
61
54
|
|
62
|
-
context "when there is a
|
55
|
+
context "when there is a config.yaml file on the Mint path" do
|
63
56
|
before do
|
64
57
|
FileUtils.mkdir_p ".mint"
|
65
|
-
File.open(".mint/
|
58
|
+
File.open(".mint/config.yaml", "w") do |file|
|
66
59
|
file << "layout: zen"
|
67
60
|
end
|
68
61
|
end
|
@@ -72,57 +65,62 @@ describe Mint do
|
|
72
65
|
end
|
73
66
|
|
74
67
|
it "merges all specified options with precedence according to scope" do
|
75
|
-
Mint.configuration[:layout].
|
68
|
+
expect(Mint.configuration[:layout]).to eq("zen")
|
76
69
|
end
|
77
70
|
|
78
71
|
it "can filter by scope (but always includes defaults)" do
|
79
|
-
Mint.configuration(:
|
72
|
+
expect(Mint.configuration(scopes: [:user])).to eq(defaults)
|
80
73
|
end
|
81
74
|
end
|
82
75
|
end
|
83
76
|
|
84
77
|
describe ".configuration_with" do
|
85
78
|
it "displays the sum of all configuration files with other options added" do
|
86
|
-
Mint.configuration_with(:
|
87
|
-
|
88
|
-
style: "default",
|
79
|
+
expect(Mint.configuration_with(local: true)).to eq({
|
80
|
+
root: Dir.getwd,
|
89
81
|
destination: nil,
|
82
|
+
style_mode: :inline,
|
90
83
|
style_destination: nil,
|
84
|
+
output_file: '#{basename}.#{new_extension}',
|
85
|
+
layout_or_style_or_template: [:template, 'default'],
|
86
|
+
scope: :local,
|
87
|
+
recursive: false,
|
88
|
+
verbose: false,
|
91
89
|
local: true
|
92
|
-
}
|
90
|
+
})
|
93
91
|
end
|
94
92
|
end
|
95
93
|
|
96
94
|
describe ".templates" do
|
97
|
-
it "returns
|
98
|
-
|
95
|
+
it "returns local templates by default" do
|
96
|
+
# Note: Now defaults to local scope, will include global templates only if explicitly requested
|
97
|
+
expect(Mint.templates).to be_an(Array)
|
99
98
|
end
|
100
99
|
|
101
|
-
it "returns
|
102
|
-
|
103
|
-
Mint.templates(:scope => :local).should_not include(Mint.root + "/config/templates/default")
|
100
|
+
it "returns global templates when global scope is specified" do
|
101
|
+
expect(Mint.templates(:global)).to include(Mint::ROOT + "/config/templates/default")
|
104
102
|
end
|
105
103
|
end
|
106
104
|
|
107
105
|
describe ".formats" do
|
108
106
|
it "includes Markdown" do
|
109
|
-
Mint.formats.
|
107
|
+
expect(Mint.formats).to include("md")
|
110
108
|
end
|
111
109
|
|
112
110
|
it "includes Haml" do
|
113
|
-
Mint.formats.
|
111
|
+
expect(Mint.formats).to include("haml")
|
114
112
|
end
|
115
113
|
end
|
116
114
|
|
117
115
|
describe ".css_formats" do
|
118
116
|
it "includes Sass" do
|
119
|
-
Mint.
|
117
|
+
expect(Mint.css_formats).to include("sass")
|
120
118
|
end
|
121
119
|
end
|
122
120
|
|
123
121
|
describe ".renderer" do
|
124
122
|
it "creates a valid renderer" do
|
125
|
-
Mint.renderer(@content_file).
|
123
|
+
expect(Mint.renderer(@content_file)).to respond_to(:render)
|
126
124
|
end
|
127
125
|
end
|
128
126
|
|
@@ -130,51 +128,69 @@ describe Mint do
|
|
130
128
|
it "chooses the appropriate path for scope" do
|
131
129
|
expectations = {
|
132
130
|
local: Pathname.new(".mint"),
|
133
|
-
user: Pathname.new("~/.mint").expand_path,
|
134
|
-
global: Pathname.new(Mint
|
131
|
+
user: Pathname.new("~/.config/mint").expand_path,
|
132
|
+
global: Pathname.new(Mint::ROOT + "/config").expand_path
|
135
133
|
}
|
136
134
|
|
137
135
|
expectations.each do |scope, path|
|
138
|
-
Mint.path_for_scope(scope).
|
136
|
+
expect(Mint.path_for_scope(scope)).to eq(path)
|
139
137
|
end
|
140
138
|
end
|
141
139
|
end
|
142
140
|
|
141
|
+
# Refactored lookup methods for explicit parameter interface
|
143
142
|
describe ".lookup_template" do
|
144
|
-
it "
|
145
|
-
Mint.lookup_template(
|
146
|
-
|
147
|
-
|
148
|
-
Mint.lookup_template(:zen, :style).should be_in_template("zen")
|
149
|
-
Mint.lookup_template("layout.haml").should == "layout.haml"
|
150
|
-
Mint.lookup_template("dynamic.sass").should == "dynamic.sass"
|
143
|
+
it "returns template directory path by name" do
|
144
|
+
result = Mint.lookup_template("default")
|
145
|
+
expect(result.to_s).to include("templates/default")
|
146
|
+
expect(File.directory?(result)).to be true
|
151
147
|
end
|
152
148
|
end
|
153
149
|
|
154
|
-
describe ".
|
155
|
-
it "
|
156
|
-
Mint.
|
157
|
-
|
158
|
-
|
150
|
+
describe ".lookup_layout" do
|
151
|
+
it "returns layout file path by template name" do
|
152
|
+
result = Mint.lookup_layout("default")
|
153
|
+
expect(result).to include("templates/default")
|
154
|
+
expect(result).to end_with("layout.erb")
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe ".lookup_style" do
|
159
|
+
it "returns style file path by template name" do
|
160
|
+
result = Mint.lookup_style("default")
|
161
|
+
expect(result).to include("templates/default")
|
162
|
+
expect(result).to end_with("style.css")
|
159
163
|
end
|
164
|
+
end
|
160
165
|
|
161
|
-
|
162
|
-
|
163
|
-
|
166
|
+
describe ".find_template" do
|
167
|
+
it "finds the correct template file by name and type" do
|
168
|
+
layout_file = Mint.find_template("default", :layout)
|
169
|
+
style_file = Mint.find_template("default", :style)
|
170
|
+
|
171
|
+
expect(layout_file).to include("templates/default")
|
172
|
+
expect(layout_file).to end_with("layout.erb")
|
173
|
+
expect(style_file).to include("templates/default")
|
174
|
+
expect(style_file).to end_with("style.css")
|
175
|
+
end
|
176
|
+
|
177
|
+
it "determines if a file is a template file" do
|
178
|
+
actual_template = Mint.lookup_layout("default")
|
179
|
+
fake_template = "#{Mint::ROOT}/config/templates/default.css"
|
164
180
|
obvious_nontemplate = @dynamic_style_file
|
165
181
|
|
166
|
-
actual_template.
|
167
|
-
fake_template.
|
168
|
-
obvious_nontemplate.
|
182
|
+
expect(Mint.template?(actual_template)).to be_truthy
|
183
|
+
expect(Mint.template?(fake_template)).to be_falsy
|
184
|
+
expect(Mint.template?(obvious_nontemplate)).to be_falsy
|
169
185
|
end
|
170
186
|
end
|
171
187
|
|
172
188
|
describe ".guess_name_from" do
|
173
189
|
it "properly guesses destination file names based on source file names" do
|
174
|
-
Mint.guess_name_from("content.md").
|
175
|
-
Mint.guess_name_from("content.textile").
|
176
|
-
Mint.guess_name_from("layout.haml").
|
177
|
-
Mint.guess_name_from("dynamic.sass").
|
190
|
+
expect(Mint.guess_name_from("content.md")).to eq("content.html")
|
191
|
+
expect(Mint.guess_name_from("content.textile")).to eq("content.html")
|
192
|
+
expect(Mint.guess_name_from("layout.haml")).to eq("layout.html")
|
193
|
+
expect(Mint.guess_name_from("dynamic.sass")).to eq("dynamic.css")
|
178
194
|
end
|
179
195
|
end
|
180
196
|
|
@@ -184,7 +200,11 @@ describe Mint do
|
|
184
200
|
subject { document }
|
185
201
|
|
186
202
|
its(:destination_file_path) { should_not exist }
|
187
|
-
|
203
|
+
it "style destination file should not exist initially" do
|
204
|
+
# Clean up any existing style file first
|
205
|
+
FileUtils.rm_f(document.style_destination_file_path) if document.style_destination_file_path && File.exist?(document.style_destination_file_path)
|
206
|
+
expect(document.style_destination_file_path).not_to exist
|
207
|
+
end
|
188
208
|
end
|
189
209
|
|
190
210
|
# These are copied from document_spec.rb. I eventually want to move
|
@@ -195,24 +215,28 @@ describe Mint do
|
|
195
215
|
subject { document }
|
196
216
|
|
197
217
|
its(:destination_file_path) { should exist }
|
198
|
-
|
218
|
+
|
219
|
+
it "creates style file only for external style mode" do
|
220
|
+
if document.style_mode == :external
|
221
|
+
expect(document.style_destination_file_path).to exist
|
222
|
+
else
|
223
|
+
expect(document.style_destination_file_path).not_to exist
|
224
|
+
end
|
225
|
+
end
|
199
226
|
end
|
200
227
|
end
|
201
228
|
|
202
229
|
describe ".template_path" do
|
203
|
-
it "
|
204
|
-
Mint.template_path("pro", :
|
205
|
-
".mint/templates/pro/layout.haml"
|
230
|
+
it "returns template directory for given name and scope" do
|
231
|
+
expect(Mint.template_path("pro", :local)).to eq(Pathname.new(".mint/templates/pro"))
|
206
232
|
end
|
207
233
|
|
208
|
-
it "
|
209
|
-
Mint.template_path("pro", :
|
210
|
-
".mint/templates/pro/layout.erb"
|
234
|
+
it "works with user scope" do
|
235
|
+
expect(Mint.template_path("pro", :user)).to eq(Pathname.new("~/.config/mint/templates/pro").expand_path)
|
211
236
|
end
|
212
237
|
|
213
|
-
it "
|
214
|
-
Mint.template_path("pro", :
|
215
|
-
File.expand_path("~/.mint/templates/pro/layout.haml")
|
238
|
+
it "works with global scope" do
|
239
|
+
expect(Mint.template_path("pro", :global)).to eq(Pathname.new("#{Mint::ROOT}/config/templates/pro"))
|
216
240
|
end
|
217
241
|
end
|
218
242
|
end
|