mint 0.7.3 → 0.8.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 +7 -0
- data/Gemfile +23 -14
- data/LICENSE +22 -0
- data/README.md +82 -56
- data/bin/mint +47 -10
- data/bin/mint-epub +1 -4
- data/config/templates/base/style.css +187 -0
- data/config/templates/default/css/style.css +126 -79
- 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/newspaper/layout.erb +16 -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/protocol/layout.erb +9 -0
- data/config/templates/protocol/style.css +25 -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_template.rb +37 -0
- data/lib/mint/document.rb +193 -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 +207 -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_spec.rb +1 -1
- data/spec/document_spec.rb +105 -68
- data/spec/helpers_spec.rb +42 -42
- data/spec/mint_spec.rb +104 -80
- data/spec/plugin_spec.rb +86 -88
- 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 +145 -167
- data/config/syntax.yaml +0 -71
- data/config/templates/base/style.sass +0 -144
- 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/document_spec.rb
CHANGED
@@ -14,20 +14,27 @@ module Mint
|
|
14
14
|
#
|
15
15
|
# This test doesn't cover any plugin transformations. Those
|
16
16
|
# transformations are covered in the Plugin spec.
|
17
|
-
its(:content) {
|
18
|
-
its(:metadata) {
|
17
|
+
its(:content) { is_expected.to match(/<p>This is just a test.<\/p>/) }
|
18
|
+
its(:metadata) { is_expected.to eq({ "metadata" => true }) }
|
19
19
|
|
20
20
|
# Render output
|
21
21
|
|
22
22
|
# This test doesn't cover any plugin transformations. Those
|
23
23
|
# transformations are covered in the Plugin spec.
|
24
24
|
it "renders its layout, injecting content inside" do
|
25
|
-
document.render.
|
26
|
-
|
25
|
+
expect(document.render).to include(document.content)
|
26
|
+
expect(document.render).to include("<html")
|
27
|
+
expect(document.render).to include("</html>")
|
27
28
|
end
|
28
29
|
|
29
|
-
it "
|
30
|
-
document.
|
30
|
+
it "includes its stylesheet appropriately based on style mode" do
|
31
|
+
if document.style_mode == :external
|
32
|
+
expect(document.render).to include('<link rel="stylesheet"')
|
33
|
+
expect(document.render).not_to include("<style>")
|
34
|
+
else
|
35
|
+
expect(document.render).to include("<style>")
|
36
|
+
expect(document.render).to include("</style>")
|
37
|
+
end
|
31
38
|
end
|
32
39
|
|
33
40
|
# Mint output
|
@@ -36,14 +43,19 @@ module Mint
|
|
36
43
|
# transformations are covered in the Plugin spec.
|
37
44
|
it "writes its rendered style to #style_destination_file" do
|
38
45
|
document.publish!
|
39
|
-
document.
|
46
|
+
if document.style_mode == :external
|
47
|
+
expect(document.style_destination_file_path).to exist
|
48
|
+
else
|
49
|
+
# For inline styles, no external file should be created
|
50
|
+
expect(document.style_destination_file_path).not_to exist
|
51
|
+
end
|
40
52
|
end
|
41
53
|
|
42
54
|
it "writes its rendered layout and content to #destination_file" do
|
43
55
|
document.publish!
|
44
|
-
document.destination_file_path.
|
56
|
+
expect(document.destination_file_path).to exist
|
45
57
|
content = File.read document.destination_file
|
46
|
-
content.
|
58
|
+
expect(content).to eq(document.render)
|
47
59
|
end
|
48
60
|
end
|
49
61
|
|
@@ -51,100 +63,119 @@ module Mint
|
|
51
63
|
let(:document) { Document.new @content_file }
|
52
64
|
|
53
65
|
subject { document }
|
54
|
-
its(:root) {
|
55
|
-
its(:destination) {
|
56
|
-
its(:source) {
|
57
|
-
its(:style_destination) {
|
66
|
+
its(:root) { is_expected.to eq(@tmp_dir) }
|
67
|
+
its(:destination) { is_expected.to be_nil }
|
68
|
+
its(:source) { is_expected.to eq("content.md") }
|
69
|
+
its(:style_destination) { is_expected.to be_nil }
|
58
70
|
|
59
|
-
|
60
|
-
|
71
|
+
it "has a style destination file in user tmp directory" do
|
72
|
+
expect(document.style_destination_file).to match(/\.config\/mint\/tmp\/style\.css$/)
|
61
73
|
end
|
62
74
|
|
63
|
-
|
64
|
-
|
75
|
+
it "has a style destination directory in user tmp directory" do
|
76
|
+
expect(document.style_destination_directory).to match(/\.config\/mint\/tmp$/)
|
65
77
|
end
|
66
78
|
|
67
79
|
its(:style_destination_file_path) do
|
68
|
-
|
80
|
+
is_expected.to eq(Pathname.new(document.style_destination_file))
|
69
81
|
end
|
70
82
|
|
71
83
|
its(:style_destination_directory_path) do
|
72
|
-
|
84
|
+
is_expected.to eq(Pathname.new(document.style_destination_directory))
|
73
85
|
end
|
74
86
|
|
75
|
-
its(:layout) {
|
76
|
-
its(:style) {
|
87
|
+
its(:layout) { is_expected.to be_in_directory("default") }
|
88
|
+
its(:style) { is_expected.to be_in_directory("default") }
|
77
89
|
|
78
|
-
|
90
|
+
it "has a stylesheet path relative to user tmp directory" do
|
91
|
+
expect(document.stylesheet).to match(/\.config\/mint\/tmp\/style\.css$/)
|
92
|
+
end
|
79
93
|
|
80
94
|
it_should_behave_like "all documents"
|
81
95
|
end
|
82
96
|
|
83
97
|
context "when it's created with explicit destination directories" do
|
84
98
|
let(:document) { Document.new @content_file,
|
85
|
-
:
|
86
|
-
:
|
99
|
+
destination: "destination",
|
100
|
+
style_destination: "styles" }
|
87
101
|
|
88
102
|
subject { document }
|
89
|
-
its(:root) {
|
90
|
-
its(:destination) {
|
91
|
-
its(:source) {
|
92
|
-
its(:style_destination) {
|
103
|
+
its(:root) { is_expected.to eq(@tmp_dir) }
|
104
|
+
its(:destination) { is_expected.to eq("destination") }
|
105
|
+
its(:source) { is_expected.to eq("content.md") }
|
106
|
+
its(:style_destination) { is_expected.to eq("styles") }
|
93
107
|
|
94
108
|
its(:style_destination_file) do
|
95
|
-
|
109
|
+
is_expected.to eq("#{@tmp_dir}/destination/styles/style.css")
|
96
110
|
end
|
97
111
|
|
98
112
|
its(:style_destination_directory) do
|
99
|
-
|
113
|
+
is_expected.to eq("#{@tmp_dir}/destination/styles")
|
100
114
|
end
|
101
115
|
|
102
116
|
its(:style_destination_file_path) do
|
103
|
-
|
117
|
+
is_expected.to eq(Pathname.new(document.style_destination_file))
|
104
118
|
end
|
105
119
|
|
106
120
|
its(:style_destination_directory_path) do
|
107
|
-
|
121
|
+
is_expected.to eq(Pathname.new(document.style_destination_directory))
|
108
122
|
end
|
109
123
|
|
110
|
-
its(:layout) {
|
111
|
-
its(:style) {
|
124
|
+
its(:layout) { is_expected.to be_in_directory("default") }
|
125
|
+
its(:style) { is_expected.to be_in_directory("default") }
|
112
126
|
|
113
|
-
|
127
|
+
it "has a stylesheet path relative to user tmp directory" do
|
128
|
+
expect(document.stylesheet).to match(/\.config\/mint\/tmp\/style\.css$/)
|
129
|
+
end
|
114
130
|
|
115
131
|
it_should_behave_like "all documents"
|
116
132
|
end
|
117
133
|
|
118
134
|
context "when it's created with an explicit root" do
|
119
135
|
let(:document) { Document.new @content_file,
|
120
|
-
:
|
136
|
+
root: "#{@tmp_dir}/alternative-root" }
|
121
137
|
|
122
138
|
subject { document }
|
123
|
-
its(:root) {
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
its(:
|
129
|
-
|
139
|
+
its(:root) { is_expected.to eq("#{@tmp_dir}/alternative-root") }
|
140
|
+
it "preserves folder structure" do
|
141
|
+
expect(document.destination).to be_present
|
142
|
+
end
|
143
|
+
its(:source) { is_expected.to eq("content.md") }
|
144
|
+
its(:style_destination) { is_expected.to be_nil }
|
145
|
+
|
146
|
+
it "has appropriate style behavior based on style mode" do
|
147
|
+
if document.style_mode == :external
|
148
|
+
expect(document.style_destination_file).to match(/\.config\/mint\/tmp\/style\.css$/)
|
149
|
+
else
|
150
|
+
# For inline styles, the style_destination_file should still exist as a path
|
151
|
+
# but no actual file should be created during publish
|
152
|
+
expect(document.style_destination_file).to be_present
|
153
|
+
end
|
130
154
|
end
|
131
155
|
|
132
|
-
|
133
|
-
|
156
|
+
it "has appropriate style destination directory based on style mode" do
|
157
|
+
if document.style_mode == :external
|
158
|
+
expect(document.style_destination_directory).to match(/\.config\/mint\/tmp$/)
|
159
|
+
else
|
160
|
+
# For inline styles, still has a directory path but it's not used for external files
|
161
|
+
expect(document.style_destination_directory).to be_present
|
162
|
+
end
|
134
163
|
end
|
135
164
|
|
136
165
|
its(:style_destination_file_path) do
|
137
|
-
|
166
|
+
is_expected.to eq(Pathname.new(document.style_destination_file))
|
138
167
|
end
|
139
168
|
|
140
169
|
its(:style_destination_directory_path) do
|
141
|
-
|
170
|
+
is_expected.to eq(Pathname.new(document.style_destination_directory))
|
142
171
|
end
|
143
172
|
|
144
|
-
its(:layout) {
|
145
|
-
its(:style) {
|
173
|
+
its(:layout) { is_expected.to be_in_directory("default") }
|
174
|
+
its(:style) { is_expected.to be_in_directory("default") }
|
146
175
|
|
147
|
-
|
176
|
+
it "has a stylesheet path relative to user tmp directory" do
|
177
|
+
expect(document.stylesheet).to match(/\.config\/mint\/tmp\/style\.css$/)
|
178
|
+
end
|
148
179
|
|
149
180
|
it_should_behave_like "all documents"
|
150
181
|
end
|
@@ -161,31 +192,33 @@ module Mint
|
|
161
192
|
end
|
162
193
|
|
163
194
|
subject { document }
|
164
|
-
its(:root) {
|
165
|
-
its(:destination) {
|
166
|
-
its(:source) {
|
167
|
-
its(:style_destination) {
|
195
|
+
its(:root) { is_expected.to eq("#{@tmp_dir}/alternative-root") }
|
196
|
+
its(:destination) { is_expected.to eq("destination") }
|
197
|
+
its(:source) { is_expected.to eq("content.md") }
|
198
|
+
its(:style_destination) { is_expected.to eq("styles") }
|
168
199
|
|
169
200
|
its(:style_destination_file) do
|
170
|
-
|
201
|
+
is_expected.to eq("#{@tmp_dir}/alternative-root/destination/styles/style.css")
|
171
202
|
end
|
172
203
|
|
173
204
|
its(:style_destination_directory) do
|
174
|
-
|
205
|
+
is_expected.to eq("#{@tmp_dir}/alternative-root/destination/styles")
|
175
206
|
end
|
176
207
|
|
177
208
|
its(:style_destination_file_path) do
|
178
|
-
|
209
|
+
is_expected.to eq(Pathname.new(document.style_destination_file))
|
179
210
|
end
|
180
211
|
|
181
212
|
its(:style_destination_directory_path) do
|
182
|
-
|
213
|
+
is_expected.to eq(Pathname.new(document.style_destination_directory))
|
183
214
|
end
|
184
215
|
|
185
|
-
its(:layout) {
|
186
|
-
its(:style) {
|
216
|
+
its(:layout) { is_expected.to be_in_directory("zen") }
|
217
|
+
its(:style) { is_expected.to be_in_directory("zen") }
|
187
218
|
|
188
|
-
|
219
|
+
it "has a stylesheet path relative to user tmp directory" do
|
220
|
+
expect(document.stylesheet).to match(/\.config\/mint\/tmp\/style\.css$/)
|
221
|
+
end
|
189
222
|
|
190
223
|
it_should_behave_like "all documents"
|
191
224
|
end
|
@@ -194,29 +227,33 @@ module Mint
|
|
194
227
|
let(:text) { "metadata: true\n\nReal text" }
|
195
228
|
describe ".metadata_chunk" do
|
196
229
|
it "extracts, but does not parse, metadata from text" do
|
197
|
-
Document.metadata_chunk(text).
|
230
|
+
expect(Document.metadata_chunk(text)).to eq("metadata: true")
|
198
231
|
end
|
199
232
|
end
|
200
233
|
|
201
234
|
describe ".metadata_from" do
|
202
235
|
it "parses a documents metadata if present" do
|
203
|
-
Document.metadata_from(text).
|
236
|
+
expect(Document.metadata_from(text)).to eq({ "metadata" => true })
|
204
237
|
end
|
205
238
|
|
206
239
|
it "returns the empty string if a document has bad/no metadata" do
|
207
|
-
Document.metadata_from("No metadata here").
|
240
|
+
expect(Document.metadata_from("No metadata here")).to eq({})
|
241
|
+
end
|
242
|
+
|
243
|
+
it "handles a non-simple string that is also not YAML" do
|
244
|
+
expect(Document.metadata_from("# Non-simple string")).to eq({})
|
208
245
|
end
|
209
246
|
end
|
210
247
|
|
211
248
|
describe ".parse_metadata_from" do
|
212
249
|
it "separates text from its metadata if present" do
|
213
|
-
Document.parse_metadata_from(text).
|
214
|
-
[{ "metadata" => true }, "Real text"]
|
250
|
+
expect(Document.parse_metadata_from(text)).to eq(
|
251
|
+
[{ "metadata" => true }, "Real text"])
|
215
252
|
end
|
216
253
|
|
217
254
|
it "returns the entire text if no metadata is found" do
|
218
|
-
Document.parse_metadata_from("No metadata here").
|
219
|
-
[{}, "No metadata here"]
|
255
|
+
expect(Document.parse_metadata_from("No metadata here")).to eq(
|
256
|
+
[{}, "No metadata here"])
|
220
257
|
end
|
221
258
|
end
|
222
259
|
end
|
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
|