cartage 2.2 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +99 -80
- data/README.rdoc +13 -7
- data/Rakefile +52 -38
- data/lib/cartage/backport.rb +3 -3
- data/lib/cartage/cli.rb +76 -76
- data/lib/cartage/commands/echo.rb +6 -6
- data/lib/cartage/commands/info.rb +17 -17
- data/lib/cartage/commands/manifest.rb +46 -46
- data/lib/cartage/commands/metadata.rb +2 -2
- data/lib/cartage/commands/pack.rb +6 -6
- data/lib/cartage/config.rb +27 -25
- data/lib/cartage/core.rb +18 -18
- data/lib/cartage/gli_ext.rb +10 -10
- data/lib/cartage/minitest.rb +7 -7
- data/lib/cartage/plugin.rb +10 -9
- data/lib/cartage/plugins/build_tarball.rb +2 -2
- data/lib/cartage/plugins/manifest.rb +85 -85
- data/lib/cartage.rb +67 -67
- data/test/minitest_config.rb +8 -8
- data/test/test_cartage.rb +130 -130
- data/test/test_cartage_build_tarball.rb +22 -22
- data/test/test_cartage_config.rb +27 -27
- data/test/test_cartage_core.rb +36 -36
- data/test/test_cartage_manifest.rb +51 -53
- data/test/test_cartage_plugin.rb +21 -21
- metadata +37 -20
data/test/test_cartage_config.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "minitest_config"
|
4
|
+
require "cartage/config"
|
5
5
|
|
6
6
|
describe Cartage::Config do
|
7
7
|
let(:data) {
|
8
8
|
{
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
"x" => 1,
|
10
|
+
"arr" => %w[a b c],
|
11
|
+
"commands" => {},
|
12
|
+
"plugins" => {
|
13
|
+
"test" => {
|
14
|
+
"x" => 2
|
15
15
|
}
|
16
16
|
}
|
17
17
|
}
|
@@ -20,7 +20,7 @@ describe Cartage::Config do
|
|
20
20
|
let(:config) { Cartage::Config.new(odata) }
|
21
21
|
let(:hdata) { Marshal.load(Marshal.dump(data)) }
|
22
22
|
|
23
|
-
describe
|
23
|
+
describe "load" do
|
24
24
|
def watch_pathname_exist
|
25
25
|
mpname = Pathname.singleton_class
|
26
26
|
mpname.send(:define_method, :exist_tries, -> { @exist_tries ||= [] })
|
@@ -47,7 +47,7 @@ describe Cartage::Config do
|
|
47
47
|
Pathname.send(:undef_method, :__stub_expand_path__)
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
50
|
+
it "looks for default files when given :default" do
|
51
51
|
watch_pathname_exist do
|
52
52
|
ignore_pathname_expand_path do
|
53
53
|
Cartage::Config.load(:default)
|
@@ -56,17 +56,17 @@ describe Cartage::Config do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
59
|
+
it "fails if the file does not exist" do
|
60
60
|
instance_stub Pathname, :exist?, -> { false } do
|
61
61
|
assert_raises_with_message ArgumentError,
|
62
|
-
|
63
|
-
Cartage::Config.load(
|
62
|
+
"Configuration file foo does not exist." do
|
63
|
+
Cartage::Config.load("foo")
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
it
|
69
|
-
instance_stub Pathname, :read, -> {
|
68
|
+
it "loads the file if it exists" do
|
69
|
+
instance_stub Pathname, :read, -> { "{ faked: true }" } do
|
70
70
|
instance_stub Pathname, :exist?, -> { true } do
|
71
71
|
expected = {
|
72
72
|
faked: true,
|
@@ -74,12 +74,12 @@ describe Cartage::Config do
|
|
74
74
|
plugins: OpenStruct.new
|
75
75
|
}
|
76
76
|
assert_equal expected,
|
77
|
-
Cartage::Config.load(
|
77
|
+
Cartage::Config.load("foo").instance_variable_get(:@table)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
it
|
82
|
+
it "uses a default configuration if there is no default config file" do
|
83
83
|
expected = {
|
84
84
|
commands: OpenStruct.new,
|
85
85
|
plugins: OpenStruct.new
|
@@ -89,30 +89,30 @@ describe Cartage::Config do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
describe
|
93
|
-
it
|
92
|
+
describe "import" do
|
93
|
+
it "reads a file if it exists" do
|
94
94
|
stub File, :exist?, ->(_) { true } do
|
95
|
-
stub File, :read, ->(_) {
|
96
|
-
assert_equal
|
95
|
+
stub File, :read, ->(_) { "faked" } do
|
96
|
+
assert_equal "faked", Cartage::Config.import("foo")
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
it
|
101
|
+
it "returns nil if the file does not exist" do
|
102
102
|
stub File, :exist?, ->(_) { false } do
|
103
|
-
assert_nil Cartage::Config.import(
|
103
|
+
assert_nil Cartage::Config.import("foo")
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
describe
|
109
|
-
it
|
108
|
+
describe "#to_h" do
|
109
|
+
it "completely converts a Config object to hash" do
|
110
110
|
assert_equal hdata, config.to_h
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
describe
|
115
|
-
it
|
114
|
+
describe "#to_yaml" do
|
115
|
+
it "overrides the OpenStruct implementation" do
|
116
116
|
assert_equal hdata.to_yaml, config.to_yaml
|
117
117
|
end
|
118
118
|
end
|
data/test/test_cartage_core.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "minitest_config"
|
4
4
|
|
5
5
|
describe Cartage::Core do
|
6
6
|
let(:subject) {
|
@@ -18,20 +18,20 @@ describe Cartage::Core do
|
|
18
18
|
}
|
19
19
|
let(:object) { subject.new }
|
20
20
|
|
21
|
-
describe
|
22
|
-
it
|
23
|
-
assert_raises_with_message ArgumentError,
|
21
|
+
describe "attr_reader_with_default" do
|
22
|
+
it "fails without a default" do
|
23
|
+
assert_raises_with_message ArgumentError, "No default provided." do
|
24
24
|
subject.attr_reader_with_default :answer
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
29
|
-
assert_raises_with_message ArgumentError,
|
28
|
+
it "fails with too many defaults" do
|
29
|
+
assert_raises_with_message ArgumentError, "Too many defaults provided." do
|
30
30
|
subject.attr_reader_with_default :answer, 42, &-> { 42 }
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it "defines default and reader methods when given a value" do
|
35
35
|
subject.attr_reader_with_default :answer, 42
|
36
36
|
assert_respond_to object, :answer
|
37
37
|
assert_equal 42, object.answer
|
@@ -40,7 +40,7 @@ describe Cartage::Core do
|
|
40
40
|
assert_equal 42, object.default_answer
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
43
|
+
it "defines default and reader methods when given a block" do
|
44
44
|
subject.attr_reader_with_default :answer do
|
45
45
|
42
|
46
46
|
end
|
@@ -52,63 +52,63 @@ describe Cartage::Core do
|
|
52
52
|
assert_equal 42, object.default_answer
|
53
53
|
end
|
54
54
|
|
55
|
-
it
|
56
|
-
subject.attr_reader_with_default :favourite_colour,
|
55
|
+
it "memoizes the default value" do
|
56
|
+
subject.attr_reader_with_default :favourite_colour, "blue"
|
57
57
|
assert_same object.default_favourite_colour, object.default_favourite_colour
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
describe
|
62
|
-
it
|
63
|
-
assert_raises_with_message ArgumentError,
|
61
|
+
describe "attr_writer_with_transform" do
|
62
|
+
it "fails without a transform" do
|
63
|
+
assert_raises_with_message ArgumentError, "No transform provided." do
|
64
64
|
subject.attr_writer_with_transform :answer
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
it
|
69
|
-
assert_raises_with_message ArgumentError,
|
68
|
+
it "fails with too many transforms" do
|
69
|
+
assert_raises_with_message ArgumentError, "Too many transforms provided." do
|
70
70
|
subject.attr_writer_with_transform :answer, 42, &-> { 42 }
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
it
|
75
|
-
assert_raises_with_message ArgumentError,
|
74
|
+
it "fails if the transform is not callable" do
|
75
|
+
assert_raises_with_message ArgumentError, "Transform is not callable." do
|
76
76
|
subject.attr_writer_with_transform :answer, 42
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
80
|
+
it "defines a writer method when given a symbol" do
|
81
81
|
subject.attr_writer_with_transform :answer, :to_s
|
82
82
|
assert_respond_to object, :answer=
|
83
83
|
object.answer = 42
|
84
|
-
assert_equal
|
84
|
+
assert_equal "42", object.instance_variable_get(:@answer)
|
85
85
|
end
|
86
86
|
|
87
|
-
it
|
87
|
+
it "defines a writer method when given a callable" do
|
88
88
|
subject.attr_writer_with_transform :answer, ->(v) { v.to_s }
|
89
89
|
assert_respond_to object, :answer=
|
90
90
|
object.answer = 42
|
91
|
-
assert_equal
|
91
|
+
assert_equal "42", object.instance_variable_get(:@answer)
|
92
92
|
end
|
93
93
|
|
94
|
-
it
|
94
|
+
it "defines a writer method when given a block" do
|
95
95
|
subject.attr_writer_with_transform :answer do |v|
|
96
96
|
String(v)
|
97
97
|
end
|
98
98
|
assert_respond_to object, :answer=
|
99
99
|
object.answer = 42
|
100
|
-
assert_equal
|
100
|
+
assert_equal "42", object.instance_variable_get(:@answer)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
describe
|
105
|
-
it
|
106
|
-
assert_raises_with_message ArgumentError,
|
104
|
+
describe "attr_accessor_with_default" do
|
105
|
+
it "fails without a default" do
|
106
|
+
assert_raises_with_message ArgumentError, "No default provided." do
|
107
107
|
subject.attr_accessor_with_default :answer
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
it
|
111
|
+
it "defines a default, reader, and writer methods when given a value" do
|
112
112
|
subject.attr_accessor_with_default :answer, default: 42
|
113
113
|
|
114
114
|
assert_respond_to object, :answer
|
@@ -120,7 +120,7 @@ describe Cartage::Core do
|
|
120
120
|
assert_equal 42, object.default_answer
|
121
121
|
end
|
122
122
|
|
123
|
-
it
|
123
|
+
it "defines a default, reader, and writer methods when given a block" do
|
124
124
|
subject.attr_accessor_with_default :answer do
|
125
125
|
42
|
126
126
|
end
|
@@ -134,18 +134,18 @@ describe Cartage::Core do
|
|
134
134
|
assert_equal 42, object.default_answer
|
135
135
|
end
|
136
136
|
|
137
|
-
it
|
138
|
-
subject.attr_accessor_with_default :favourite_colour, default:
|
137
|
+
it "memoizes the default value" do
|
138
|
+
subject.attr_accessor_with_default :favourite_colour, default: "blue"
|
139
139
|
assert_same object.favourite_colour, object.favourite_colour
|
140
140
|
end
|
141
141
|
|
142
|
-
it
|
143
|
-
assert_raises_with_message ArgumentError,
|
142
|
+
it "fails if transform is not callable" do
|
143
|
+
assert_raises_with_message ArgumentError, "Transform is not callable." do
|
144
144
|
subject.attr_accessor_with_default :answer, default: 42, transform: 42
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
it
|
148
|
+
it "accepts a symbol for transform" do
|
149
149
|
subject.attr_accessor_with_default :answer, default: 42, transform: :to_s
|
150
150
|
|
151
151
|
assert_respond_to object, :answer
|
@@ -154,10 +154,10 @@ describe Cartage::Core do
|
|
154
154
|
|
155
155
|
assert_equal 42, object.answer
|
156
156
|
object.answer = 21
|
157
|
-
assert_equal
|
157
|
+
assert_equal "21", object.answer
|
158
158
|
end
|
159
159
|
|
160
|
-
it
|
160
|
+
it "accepts a callable for transform" do
|
161
161
|
subject.attr_accessor_with_default :answer,
|
162
162
|
default: 42, transform: ->(v) { v.to_s }
|
163
163
|
assert_respond_to object, :answer
|
@@ -166,7 +166,7 @@ describe Cartage::Core do
|
|
166
166
|
|
167
167
|
assert_equal 42, object.answer
|
168
168
|
object.answer = 21
|
169
|
-
assert_equal
|
169
|
+
assert_equal "21", object.answer
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "minitest_config"
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe "Cartage::Manifest" do
|
6
6
|
let(:cartage) { Cartage.new }
|
7
7
|
let(:manifest) { cartage.manifest }
|
8
|
-
let(:manifest_contents) { %w
|
9
|
-
let(:expected_tmpfile) { %W
|
8
|
+
let(:manifest_contents) { %w[bin/build bin/cartage lib/cartage.rb spec/cartage.rb] }
|
9
|
+
let(:expected_tmpfile) { %W[foo/bin/build\n foo/bin/cartage\n foo/lib/cartage.rb\n] }
|
10
10
|
|
11
11
|
before do
|
12
12
|
cartage
|
@@ -51,8 +51,8 @@ describe 'Cartage::Manifest' do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe
|
55
|
-
it
|
54
|
+
describe "#resolve" do
|
55
|
+
it "fails if there is no manifest_file" do
|
56
56
|
stub_manifest_file exists: false do
|
57
57
|
ex = assert_raises Cartage::Manifest::MissingError do
|
58
58
|
manifest.resolve
|
@@ -61,26 +61,26 @@ describe 'Cartage::Manifest' do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
it
|
64
|
+
it "fails if there is no block given" do
|
65
65
|
stub_manifest_file do
|
66
|
-
assert_raises_with_message ArgumentError,
|
66
|
+
assert_raises_with_message ArgumentError, "A block is required." do
|
67
67
|
manifest.resolve
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
it
|
72
|
+
it "fails if the manifest is empty" do
|
73
73
|
stub_manifest_file contents: [] do
|
74
|
-
assert_raises_with_message RuntimeError,
|
74
|
+
assert_raises_with_message RuntimeError, "Manifest.txt is empty." do
|
75
75
|
manifest.resolve {}
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
80
|
+
it "yields the name of a tempfile with the manifest contents" do
|
81
81
|
stub_ignore_file contents: [] do
|
82
82
|
stub_manifest_file contents: manifest_contents do
|
83
|
-
manifest.resolve(Pathname(
|
83
|
+
manifest.resolve(Pathname("foo")) { |name|
|
84
84
|
assert_match(/Manifest\./, name)
|
85
85
|
assert_equal (expected_tmpfile << "foo/spec/cartage.rb\n"),
|
86
86
|
Pathname(name).readlines
|
@@ -89,21 +89,21 @@ describe 'Cartage::Manifest' do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
it
|
93
|
-
stub_ignore_file contents: %w
|
92
|
+
it "prunes out ignored files from a specified cartignore" do
|
93
|
+
stub_ignore_file contents: %w[spec/] do
|
94
94
|
stub_manifest_file contents: manifest_contents do
|
95
|
-
manifest.resolve(Pathname(
|
95
|
+
manifest.resolve(Pathname("foo")) { |name|
|
96
96
|
assert_equal expected_tmpfile, Pathname(name).readlines
|
97
97
|
}
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
it
|
102
|
+
it "prunes out ignored files from a specified slugignore" do
|
103
103
|
stub_ignore_file exists: false do
|
104
|
-
stub_slugignore_file contents: %w
|
104
|
+
stub_slugignore_file contents: %w[spec/] do
|
105
105
|
stub_manifest_file contents: manifest_contents do
|
106
|
-
manifest.resolve(Pathname(
|
106
|
+
manifest.resolve(Pathname("foo")) { |name|
|
107
107
|
assert_equal expected_tmpfile, Pathname(name).readlines
|
108
108
|
}
|
109
109
|
end
|
@@ -111,11 +111,11 @@ describe 'Cartage::Manifest' do
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
it
|
114
|
+
it "prunes out ignored files from the default cartignore" do
|
115
115
|
stub_ignore_file exists: false do
|
116
116
|
stub_slugignore_file exists: false do
|
117
117
|
stub_manifest_file contents: manifest_contents do
|
118
|
-
manifest.resolve(Pathname(
|
118
|
+
manifest.resolve(Pathname("foo")) { |name|
|
119
119
|
assert_equal expected_tmpfile.reject { |v| v =~ /build/ },
|
120
120
|
Pathname(name).readlines
|
121
121
|
}
|
@@ -124,10 +124,10 @@ describe 'Cartage::Manifest' do
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
-
it
|
128
|
-
stub_ignore_file contents: %w
|
127
|
+
it "prunes out ignored files with a leading slash" do
|
128
|
+
stub_ignore_file contents: %w[/spec] do
|
129
129
|
stub_manifest_file contents: manifest_contents do
|
130
|
-
manifest.resolve(Pathname(
|
130
|
+
manifest.resolve(Pathname("foo")) { |name|
|
131
131
|
assert_equal expected_tmpfile, Pathname(name).readlines
|
132
132
|
}
|
133
133
|
end
|
@@ -135,18 +135,18 @@ describe 'Cartage::Manifest' do
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
-
describe
|
139
|
-
it
|
138
|
+
describe "#generate" do
|
139
|
+
it "is created with sorted and unique filenames" do
|
140
140
|
assert_pathname_write "a\nb\nc\n" do
|
141
|
-
stub_backticks %w
|
141
|
+
stub_backticks %w[b a a a b c].join("\n") do
|
142
142
|
manifest.generate
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
describe
|
149
|
-
it
|
148
|
+
describe "#check" do
|
149
|
+
it "fails if there is no manifest_file" do
|
150
150
|
stub_manifest_file exists: false do
|
151
151
|
ex = assert_raises Cartage::Manifest::MissingError do
|
152
152
|
manifest.check
|
@@ -155,35 +155,33 @@ describe 'Cartage::Manifest' do
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
-
it
|
159
|
-
|
160
|
-
sysc = ->(*args) { IO.popen(args) { |diff| puts diff.read } }
|
158
|
+
it "compares the current files against the manifest" do
|
159
|
+
sysc = ->(*args) { IO.popen(args) { |diff| puts diff.read } }
|
161
160
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
161
|
+
assert_output(/^\+d/) do
|
162
|
+
instance_stub Kernel, :system, sysc do
|
163
|
+
stub_backticks %w[a b c].join("\n") do
|
164
|
+
manifest.instance_variable_set(:@manifest_file, Pathname("Manifest.test"))
|
165
|
+
manifest.generate
|
166
|
+
end
|
168
167
|
|
169
|
-
|
170
|
-
|
171
|
-
end
|
168
|
+
stub_backticks %w[a b c d].join("\n") do
|
169
|
+
manifest.check
|
172
170
|
end
|
173
171
|
end
|
174
|
-
ensure
|
175
|
-
file = manifest.send(:manifest_file)
|
176
|
-
file.unlink if file.to_s.end_with?('Manifest.test')
|
177
172
|
end
|
173
|
+
ensure
|
174
|
+
file = manifest.send(:manifest_file)
|
175
|
+
file.unlink if file.to_s.end_with?("Manifest.test")
|
178
176
|
end
|
179
177
|
end
|
180
178
|
|
181
|
-
describe
|
179
|
+
describe "#install_default_ignore" do
|
182
180
|
before do
|
183
181
|
cartage.verbose = true
|
184
182
|
end
|
185
183
|
|
186
|
-
it
|
184
|
+
it "does nothing if the ignore file exists without overwrite or merge" do
|
187
185
|
assert_output ".cartignore already exists, skipping...\n" do
|
188
186
|
stub_ignore_file do |ignore_file|
|
189
187
|
stub ignore_file, :write, ->(_) {} do
|
@@ -206,11 +204,11 @@ describe 'Cartage::Manifest' do
|
|
206
204
|
end
|
207
205
|
end
|
208
206
|
|
209
|
-
it
|
210
|
-
stub_ignore_file contents: %w
|
207
|
+
it "merges if mode is merge" do
|
208
|
+
stub_ignore_file contents: %w[xyz/] do |ignore_file|
|
211
209
|
stub ignore_file, :write, ignore_file_writer(%r{^xyz/.*vendor/bundle/$}m) do
|
212
210
|
assert_output "Merging .cartignore...\n" do
|
213
|
-
manifest.install_default_ignore(mode:
|
211
|
+
manifest.install_default_ignore(mode: "merge")
|
214
212
|
end
|
215
213
|
|
216
214
|
assert_instance_called ignore_file.class, :write
|
@@ -218,11 +216,11 @@ describe 'Cartage::Manifest' do
|
|
218
216
|
end
|
219
217
|
end
|
220
218
|
|
221
|
-
it
|
219
|
+
it "merges if mode is merge and ignore file is empty" do
|
222
220
|
stub_ignore_file contents: [] do |ignore_file|
|
223
221
|
stub ignore_file, :write, ignore_file_writer(%r{^# Some .*vendor/bundle/$}m) do
|
224
222
|
assert_output "Merging .cartignore...\n" do
|
225
|
-
manifest.install_default_ignore(mode:
|
223
|
+
manifest.install_default_ignore(mode: "merge")
|
226
224
|
end
|
227
225
|
|
228
226
|
assert_instance_called ignore_file.class, :write
|
@@ -230,11 +228,11 @@ describe 'Cartage::Manifest' do
|
|
230
228
|
end
|
231
229
|
end
|
232
230
|
|
233
|
-
it
|
234
|
-
stub_ignore_file contents: %w
|
231
|
+
it "forces when mode is force" do
|
232
|
+
stub_ignore_file contents: %w[xyz/] do |ignore_file|
|
235
233
|
stub ignore_file, :write, ignore_file_writer(%r{^# Some .*vendor/bundle/$}m) do
|
236
234
|
assert_output "Creating .cartignore...\n" do
|
237
|
-
manifest.install_default_ignore(mode:
|
235
|
+
manifest.install_default_ignore(mode: "force")
|
238
236
|
end
|
239
237
|
|
240
238
|
assert_instance_called ignore_file.class, :write
|
data/test/test_cartage_plugin.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "minitest_config"
|
4
|
+
|
5
|
+
class Cartage::Plugin::Test < ::Cartage::Plugin
|
6
|
+
def test
|
7
|
+
"test"
|
8
|
+
end
|
9
|
+
end
|
4
10
|
|
5
11
|
describe Cartage::Plugin do
|
6
12
|
let(:config) { Cartage::Config.load(:default) }
|
@@ -8,25 +14,19 @@ describe Cartage::Plugin do
|
|
8
14
|
let(:plugin) { Cartage::Plugin::Test }
|
9
15
|
let(:instance) { plugin.new(cartage) }
|
10
16
|
|
11
|
-
it
|
12
|
-
assert_raises_with_message NotImplementedError,
|
17
|
+
it "cannot be instantiated without being subclassed" do
|
18
|
+
assert_raises_with_message NotImplementedError, "not a subclass" do
|
13
19
|
Cartage::Plugin.new(cartage)
|
14
20
|
end
|
15
21
|
end
|
16
22
|
|
17
|
-
class Cartage::Plugin::Test < ::Cartage::Plugin
|
18
|
-
def test
|
19
|
-
'test'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
23
|
describe Cartage::Plugin::Test do
|
24
|
-
it
|
24
|
+
it "is enabled by default" do
|
25
25
|
assert_true instance.enabled?
|
26
26
|
assert_false instance.disabled?
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it "can be disabled by configuration" do
|
30
30
|
contents = {
|
31
31
|
plugins: {
|
32
32
|
test: {
|
@@ -37,7 +37,7 @@ describe Cartage::Plugin do
|
|
37
37
|
|
38
38
|
config = instance_stub Pathname, :read, -> { contents } do
|
39
39
|
instance_stub Pathname, :exist?, -> { true } do
|
40
|
-
Cartage::Config.load(
|
40
|
+
Cartage::Config.load("foo")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -46,14 +46,14 @@ describe Cartage::Plugin do
|
|
46
46
|
assert_true cartage.test.disabled?
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
49
|
+
it "has its configured feature offers" do
|
50
50
|
assert_true instance.offer?(:test)
|
51
51
|
assert_false instance.offer?(:other)
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
55
|
-
assert_equal
|
56
|
-
assert_equal
|
54
|
+
it "is named based on the class" do
|
55
|
+
assert_equal "test", instance.plugin_name
|
56
|
+
assert_equal "test", plugin.plugin_name
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -61,12 +61,12 @@ describe Cartage::Plugin do
|
|
61
61
|
let(:manifest) { Cartage::Manifest.new(cartage) }
|
62
62
|
let(:subject) { Cartage::Plugins.new.tap { |c| c.add(instance, manifest) } }
|
63
63
|
|
64
|
-
it
|
64
|
+
it "#enabled returns all enabled plugins" do
|
65
65
|
instance.define_singleton_method(:disabled?, -> { true })
|
66
66
|
assert_equal 1, subject.enabled.count
|
67
67
|
end
|
68
68
|
|
69
|
-
it
|
69
|
+
it "#request executes the named feature on found plug-ins" do
|
70
70
|
instance_stub Cartage::Plugin::Test, :test, -> {} do
|
71
71
|
subject.request(:test)
|
72
72
|
end
|
@@ -74,9 +74,9 @@ describe Cartage::Plugin do
|
|
74
74
|
assert_instance_called Cartage::Plugin::Test, :test, 1
|
75
75
|
end
|
76
76
|
|
77
|
-
it
|
78
|
-
instance_stub Cartage::Plugin::Test, :test, -> {
|
79
|
-
assert_equal %w
|
77
|
+
it "#request_map maps the named feature on found plug-ins" do
|
78
|
+
instance_stub Cartage::Plugin::Test, :test, -> { "TEST" } do
|
79
|
+
assert_equal %w[TEST], subject.request_map(:test)
|
80
80
|
end
|
81
81
|
|
82
82
|
assert_instance_called Cartage::Plugin::Test, :test, 1
|