monkeyhelper-jeweler 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/ChangeLog.markdown +83 -0
- data/LICENSE +20 -0
- data/README.markdown +170 -0
- data/ROADMAP +12 -0
- data/Rakefile +106 -0
- data/VERSION.yml +4 -0
- data/bin/jeweler +8 -0
- data/features/generator/cucumber.feature +83 -0
- data/features/generator/directory_layout.feature +76 -0
- data/features/generator/dotdocument.feature +14 -0
- data/features/generator/env_options.feature +9 -0
- data/features/generator/git.feature +94 -0
- data/features/generator/license.feature +11 -0
- data/features/generator/rakefile.feature +110 -0
- data/features/generator/readme.feature +12 -0
- data/features/generator/test.feature +41 -0
- data/features/generator/test_helper.feature +49 -0
- data/features/placeholder.feature +5 -0
- data/features/step_definitions/debug_steps.rb +6 -0
- data/features/step_definitions/filesystem_steps.rb +65 -0
- data/features/step_definitions/generator_steps.rb +251 -0
- data/features/step_definitions/task_steps.rb +6 -0
- data/features/support/env.rb +19 -0
- data/features/tasks/build_gem.feature +9 -0
- data/features/tasks/version.feature +24 -0
- data/features/tasks/version_bumping.feature +33 -0
- data/jeweler.gemspec +204 -0
- data/lib/jeweler.rb +142 -0
- data/lib/jeweler/commands.rb +12 -0
- data/lib/jeweler/commands/build_gem.rb +31 -0
- data/lib/jeweler/commands/install_gem.rb +26 -0
- data/lib/jeweler/commands/release.rb +83 -0
- data/lib/jeweler/commands/release_to_rubyforge.rb +51 -0
- data/lib/jeweler/commands/setup_rubyforge.rb +38 -0
- data/lib/jeweler/commands/validate_gemspec.rb +30 -0
- data/lib/jeweler/commands/version/base.rb +41 -0
- data/lib/jeweler/commands/version/bump_major.rb +13 -0
- data/lib/jeweler/commands/version/bump_minor.rb +12 -0
- data/lib/jeweler/commands/version/bump_patch.rb +14 -0
- data/lib/jeweler/commands/version/write.rb +12 -0
- data/lib/jeweler/commands/write_gemspec.rb +39 -0
- data/lib/jeweler/errors.rb +20 -0
- data/lib/jeweler/gemspec_helper.rb +76 -0
- data/lib/jeweler/generator.rb +284 -0
- data/lib/jeweler/generator/application.rb +54 -0
- data/lib/jeweler/generator/bacon_mixin.rb +39 -0
- data/lib/jeweler/generator/micronaut_mixin.rb +38 -0
- data/lib/jeweler/generator/minitest_mixin.rb +39 -0
- data/lib/jeweler/generator/options.rb +77 -0
- data/lib/jeweler/generator/rspec_mixin.rb +39 -0
- data/lib/jeweler/generator/shoulda_mixin.rb +39 -0
- data/lib/jeweler/generator/testunit_mixin.rb +39 -0
- data/lib/jeweler/rubyforge_tasks.rb +46 -0
- data/lib/jeweler/specification.rb +67 -0
- data/lib/jeweler/tasks.rb +124 -0
- data/lib/jeweler/templates/.document +5 -0
- data/lib/jeweler/templates/.gitignore +5 -0
- data/lib/jeweler/templates/LICENSE +20 -0
- data/lib/jeweler/templates/README.rdoc +7 -0
- data/lib/jeweler/templates/Rakefile +102 -0
- data/lib/jeweler/templates/bacon/flunking.rb +7 -0
- data/lib/jeweler/templates/bacon/helper.rb +8 -0
- data/lib/jeweler/templates/features/default.feature +9 -0
- data/lib/jeweler/templates/features/support/env.rb +8 -0
- data/lib/jeweler/templates/micronaut/flunking.rb +7 -0
- data/lib/jeweler/templates/micronaut/helper.rb +17 -0
- data/lib/jeweler/templates/minitest/flunking.rb +7 -0
- data/lib/jeweler/templates/minitest/helper.rb +11 -0
- data/lib/jeweler/templates/rspec/flunking.rb +7 -0
- data/lib/jeweler/templates/rspec/helper.rb +9 -0
- data/lib/jeweler/templates/shoulda/flunking.rb +7 -0
- data/lib/jeweler/templates/shoulda/helper.rb +10 -0
- data/lib/jeweler/templates/testunit/flunking.rb +7 -0
- data/lib/jeweler/templates/testunit/helper.rb +9 -0
- data/lib/jeweler/version_helper.rb +128 -0
- data/test/fixtures/bar/VERSION.yml +4 -0
- data/test/fixtures/bar/bin/foo_the_ultimate_bin +1 -0
- data/test/fixtures/bar/hey_include_me_in_gemspec +0 -0
- data/test/fixtures/bar/lib/foo_the_ultimate_lib.rb +1 -0
- data/test/fixtures/existing-project-with-version-plaintext/.document +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/LICENSE +20 -0
- data/test/fixtures/existing-project-with-version-plaintext/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +82 -0
- data/test/fixtures/existing-project-with-version-plaintext/VERSION +1 -0
- data/test/fixtures/existing-project-with-version-plaintext/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-plaintext/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-plaintext/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/test/test_helper.rb +10 -0
- data/test/fixtures/existing-project-with-version-yaml/.document +5 -0
- data/test/fixtures/existing-project-with-version-yaml/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-yaml/LICENSE +20 -0
- data/test/fixtures/existing-project-with-version-yaml/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +82 -0
- data/test/fixtures/existing-project-with-version-yaml/VERSION.yml +4 -0
- data/test/fixtures/existing-project-with-version-yaml/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-yaml/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-yaml/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-yaml/test/test_helper.rb +10 -0
- data/test/geminstaller.yml +12 -0
- data/test/jeweler/commands/test_build_gem.rb +72 -0
- data/test/jeweler/commands/test_install_gem.rb +21 -0
- data/test/jeweler/commands/test_release.rb +405 -0
- data/test/jeweler/commands/test_release_to_rubyforge.rb +157 -0
- data/test/jeweler/commands/test_setup_rubyforge.rb +88 -0
- data/test/jeweler/commands/test_validate_gemspec.rb +27 -0
- data/test/jeweler/commands/test_write_gemspec.rb +92 -0
- data/test/jeweler/commands/version/test_base.rb +32 -0
- data/test/jeweler/commands/version/test_bump_major.rb +22 -0
- data/test/jeweler/commands/version/test_bump_minor.rb +19 -0
- data/test/jeweler/commands/version/test_bump_patch.rb +20 -0
- data/test/jeweler/commands/version/test_write.rb +23 -0
- data/test/shoulda_macros/jeweler_macros.rb +35 -0
- data/test/test_application.rb +139 -0
- data/test/test_gemspec_helper.rb +40 -0
- data/test/test_generator.rb +154 -0
- data/test/test_generator_initialization.rb +113 -0
- data/test/test_generator_mixins.rb +18 -0
- data/test/test_helper.rb +133 -0
- data/test/test_jeweler.rb +174 -0
- data/test/test_options.rb +116 -0
- data/test/test_specification.rb +61 -0
- data/test/test_tasks.rb +51 -0
- data/test/test_version_helper.rb +153 -0
- metadata +228 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
module Commands
|
5
|
+
class TestSetupRubyforge < Test::Unit::TestCase
|
6
|
+
def self.subject
|
7
|
+
Jeweler::Commands::SetupRubyforge.new
|
8
|
+
end
|
9
|
+
|
10
|
+
rubyforge_command_context "rubyforge_project is defined in gemspec and package exists on rubyforge" do
|
11
|
+
setup do
|
12
|
+
stub(@rubyforge).configure
|
13
|
+
stub(@rubyforge).login
|
14
|
+
stub(@rubyforge).create_package('myproject', 'zomg')
|
15
|
+
|
16
|
+
stub(@gemspec).name { 'zomg' }
|
17
|
+
stub(@gemspec).rubyforge_project { 'myproject' }
|
18
|
+
|
19
|
+
@command.run
|
20
|
+
end
|
21
|
+
|
22
|
+
should "configure rubyforge" do
|
23
|
+
assert_received(@rubyforge) {|rubyforge| rubyforge.configure}
|
24
|
+
end
|
25
|
+
|
26
|
+
should "login to rubyforge" do
|
27
|
+
assert_received(@rubyforge) {|rubyforge| rubyforge.login}
|
28
|
+
end
|
29
|
+
|
30
|
+
should "create zomg package to myproject on rubyforge" do
|
31
|
+
assert_received(@rubyforge) {|rubyforge| rubyforge.create_package('myproject', 'zomg') }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
rubyforge_command_context "rubyforge_project not configured" do
|
36
|
+
setup do
|
37
|
+
stub(@gemspec).name { 'zomg' }
|
38
|
+
stub(@gemspec).rubyforge_project { nil }
|
39
|
+
end
|
40
|
+
|
41
|
+
should "raise NoRubyForgeProjectConfigured" do
|
42
|
+
assert_raises Jeweler::NoRubyForgeProjectInGemspecError do
|
43
|
+
@command.run
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
rubyforge_command_context "rubyforge project doesn't exist or not setup in ~/.rubyforge/autoconfig.yml" do
|
49
|
+
setup do
|
50
|
+
stub(@rubyforge).configure
|
51
|
+
stub(@rubyforge).login
|
52
|
+
stub(@rubyforge).create_package('some_project_that_doesnt_exist', 'zomg')do
|
53
|
+
raise RuntimeError, "no <group_id> configured for <some_project_that_doesnt_exist>"
|
54
|
+
end
|
55
|
+
|
56
|
+
stub(@gemspec).name { 'zomg' }
|
57
|
+
stub(@gemspec).rubyforge_project { 'some_project_that_doesnt_exist' }
|
58
|
+
end
|
59
|
+
|
60
|
+
should "raise RubyForgeProjectNotConfiguredError" do
|
61
|
+
assert_raises RubyForgeProjectNotConfiguredError do
|
62
|
+
@command.run
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
build_command_context "build for jeweler" do
|
69
|
+
setup do
|
70
|
+
@command = Jeweler::Commands::SetupRubyforge.build_for(@jeweler)
|
71
|
+
end
|
72
|
+
|
73
|
+
should "assign gemspec" do
|
74
|
+
assert_equal @gemspec, @command.gemspec
|
75
|
+
end
|
76
|
+
|
77
|
+
should "assign output" do
|
78
|
+
assert_equal @output, @command.output
|
79
|
+
end
|
80
|
+
|
81
|
+
should "assign rubyforge" do
|
82
|
+
assert_equal @rubyforge, @command.rubyforge
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
module Commands
|
5
|
+
class TestValidateGemspec < Test::Unit::TestCase
|
6
|
+
|
7
|
+
build_command_context "build context" do
|
8
|
+
setup do
|
9
|
+
@command = Jeweler::Commands::ValidateGemspec.build_for(@jeweler)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "assign gemspec_helper" do
|
13
|
+
assert_same @gemspec_helper, @command.gemspec_helper
|
14
|
+
end
|
15
|
+
|
16
|
+
should "assign output" do
|
17
|
+
assert_same @output, @command.output
|
18
|
+
end
|
19
|
+
|
20
|
+
should "return Jeweler::Commands::ValidateGemspec" do
|
21
|
+
assert_kind_of Jeweler::Commands::ValidateGemspec, @command
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
module Commands
|
5
|
+
class TestWriteGemspec < Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "after run" do
|
8
|
+
setup do
|
9
|
+
@gemspec = Gem::Specification.new {|s| s.name = 'zomg' }
|
10
|
+
@gemspec_helper = Object.new
|
11
|
+
stub(@gemspec_helper).spec { @gemspec }
|
12
|
+
stub(@gemspec_helper).path { 'zomg.gemspec' }
|
13
|
+
stub(@gemspec_helper).write
|
14
|
+
|
15
|
+
@output = StringIO.new
|
16
|
+
|
17
|
+
@version_helper = Object.new
|
18
|
+
stub(@version_helper).to_s { '1.2.3' }
|
19
|
+
stub(@version_helper).refresh
|
20
|
+
|
21
|
+
@command = Jeweler::Commands::WriteGemspec.new
|
22
|
+
@command.base_dir = 'tmp'
|
23
|
+
@command.version_helper = @version_helper
|
24
|
+
@command.gemspec = @gemspec
|
25
|
+
@command.output = @output
|
26
|
+
@command.gemspec_helper = @gemspec_helper
|
27
|
+
|
28
|
+
@now = Time.now
|
29
|
+
stub(Time.now).now { @now }
|
30
|
+
|
31
|
+
@command.run
|
32
|
+
end
|
33
|
+
|
34
|
+
should "refresh version" do
|
35
|
+
assert_received(@version_helper) {|version_helper| version_helper.refresh }
|
36
|
+
end
|
37
|
+
|
38
|
+
should "update gemspec version" do
|
39
|
+
assert_equal '1.2.3', @gemspec.version.to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
should "update gemspec date to the beginning of today" do
|
43
|
+
assert_equal Time.mktime(@now.year, @now.month, @now.day, 0, 0), @gemspec.date
|
44
|
+
end
|
45
|
+
|
46
|
+
should "write gemspec" do
|
47
|
+
assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.write }
|
48
|
+
end
|
49
|
+
|
50
|
+
should_eventually "output that the gemspec was written" do
|
51
|
+
assert_equal @output.string, "Generated: tmp/zomg.gemspec"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
build_command_context "building for jeweler" do
|
57
|
+
setup do
|
58
|
+
@command = Jeweler::Commands::WriteGemspec.build_for(@jeweler)
|
59
|
+
end
|
60
|
+
|
61
|
+
should "assign base_dir" do
|
62
|
+
assert_same @base_dir, @command.base_dir
|
63
|
+
end
|
64
|
+
|
65
|
+
should "assign gemspec" do
|
66
|
+
assert_same @gemspec, @command.gemspec
|
67
|
+
end
|
68
|
+
|
69
|
+
should "assign version" do
|
70
|
+
assert_same @version, @command.version
|
71
|
+
end
|
72
|
+
|
73
|
+
should "assign output" do
|
74
|
+
assert_same @output, @command.output
|
75
|
+
end
|
76
|
+
|
77
|
+
should "assign gemspec_helper" do
|
78
|
+
assert_same @gemspec_helper, @command.gemspec_helper
|
79
|
+
end
|
80
|
+
|
81
|
+
should "assign version_helper" do
|
82
|
+
assert_same @version_helper, @command.version_helper
|
83
|
+
end
|
84
|
+
|
85
|
+
should "return WriteGemspec" do
|
86
|
+
assert_kind_of Jeweler::Commands::WriteGemspec, @command
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
module Commands
|
5
|
+
module Version
|
6
|
+
class TestBase < Test::Unit::TestCase
|
7
|
+
build_command_context "build for jeweler" do
|
8
|
+
setup do
|
9
|
+
@command = Jeweler::Commands::Version::Base.build_for(@jeweler)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "assign repo" do
|
13
|
+
assert_equal @repo, @command.repo
|
14
|
+
end
|
15
|
+
|
16
|
+
should "assign version_helper" do
|
17
|
+
assert_equal @version_helper, @command.version_helper
|
18
|
+
end
|
19
|
+
|
20
|
+
should "assign gemspec" do
|
21
|
+
assert_equal @gemspec, @command.gemspec
|
22
|
+
end
|
23
|
+
|
24
|
+
should"assign commit" do
|
25
|
+
assert_equal @commit, @command.commit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
module Commands
|
5
|
+
module Version
|
6
|
+
class TestBumpMajor < Test::Unit::TestCase
|
7
|
+
|
8
|
+
should "call bump_major on version_helper in update_version" do
|
9
|
+
mock(version_helper = Object.new).bump_major
|
10
|
+
|
11
|
+
command = Jeweler::Commands::Version::BumpMajor.new
|
12
|
+
command.version_helper = version_helper
|
13
|
+
|
14
|
+
command.update_version
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
module Commands
|
5
|
+
module Version
|
6
|
+
class TestBumpMinor < Test::Unit::TestCase
|
7
|
+
|
8
|
+
should "call bump_minor on version_helper in update_version" do
|
9
|
+
mock(version_helper = Object.new).bump_minor
|
10
|
+
|
11
|
+
command = Jeweler::Commands::Version::BumpMinor.new
|
12
|
+
command.version_helper = version_helper
|
13
|
+
|
14
|
+
command.update_version
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
module Commands
|
5
|
+
module Version
|
6
|
+
class TestBumpPatch < Test::Unit::TestCase
|
7
|
+
|
8
|
+
should "call bump_patch on version_helper in update_version" do
|
9
|
+
mock(version_helper = Object.new).bump_patch
|
10
|
+
|
11
|
+
command = Jeweler::Commands::Version::BumpPatch.new
|
12
|
+
command.version_helper = version_helper
|
13
|
+
|
14
|
+
command.update_version
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
module Commands
|
5
|
+
module Version
|
6
|
+
class TestWrite < Test::Unit::TestCase
|
7
|
+
|
8
|
+
should "call write_version on version_helper in update_version" do
|
9
|
+
mock(version_helper = Object.new).update_to 1, 2, 3
|
10
|
+
|
11
|
+
command = Jeweler::Commands::Version::Write.new
|
12
|
+
command.version_helper = version_helper
|
13
|
+
command.major = 1
|
14
|
+
command.minor = 2
|
15
|
+
command.patch = 3
|
16
|
+
|
17
|
+
command.update_version
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Test::Unit::TestCase
|
2
|
+
class << self
|
3
|
+
def should_have_major_version(version)
|
4
|
+
should "have major version of #{version}" do
|
5
|
+
assert_equal version, @jeweler.major_version
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def should_have_minor_version(version)
|
10
|
+
should "have minor version of #{version}" do
|
11
|
+
assert_equal version, @jeweler.minor_version
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def should_have_patch_version(version)
|
16
|
+
should "have patch version of #{version}" do
|
17
|
+
assert_equal version, @jeweler.patch_version
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def should_be_version(version)
|
22
|
+
should "be version #{version}" do
|
23
|
+
assert_equal version, @jeweler.version
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def should_bump_version(major, minor, patch)
|
28
|
+
version = "#{major}.#{minor}.#{patch}"
|
29
|
+
should_have_major_version major
|
30
|
+
should_have_minor_version minor
|
31
|
+
should_have_patch_version patch
|
32
|
+
should_be_version version
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestApplication < Test::Unit::TestCase
|
4
|
+
def run_application(*arguments)
|
5
|
+
original_stdout = $stdout
|
6
|
+
original_stderr = $stderr
|
7
|
+
|
8
|
+
fake_stdout = StringIO.new
|
9
|
+
fake_stderr = StringIO.new
|
10
|
+
|
11
|
+
$stdout = fake_stdout
|
12
|
+
$stderr = fake_stderr
|
13
|
+
|
14
|
+
result = nil
|
15
|
+
begin
|
16
|
+
result = Jeweler::Generator::Application.run!(*arguments)
|
17
|
+
ensure
|
18
|
+
$stdout = original_stdout
|
19
|
+
$stderr = original_stderr
|
20
|
+
end
|
21
|
+
|
22
|
+
@stdout = fake_stdout.string
|
23
|
+
@stderr = fake_stderr.string
|
24
|
+
|
25
|
+
result
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.should_exit_with_code(code)
|
29
|
+
should "exit with code #{code}" do
|
30
|
+
assert_equal code, @result
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "called without any args" do
|
35
|
+
setup do
|
36
|
+
@result = run_application
|
37
|
+
end
|
38
|
+
|
39
|
+
should_exit_with_code 1
|
40
|
+
|
41
|
+
should 'display usage on stderr' do
|
42
|
+
assert_match 'Usage:', @stderr
|
43
|
+
end
|
44
|
+
|
45
|
+
should 'not display anything on stdout' do
|
46
|
+
assert_equal '', @stdout.squeeze.strip
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def build_generator(name = 'zomg', options = {:testing_framework => :shoulda})
|
51
|
+
stub.instance_of(Git::Lib).parse_config '~/.gitconfig' do
|
52
|
+
{'user.name' => 'John Doe', 'user.email' => 'john@example.com', 'github.user' => 'johndoe', 'github.token' => 'yyz'}
|
53
|
+
end
|
54
|
+
|
55
|
+
Jeweler::Generator.new(name, options)
|
56
|
+
end
|
57
|
+
|
58
|
+
context "called with -h" do
|
59
|
+
setup do
|
60
|
+
@generator = build_generator
|
61
|
+
stub(@generator).run
|
62
|
+
stub(Jeweler::Generator).new { raise "Shouldn't have made this far"}
|
63
|
+
|
64
|
+
assert_nothing_raised do
|
65
|
+
@result = run_application("-h")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
should_exit_with_code 1
|
70
|
+
|
71
|
+
should 'display usage on stderr' do
|
72
|
+
assert_match 'Usage:', @stderr
|
73
|
+
end
|
74
|
+
|
75
|
+
should 'not display anything on stdout' do
|
76
|
+
assert_equal '', @stdout.squeeze.strip
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "called with --invalid-argument" do
|
81
|
+
setup do
|
82
|
+
@generator = build_generator
|
83
|
+
stub(@generator).run
|
84
|
+
stub(Jeweler::Generator).new { raise "Shouldn't have made this far"}
|
85
|
+
|
86
|
+
assert_nothing_raised do
|
87
|
+
@result = run_application("--invalid-argument")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
should_exit_with_code 1
|
92
|
+
|
93
|
+
should 'display invalid argument' do
|
94
|
+
assert_match '--invalid-argument', @stderr
|
95
|
+
end
|
96
|
+
|
97
|
+
should 'display usage on stderr' do
|
98
|
+
assert_match 'Usage:', @stderr
|
99
|
+
end
|
100
|
+
|
101
|
+
should 'not display anything on stdout' do
|
102
|
+
assert_equal '', @stdout.squeeze.strip
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "when called with repo name" do
|
107
|
+
setup do
|
108
|
+
@options = {:testing_framework => :shoulda}
|
109
|
+
@generator = build_generator('zomg', @options)
|
110
|
+
|
111
|
+
stub(@generator).run
|
112
|
+
stub(Jeweler::Generator).new { @generator }
|
113
|
+
end
|
114
|
+
|
115
|
+
should 'return exit code 0' do
|
116
|
+
result = run_application("zomg")
|
117
|
+
assert_equal 0, result
|
118
|
+
end
|
119
|
+
|
120
|
+
should 'create generator with repo name and no options' do
|
121
|
+
run_application("zomg")
|
122
|
+
|
123
|
+
assert_received Jeweler::Generator do |subject|
|
124
|
+
subject.new('zomg', @options)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
should 'run generator' do
|
129
|
+
run_application("zomg")
|
130
|
+
|
131
|
+
assert_received(@generator) {|subject| subject.run }
|
132
|
+
end
|
133
|
+
|
134
|
+
should 'not display usage on stderr' do
|
135
|
+
assert_no_match /Usage:/, @stderr
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|