rubygems-tasks 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +31 -0
  3. data/.gitignore +4 -2
  4. data/ChangeLog.md +20 -0
  5. data/Gemfile +12 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.md +114 -80
  8. data/Rakefile +6 -20
  9. data/gemspec.yml +13 -5
  10. data/lib/rubygems/tasks/build/gem.rb +5 -6
  11. data/lib/rubygems/tasks/build/tar.rb +5 -6
  12. data/lib/rubygems/tasks/build/task.rb +4 -2
  13. data/lib/rubygems/tasks/build/zip.rb +5 -6
  14. data/lib/rubygems/tasks/build.rb +61 -3
  15. data/lib/rubygems/tasks/console.rb +13 -10
  16. data/lib/rubygems/tasks/install.rb +4 -5
  17. data/lib/rubygems/tasks/printing.rb +2 -0
  18. data/lib/rubygems/tasks/project.rb +3 -1
  19. data/lib/rubygems/tasks/push.rb +20 -7
  20. data/lib/rubygems/tasks/release.rb +4 -5
  21. data/lib/rubygems/tasks/scm/push.rb +5 -6
  22. data/lib/rubygems/tasks/scm/status.rb +5 -6
  23. data/lib/rubygems/tasks/scm/tag.rb +9 -12
  24. data/lib/rubygems/tasks/scm.rb +52 -3
  25. data/lib/rubygems/tasks/sign/checksum.rb +21 -14
  26. data/lib/rubygems/tasks/sign/pgp.rb +5 -6
  27. data/lib/rubygems/tasks/sign/task.rb +4 -2
  28. data/lib/rubygems/tasks/sign.rb +42 -2
  29. data/lib/rubygems/tasks/task.rb +11 -3
  30. data/lib/rubygems/tasks.rb +67 -66
  31. data/rubygems-tasks.gemspec +1 -0
  32. data/spec/build_spec.rb +72 -0
  33. data/spec/console_spec.rb +45 -18
  34. data/spec/install_spec.rb +5 -1
  35. data/spec/project_spec.rb +19 -19
  36. data/spec/push_spec.rb +15 -3
  37. data/spec/scm/push_spec.rb +6 -6
  38. data/spec/scm/status_spec.rb +8 -12
  39. data/spec/scm/tag_spec.rb +18 -28
  40. data/spec/scm_spec.rb +72 -0
  41. data/spec/sign/pgp_spec.rb +1 -1
  42. data/spec/sign_spec.rb +52 -0
  43. data/spec/tasks_spec.rb +18 -191
  44. metadata +32 -26
data/spec/console_spec.rb CHANGED
@@ -13,15 +13,24 @@ describe Gem::Tasks::Console do
13
13
  let(:custom_options) { %w[-Ivendor -rfoo] }
14
14
 
15
15
  context "defaults" do
16
- it "should run `irb`" do
17
- expect(subject).to receive(:run).with('irb',*default_options)
16
+ context "when the project does not use Bundler" do
17
+ before do
18
+ allow(subject.project).to receive(:bundler?).and_return(false)
19
+ end
20
+
21
+ it "must run `irb`" do
22
+ expect(subject).to receive(:run).with('irb',*default_options)
18
23
 
19
- subject.console
24
+ subject.console
25
+ end
20
26
  end
21
27
 
22
- context "when project.bundler? == true" do
23
- it "should use `bundle exec`" do
28
+ context "when the project does use Bundler" do
29
+ before do
24
30
  allow(subject.project).to receive(:bundler?).and_return(true)
31
+ end
32
+
33
+ it "must use `bundle exec`" do
25
34
  expect(subject).to receive(:run).with(
26
35
  'bundle', 'exec', 'irb', *default_options
27
36
  )
@@ -31,18 +40,27 @@ describe Gem::Tasks::Console do
31
40
  end
32
41
  end
33
42
 
34
- context "with custom command" do
35
- subject { described_class.new(:command => custom_command) }
43
+ context "with a custom command" do
44
+ subject { described_class.new(command: custom_command) }
45
+
46
+ context "when the project does not use Bundler" do
47
+ before do
48
+ allow(subject.project).to receive(:bundler?).and_return(false)
49
+ end
36
50
 
37
- it "should run the custom console" do
38
- expect(subject).to receive(:run).with(custom_command,*default_options)
51
+ it "must run the custom console" do
52
+ expect(subject).to receive(:run).with(custom_command,*default_options)
39
53
 
40
- subject.console
54
+ subject.console
55
+ end
41
56
  end
42
57
 
43
- context "when project.bundler? == true" do
44
- it "should use `bundle exec`" do
58
+ context "when the project does use Bundler" do
59
+ before do
45
60
  allow(subject.project).to receive(:bundler?).and_return(true)
61
+ end
62
+
63
+ it "must use `bundle exec`" do
46
64
  expect(subject).to receive(:run).with(
47
65
  'bundle', 'exec', custom_command, *default_options
48
66
  )
@@ -53,17 +71,26 @@ describe Gem::Tasks::Console do
53
71
  end
54
72
 
55
73
  context "with custom options" do
56
- subject { described_class.new(:options => custom_options) }
74
+ subject { described_class.new(options: custom_options) }
75
+
76
+ context "when the project does not use Bundler" do
77
+ before do
78
+ allow(subject.project).to receive(:bundler?).and_return(false)
79
+ end
57
80
 
58
- it "should pass custom options to `irb`" do
59
- expect(subject).to receive(:run).with('irb', *(default_options + custom_options))
81
+ it "must pass custom options to `irb`" do
82
+ expect(subject).to receive(:run).with('irb', *(default_options + custom_options))
60
83
 
61
- subject.console
84
+ subject.console
85
+ end
62
86
  end
63
87
 
64
- context "when project.bundler? == true" do
65
- it "should use `bundle exec ...`" do
88
+ context "when the project does use Bundler" do
89
+ before do
66
90
  allow(subject.project).to receive(:bundler?).and_return(true)
91
+ end
92
+
93
+ it "must use `bundle exec ...`" do
67
94
  expect(subject).to receive(:run).with('bundle', 'exec', 'irb', *(default_options + custom_options))
68
95
 
69
96
  subject.console
data/spec/install_spec.rb CHANGED
@@ -7,7 +7,11 @@ describe Gem::Tasks::Install do
7
7
  describe "#install" do
8
8
  let(:path) { 'pkg/foo-1.2.3.gem' }
9
9
 
10
- it "should use `gem install -q`" do
10
+ it "must use `gem install -q`" do
11
+ if defined?(Bundler)
12
+ expect(Bundler).to receive(:with_original_env).and_yield()
13
+ end
14
+
11
15
  expect(subject).to receive(:run).with('gem', 'install', '-q', path)
12
16
 
13
17
  subject.install(path)
data/spec/project_spec.rb CHANGED
@@ -3,7 +3,7 @@ require 'rubygems/tasks/project'
3
3
 
4
4
  describe Gem::Tasks::Project do
5
5
  let(:rubygems_project_dir) { File.join(PROJECTS_DIR,'rubygems-project') }
6
- let(:rubygems_project) { described_class.new(rubygems_project_dir) }
6
+ let(:rubygems_project) { described_class.new(rubygems_project_dir) }
7
7
 
8
8
  let(:rubygems_multi_project_dir) do
9
9
  File.join(PROJECTS_DIR,'rubygems-multi-project')
@@ -14,12 +14,12 @@ describe Gem::Tasks::Project do
14
14
  end
15
15
 
16
16
  let(:bundler_project_dir) { File.join(PROJECTS_DIR,'bundler-project') }
17
- let(:bundler_project) { described_class.new(bundler_project_dir) }
17
+ let(:bundler_project) { described_class.new(bundler_project_dir) }
18
18
 
19
19
  describe "directories" do
20
20
  let(:directory) { rubygems_project_dir }
21
21
 
22
- it "should map paths to #{described_class} instances" do
22
+ it "must map paths to #{described_class} instances" do
23
23
  project = described_class.directories[directory]
24
24
 
25
25
  expect(project.root).to eq(directory)
@@ -29,7 +29,7 @@ describe Gem::Tasks::Project do
29
29
  describe "#name" do
30
30
  subject { rubygems_project }
31
31
 
32
- it "should use the name of the directory" do
32
+ it "must use the name of the directory" do
33
33
  expect(subject.name).to eq('rubygems-project')
34
34
  end
35
35
  end
@@ -37,7 +37,7 @@ describe Gem::Tasks::Project do
37
37
  describe "#scm" do
38
38
  subject { bundler_project }
39
39
 
40
- it "should detect the SCM used" do
40
+ it "must detect the SCM used" do
41
41
  expect(subject.scm).to eq(:git)
42
42
  end
43
43
  end
@@ -46,7 +46,7 @@ describe Gem::Tasks::Project do
46
46
  context "with single-gemspec project" do
47
47
  subject { rubygems_project }
48
48
 
49
- it "should load the single-gemspec" do
49
+ it "must load the single-gemspec" do
50
50
  expect(subject.gemspecs.values.map(&:name)).to eq(%w[rubygems-project])
51
51
  end
52
52
  end
@@ -54,7 +54,7 @@ describe Gem::Tasks::Project do
54
54
  context "with multi-gemspec project" do
55
55
  subject { rubygems_multi_project }
56
56
 
57
- it "should load all gemspecs" do
57
+ it "must load all gemspecs" do
58
58
  expect(subject.gemspecs.values.map(&:name)).to match_array(%w[
59
59
  rubygems-project
60
60
  rubygems-project-lite
@@ -67,7 +67,7 @@ describe Gem::Tasks::Project do
67
67
  context "with single-gemspec project" do
68
68
  subject { rubygems_project }
69
69
 
70
- it "should match the directory name to the gemspec" do
70
+ it "must match the directory name to the gemspec" do
71
71
  expect(subject.primary_gemspec).to eq(subject.name)
72
72
  end
73
73
  end
@@ -75,7 +75,7 @@ describe Gem::Tasks::Project do
75
75
  context "with multi-gemspec project" do
76
76
  subject { rubygems_multi_project }
77
77
 
78
- it "should pick the first gemspec" do
78
+ it "must pick the first gemspec" do
79
79
  expect(subject.primary_gemspec).to eq('rubygems-project')
80
80
  end
81
81
  end
@@ -85,11 +85,11 @@ describe Gem::Tasks::Project do
85
85
  context "with single-gemspec project" do
86
86
  subject { rubygems_project }
87
87
 
88
- it "should default the directory name to the gemspec" do
88
+ it "must default the directory name to the gemspec" do
89
89
  expect(subject.gemspec.name).to eq(subject.name)
90
90
  end
91
91
 
92
- it "should raise an ArgumentError for unknown gemspec names" do
92
+ it "must raise an ArgumentError for unknown gemspec names" do
93
93
  expect { subject.gemspec('foo') }.to raise_error(ArgumentError)
94
94
  end
95
95
  end
@@ -97,11 +97,11 @@ describe Gem::Tasks::Project do
97
97
  context "with multi-gemspec project" do
98
98
  subject { rubygems_multi_project }
99
99
 
100
- it "should default the first gemspec" do
100
+ it "must default the first gemspec" do
101
101
  expect(subject.gemspec.name).to eq('rubygems-project')
102
102
  end
103
103
 
104
- it "should allow accessing alternate gemspecs" do
104
+ it "must allow accessing alternate gemspecs" do
105
105
  alternate = 'rubygems-project-lite'
106
106
 
107
107
  expect(subject.gemspec(alternate).name).to eq(alternate)
@@ -112,11 +112,11 @@ describe Gem::Tasks::Project do
112
112
  describe "#builds" do
113
113
  subject { rubygems_multi_project }
114
114
 
115
- it "should group builds by gemspec name" do
115
+ it "must group builds by gemspec name" do
116
116
  expect(subject.builds.keys).to be == subject.gemspecs.keys
117
117
  end
118
118
 
119
- it "should map a package format to a pkg/ path" do
119
+ it "must map a package format to a pkg/ path" do
120
120
  packages = subject.builds['rubygems-project']
121
121
 
122
122
  expect(packages['tar.gz']).to eq('pkg/rubygems-project-1.2.3.tar.gz')
@@ -125,7 +125,7 @@ describe Gem::Tasks::Project do
125
125
  context "with single-gemspec project" do
126
126
  subject { rubygems_project }
127
127
 
128
- it "should only have a key for the single-gemspec" do
128
+ it "must only have a key for the single-gemspec" do
129
129
  expect(subject.builds.keys).to eq(%w[rubygems-project])
130
130
  end
131
131
  end
@@ -133,7 +133,7 @@ describe Gem::Tasks::Project do
133
133
  context "with multi-gemspec project" do
134
134
  subject { rubygems_multi_project }
135
135
 
136
- it "should have keys for each gemspec" do
136
+ it "must have keys for each gemspec" do
137
137
  expect(subject.builds.keys).to match_array(%w[
138
138
  rubygems-project
139
139
  rubygems-project-lite
@@ -146,7 +146,7 @@ describe Gem::Tasks::Project do
146
146
  context "with Bundler" do
147
147
  subject { bundler_project }
148
148
 
149
- it "should detect the 'Gemfile' file" do
149
+ it "must detect the 'Gemfile' file" do
150
150
  expect(subject.bundler?).to be_truthy
151
151
  end
152
152
  end
@@ -154,7 +154,7 @@ describe Gem::Tasks::Project do
154
154
  context "without Bundler" do
155
155
  subject { rubygems_project }
156
156
 
157
- it "should be false" do
157
+ it "must be false" do
158
158
  expect(subject.bundler?).to be_falsey
159
159
  end
160
160
  end
data/spec/push_spec.rb CHANGED
@@ -10,7 +10,7 @@ describe Gem::Tasks::Push do
10
10
  let(:path) { 'pkg/foo-1.2.3.gem' }
11
11
 
12
12
  context "defaults" do
13
- it "should use `gem push`" do
13
+ it "must use `gem push`" do
14
14
  expect(subject).to receive(:run).with('gem', 'push', path)
15
15
 
16
16
  subject.push(path)
@@ -20,13 +20,25 @@ describe Gem::Tasks::Push do
20
20
  context "with custom :host" do
21
21
  let(:host) { 'internal.company.com' }
22
22
 
23
- subject { described_class.new(:host => host) }
23
+ subject { described_class.new(host: host) }
24
24
 
25
- it "should include the --host option" do
25
+ it "must include the --host option" do
26
26
  expect(subject).to receive(:run).with('gem', 'push', path, '--host', host)
27
27
 
28
28
  subject.push(path)
29
29
  end
30
30
  end
31
+
32
+ context "with custom :key" do
33
+ let(:key) { '098f6bcd4621d373cade4e832627b4f6' }
34
+
35
+ subject { described_class.new(key: key) }
36
+
37
+ it "should include the --key option" do
38
+ expect(subject).to receive(:run).with('gem', 'push', path, '--key', key)
39
+
40
+ subject.push(path)
41
+ end
42
+ end
31
43
  end
32
44
  end
@@ -5,8 +5,8 @@ require 'rubygems/tasks/scm/push'
5
5
 
6
6
  describe Gem::Tasks::SCM::Push do
7
7
  describe "#push!" do
8
- context "git" do
9
- it "should run `git push --tags`" do
8
+ context "when the project's SCM type is :git" do
9
+ it "must run `git push --tags`" do
10
10
  allow(subject.project).to receive(:scm).and_return(:git)
11
11
  expect(subject).to receive(:run).with('git', 'push')
12
12
  expect(subject).to receive(:run).with('git', 'push', '--tags')
@@ -15,8 +15,8 @@ describe Gem::Tasks::SCM::Push do
15
15
  end
16
16
  end
17
17
 
18
- context "hg" do
19
- it "should run `hg push`" do
18
+ context "when the project's SCM type is :hg" do
19
+ it "must run `hg push`" do
20
20
  allow(subject.project).to receive(:scm).and_return(:hg)
21
21
  expect(subject).to receive(:run).with('hg', 'push')
22
22
 
@@ -24,8 +24,8 @@ describe Gem::Tasks::SCM::Push do
24
24
  end
25
25
  end
26
26
 
27
- context "otherwise" do
28
- it "should return true" do
27
+ context "when the project's SCM type is :svn" do
28
+ it "must return true" do
29
29
  allow(subject.project).to receive(:scm).and_return(:svn)
30
30
 
31
31
  expect(subject.push!).to eq(true)
@@ -4,11 +4,11 @@ require 'rake_context'
4
4
  require 'rubygems/tasks/scm/status'
5
5
 
6
6
  describe Gem::Tasks::SCM::Status do
7
- describe "#status" do
8
- context "git" do
9
- include_context "rake"
7
+ include_context "rake"
10
8
 
11
- it "should run `git status --untracked-files=no`" do
9
+ describe "#status" do
10
+ context "when the project's SCM type is :git" do
11
+ it "must run `git status --untracked-files=no`" do
12
12
  allow(subject.project).to receive(:scm).and_return(:git)
13
13
 
14
14
  expect(subject).to receive(:run).with(
@@ -19,10 +19,8 @@ describe Gem::Tasks::SCM::Status do
19
19
  end
20
20
  end
21
21
 
22
- context "hg" do
23
- include_context "rake"
24
-
25
- it "should run `hg status --quiet`" do
22
+ context "when the project's SCM type is :hg" do
23
+ it "must run `hg status --quiet`" do
26
24
  allow(subject.project).to receive(:scm).and_return(:hg)
27
25
 
28
26
  expect(subject).to receive(:run).with(
@@ -33,10 +31,8 @@ describe Gem::Tasks::SCM::Status do
33
31
  end
34
32
  end
35
33
 
36
- context "svn" do
37
- include_context "rake"
38
-
39
- it "should run `svn status --quiet`" do
34
+ context "when the project's SCM type is :svn" do
35
+ it "must run `svn status --quiet`" do
40
36
  allow(subject.project).to receive(:scm).and_return(:svn)
41
37
 
42
38
  expect(subject).to receive(:run).with(
data/spec/scm/tag_spec.rb CHANGED
@@ -4,35 +4,33 @@ require 'rake_context'
4
4
  require 'rubygems/tasks/scm/tag'
5
5
 
6
6
  describe Gem::Tasks::SCM::Tag do
7
+ include_context "rake"
8
+
7
9
  let(:version) { '1.2.3' }
8
10
 
9
11
  describe "#version_tag" do
10
- context "defaults" do
11
- include_context "rake"
12
-
13
- it "should have a 'v' prefix" do
12
+ context "when #format is #{described_class}::DEFAULT_FORMAT" do
13
+ it "must have a 'v' prefix" do
14
14
  expect(subject.version_tag(version)).to eq("v#{version}")
15
15
  end
16
16
  end
17
17
 
18
- context "with format String" do
19
- include_context "rake"
20
-
18
+ context "when #format is a format String" do
21
19
  let(:format) { 'release-%s' }
22
20
 
23
21
  subject { described_class.new(format: format) }
24
22
 
25
- it "should apply the format String to the version" do
23
+ it "must apply the format String to the version" do
26
24
  expect(subject.version_tag(version)).to eq("release-#{version}")
27
25
  end
28
26
  end
29
27
 
30
- context "with format Proc" do
28
+ context "when #format is a Proc" do
31
29
  let(:format) { proc { |ver| "REL_" + ver.tr('.','_') } }
32
30
 
33
31
  subject { described_class.new(format: format) }
34
32
 
35
- it "should call the format Proc with the version" do
33
+ it "must call the format Proc with the version" do
36
34
  expect(subject.version_tag(version)).to eq("REL_1_2_3")
37
35
  end
38
36
  end
@@ -42,13 +40,11 @@ describe Gem::Tasks::SCM::Tag do
42
40
  let(:name) { "v#{version}" }
43
41
  let(:message) { "Tagging #{name}" }
44
42
 
45
- context "git" do
46
- context "without signing" do
47
- include_context "rake"
48
-
43
+ context "when the project's SCM type is :git" do
44
+ context "but signing is disabled" do
49
45
  subject { described_class.new(sign: false) }
50
46
 
51
- it "should run `git tag`" do
47
+ it "must run `git tag`" do
52
48
  allow(subject.project).to receive(:scm).and_return(:git)
53
49
 
54
50
  expect(subject).to receive(:run).with(
@@ -59,12 +55,10 @@ describe Gem::Tasks::SCM::Tag do
59
55
  end
60
56
  end
61
57
 
62
- context "signing" do
63
- include_context "rake"
64
-
58
+ context "and signing is enabled" do
65
59
  subject { described_class.new(sign: true) }
66
60
 
67
- it "should run `git tag -s`" do
61
+ it "must run `git tag -s`" do
68
62
  allow(subject.project).to receive(:scm).and_return(:git)
69
63
 
70
64
  expect(subject).to receive(:run).with(
@@ -76,13 +70,11 @@ describe Gem::Tasks::SCM::Tag do
76
70
  end
77
71
  end
78
72
 
79
- context "hg" do
80
- context "without signing" do
81
- include_context "rake"
82
-
73
+ context "when the project's SCM type is :hg" do
74
+ context "but signing is disabled" do
83
75
  subject { described_class.new(sign: false) }
84
76
 
85
- it "should run `hg tag`" do
77
+ it "must run `hg tag`" do
86
78
  allow(subject.project).to receive(:scm).and_return(:hg)
87
79
 
88
80
  expect(subject).to receive(:run).with(
@@ -93,12 +85,10 @@ describe Gem::Tasks::SCM::Tag do
93
85
  end
94
86
  end
95
87
 
96
- context "with signing" do
97
- include_context "rake"
98
-
88
+ context "and signing is enabled" do
99
89
  subject { described_class.new(sign: true) }
100
90
 
101
- it "should run `hg sign` then `hg tag`" do
91
+ it "must run `hg sign` then `hg tag`" do
102
92
  allow(subject.project).to receive(:scm).and_return(:hg)
103
93
 
104
94
  expect(subject).to receive(:run).with(
data/spec/scm_spec.rb ADDED
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+ require 'rake_context'
3
+
4
+ require 'rubygems/tasks/scm'
5
+
6
+ describe Gem::Tasks::SCM do
7
+ include_context "rake"
8
+
9
+ describe "#initialize" do
10
+ context "when given no keyword arguments" do
11
+ it "must initialize #status by default" do
12
+ expect(subject.status).to be_a(Gem::Tasks::SCM::Status)
13
+ end
14
+
15
+ it "must initialize #tag by default" do
16
+ expect(subject.tag).to be_a(Gem::Tasks::SCM::Tag)
17
+ end
18
+
19
+ it "must initialize #push by default" do
20
+ expect(subject.push).to be_a(Gem::Tasks::SCM::Push)
21
+ end
22
+ end
23
+
24
+ context "when given `status: true`" do
25
+ subject { described_class.new(status: true) }
26
+
27
+ it "must initialize #status" do
28
+ expect(subject.status).to be_a(Gem::Tasks::SCM::Status)
29
+ end
30
+ end
31
+
32
+ context "when given `status: false`" do
33
+ subject { described_class.new(status: false) }
34
+
35
+ it "must not initialize #status" do
36
+ expect(subject.status).to be(nil)
37
+ end
38
+ end
39
+
40
+ context "when given `tag: true`" do
41
+ subject { described_class.new(tag: true) }
42
+
43
+ it "must initialize #tag" do
44
+ expect(subject.tag).to be_a(Gem::Tasks::SCM::Tag)
45
+ end
46
+ end
47
+
48
+ context "when given `tag: false`" do
49
+ subject { described_class.new(tag: false) }
50
+
51
+ it "must not initialize #tag" do
52
+ expect(subject.tag).to be(nil)
53
+ end
54
+ end
55
+
56
+ context "when given `push: true`" do
57
+ subject { described_class.new(push: true) }
58
+
59
+ it "must initialize #push" do
60
+ expect(subject.push).to be_a(Gem::Tasks::SCM::Push)
61
+ end
62
+ end
63
+
64
+ context "when given `push: false`" do
65
+ subject { described_class.new(push: false) }
66
+
67
+ it "must not initialize #push" do
68
+ expect(subject.push).to be(nil)
69
+ end
70
+ end
71
+ end
72
+ end
@@ -9,7 +9,7 @@ describe Gem::Tasks::Sign::PGP do
9
9
 
10
10
  let(:path) { File.join('pkg','foo-1.2.3.gem') }
11
11
 
12
- it "should run `gpg --sign --detach-sign --armor ...`" do
12
+ it "must run `gpg --sign --detach-sign --armor ...`" do
13
13
  expect(subject).to receive(:run).with(
14
14
  'gpg', '--sign', '--detach-sign', '--armor', path
15
15
  )
data/spec/sign_spec.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'rake_context'
3
+
4
+ require 'rubygems/tasks/sign'
5
+
6
+ describe Gem::Tasks::Sign do
7
+ include_context "rake"
8
+
9
+ describe "#initialize" do
10
+ context "when given no keyword arguments" do
11
+ it "must not initialize #checksum by default" do
12
+ expect(subject.checksum).to be(nil)
13
+ end
14
+
15
+ it "must not initialize #pgp by default" do
16
+ expect(subject.pgp).to be(nil)
17
+ end
18
+ end
19
+
20
+ context "when given `checksum: true`" do
21
+ subject { described_class.new(checksum: true) }
22
+
23
+ it "must initialize #checksum" do
24
+ expect(subject.checksum).to be_a(Gem::Tasks::Sign::Checksum)
25
+ end
26
+ end
27
+
28
+ context "when given `checksum: false`" do
29
+ subject { described_class.new(checksum: false) }
30
+
31
+ it "must not initialize #checksum" do
32
+ expect(subject.checksum).to be(nil)
33
+ end
34
+ end
35
+
36
+ context "when given `pgp: true`" do
37
+ subject { described_class.new(pgp: true) }
38
+
39
+ it "must initialize #pgp" do
40
+ expect(subject.pgp).to be_a(Gem::Tasks::Sign::PGP)
41
+ end
42
+ end
43
+
44
+ context "when given `pgp: false`" do
45
+ subject { described_class.new(pgp: false) }
46
+
47
+ it "must not initialize #pgp" do
48
+ expect(subject.pgp).to be(nil)
49
+ end
50
+ end
51
+ end
52
+ end