juwelier 2.1.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/.coveralls.yml +2 -0
- data/.document +8 -0
- data/.semver +5 -0
- data/.travis.yml +7 -0
- data/.yardopts +2 -0
- data/ChangeLog.markdown +230 -0
- data/Gemfile +40 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +252 -0
- data/Rakefile +78 -0
- data/bin/juwelier +9 -0
- data/features/generator/cucumber.feature +103 -0
- data/features/generator/directory_layout.feature +86 -0
- data/features/generator/dotdocument.feature +13 -0
- data/features/generator/env_options.feature +9 -0
- data/features/generator/gemfile.feature +81 -0
- data/features/generator/git.feature +102 -0
- data/features/generator/license.feature +20 -0
- data/features/generator/rakefile.feature +158 -0
- data/features/generator/readme.feature +12 -0
- data/features/generator/test.feature +54 -0
- data/features/generator/test_helper.feature +149 -0
- data/features/placeholder.feature +5 -0
- data/features/step_definitions/debug_steps.rb +6 -0
- data/features/step_definitions/filesystem_steps.rb +70 -0
- data/features/step_definitions/generator_steps.rb +387 -0
- data/features/step_definitions/task_steps.rb +6 -0
- data/features/support/env.rb +41 -0
- data/features/tasks/build_gem.feature +9 -0
- data/features/tasks/version.feature +31 -0
- data/features/tasks/version_bumping.feature +49 -0
- data/juwelier.gemspec +241 -0
- data/lib/juwelier.rb +178 -0
- data/lib/juwelier/commands.rb +20 -0
- data/lib/juwelier/commands/build_gem.rb +40 -0
- data/lib/juwelier/commands/check_dependencies.rb +66 -0
- data/lib/juwelier/commands/install_gem.rb +31 -0
- data/lib/juwelier/commands/release_gemspec.rb +87 -0
- data/lib/juwelier/commands/release_to_git.rb +64 -0
- data/lib/juwelier/commands/release_to_rubygems.rb +28 -0
- data/lib/juwelier/commands/validate_gemspec.rb +30 -0
- data/lib/juwelier/commands/version/base.rb +55 -0
- data/lib/juwelier/commands/version/bump_major.rb +13 -0
- data/lib/juwelier/commands/version/bump_minor.rb +12 -0
- data/lib/juwelier/commands/version/bump_patch.rb +14 -0
- data/lib/juwelier/commands/version/write.rb +12 -0
- data/lib/juwelier/commands/write_gemspec.rb +39 -0
- data/lib/juwelier/errors.rb +8 -0
- data/lib/juwelier/gemcutter_tasks.rb +8 -0
- data/lib/juwelier/gemspec_helper.rb +87 -0
- data/lib/juwelier/generator.rb +304 -0
- data/lib/juwelier/generator/application.rb +63 -0
- data/lib/juwelier/generator/bacon_mixin.rb +43 -0
- data/lib/juwelier/generator/github_mixin.rb +22 -0
- data/lib/juwelier/generator/micronaut_mixin.rb +41 -0
- data/lib/juwelier/generator/minitest_mixin.rb +42 -0
- data/lib/juwelier/generator/options.rb +172 -0
- data/lib/juwelier/generator/rdoc_mixin.rb +13 -0
- data/lib/juwelier/generator/riot_mixin.rb +42 -0
- data/lib/juwelier/generator/rspec_mixin.rb +42 -0
- data/lib/juwelier/generator/shindo_mixin.rb +44 -0
- data/lib/juwelier/generator/shoulda_mixin.rb +42 -0
- data/lib/juwelier/generator/testspec_mixin.rb +42 -0
- data/lib/juwelier/generator/testunit_mixin.rb +39 -0
- data/lib/juwelier/generator/yard_mixin.rb +15 -0
- data/lib/juwelier/rubyforge_tasks.rb +95 -0
- data/lib/juwelier/rubygems_dot_org_tasks.rb +38 -0
- data/lib/juwelier/rubygems_tasks.rb +38 -0
- data/lib/juwelier/specification.rb +110 -0
- data/lib/juwelier/tasks.rb +239 -0
- data/lib/juwelier/templates/.document +5 -0
- data/lib/juwelier/templates/.gitignore +49 -0
- data/lib/juwelier/templates/Gemfile +12 -0
- data/lib/juwelier/templates/LICENSE.txt +20 -0
- data/lib/juwelier/templates/README.rdoc +19 -0
- data/lib/juwelier/templates/Rakefile +9 -0
- data/lib/juwelier/templates/bacon/flunking.rb +7 -0
- data/lib/juwelier/templates/bacon/helper.rb +10 -0
- data/lib/juwelier/templates/bundler_setup.erb +10 -0
- data/lib/juwelier/templates/features/default.feature +9 -0
- data/lib/juwelier/templates/features/support/env.rb +11 -0
- data/lib/juwelier/templates/juwelier_tasks.erb +31 -0
- data/lib/juwelier/templates/micronaut/flunking.rb +7 -0
- data/lib/juwelier/templates/micronaut/helper.rb +19 -0
- data/lib/juwelier/templates/minitest/flunking.rb +7 -0
- data/lib/juwelier/templates/minitest/helper.rb +13 -0
- data/lib/juwelier/templates/other_tasks.erb +70 -0
- data/lib/juwelier/templates/riot/flunking.rb +11 -0
- data/lib/juwelier/templates/riot/helper.rb +5 -0
- data/lib/juwelier/templates/rspec/.rspec +1 -0
- data/lib/juwelier/templates/rspec/flunking.rb +7 -0
- data/lib/juwelier/templates/rspec/helper.rb +14 -0
- data/lib/juwelier/templates/shindo/flunking.rb +8 -0
- data/lib/juwelier/templates/shindo/helper.rb +7 -0
- data/lib/juwelier/templates/shoulda/flunking.rb +7 -0
- data/lib/juwelier/templates/shoulda/helper.rb +12 -0
- data/lib/juwelier/templates/simplecov.erb +16 -0
- data/lib/juwelier/templates/testspec/flunking.rb +7 -0
- data/lib/juwelier/templates/testspec/helper.rb +7 -0
- data/lib/juwelier/templates/testunit/flunking.rb +7 -0
- data/lib/juwelier/templates/testunit/helper.rb +11 -0
- data/lib/juwelier/version.rb +10 -0
- data/lib/juwelier/version_helper.rb +141 -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-constant/.document +5 -0
- data/test/fixtures/existing-project-with-version-constant/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-constant/LICENSE.txt +20 -0
- data/test/fixtures/existing-project-with-version-constant/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-constant/Rakefile +85 -0
- data/test/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-constant/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-constant/test/test_helper.rb +10 -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.txt +20 -0
- data/test/fixtures/existing-project-with-version-plaintext/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +84 -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.txt +20 -0
- data/test/fixtures/existing-project-with-version-yaml/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +84 -0
- data/test/fixtures/existing-project-with-version-yaml/VERSION.yml +4 -0
- data/test/fixtures/existing-project-with-version-yaml/bin/foo_the_ultimate_bin +0 -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/juwelier/commands/test_build_gem.rb +112 -0
- data/test/juwelier/commands/test_install_gem.rb +35 -0
- data/test/juwelier/commands/test_release_to_gemcutter.rb +39 -0
- data/test/juwelier/commands/test_release_to_git.rb +271 -0
- data/test/juwelier/commands/test_release_to_github.rb +477 -0
- data/test/juwelier/commands/test_validate_gemspec.rb +27 -0
- data/test/juwelier/commands/test_write_gemspec.rb +103 -0
- data/test/juwelier/commands/version/test_base.rb +53 -0
- data/test/juwelier/commands/version/test_bump_major.rb +22 -0
- data/test/juwelier/commands/version/test_bump_minor.rb +19 -0
- data/test/juwelier/commands/version/test_bump_patch.rb +20 -0
- data/test/juwelier/commands/version/test_write.rb +22 -0
- data/test/juwelier/generator/test_application.rb +142 -0
- data/test/juwelier/generator/test_options.rb +227 -0
- data/test/juwelier/test_gemspec_helper.rb +44 -0
- data/test/juwelier/test_generator.rb +140 -0
- data/test/juwelier/test_generator_initialization.rb +150 -0
- data/test/juwelier/test_generator_mixins.rb +23 -0
- data/test/juwelier/test_specification.rb +245 -0
- data/test/juwelier/test_tasks.rb +50 -0
- data/test/juwelier/test_version_helper.rb +214 -0
- data/test/shoulda_macros/juwelier_macros.rb +35 -0
- data/test/test_helper.rb +174 -0
- data/test/test_juwelier.rb +177 -0
- metadata +396 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Juwelier
|
4
|
+
module Commands
|
5
|
+
class TestValidateGemspec < Test::Unit::TestCase
|
6
|
+
|
7
|
+
build_command_context "build context" do
|
8
|
+
setup do
|
9
|
+
@command = Juwelier::Commands::ValidateGemspec.build_for(@juwelier)
|
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 Juwelier::Commands::ValidateGemspec" do
|
21
|
+
assert_kind_of Juwelier::Commands::ValidateGemspec, @command
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Juwelier
|
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 = Juwelier::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
|
+
# FIXME apparently rubygems doesn't use Time.now under the hood when generating a date
|
29
|
+
@now = Time.local(2008, 9, 1, 12, 0, 0)
|
30
|
+
stub(Time.now).now { @now }
|
31
|
+
end
|
32
|
+
|
33
|
+
should "refresh version" do
|
34
|
+
@command.run
|
35
|
+
assert_received(@version_helper) {|version_helper| version_helper.refresh }
|
36
|
+
end
|
37
|
+
|
38
|
+
should "update gemspec version" do
|
39
|
+
@command.run
|
40
|
+
assert_equal '1.2.3', @gemspec.version.to_s
|
41
|
+
end
|
42
|
+
|
43
|
+
should "not refresh version neither update version if it's set on the gemspec" do
|
44
|
+
@gemspec.version = '2.3.4'
|
45
|
+
@command.run
|
46
|
+
assert_equal '2.3.4', @gemspec.version.to_s
|
47
|
+
end
|
48
|
+
|
49
|
+
should_eventually "update gemspec date to the beginning of today" do
|
50
|
+
@command.run
|
51
|
+
# FIXME apparently rubygems doesn't use Time.now under the hood when generating a date
|
52
|
+
assert_equal Time.local(@now.year, @now.month, @now.day, 0, 0), @gemspec.date
|
53
|
+
end
|
54
|
+
|
55
|
+
should "write gemspec" do
|
56
|
+
@command.run
|
57
|
+
assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.write }
|
58
|
+
end
|
59
|
+
|
60
|
+
should_eventually "output that the gemspec was written" do
|
61
|
+
@command.run
|
62
|
+
assert_equal @output.string, "Generated: tmp/zomg.gemspec"
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
build_command_context "building for juwelier" do
|
68
|
+
setup do
|
69
|
+
@command = Juwelier::Commands::WriteGemspec.build_for(@juwelier)
|
70
|
+
end
|
71
|
+
|
72
|
+
should "assign base_dir" do
|
73
|
+
assert_same @base_dir, @command.base_dir
|
74
|
+
end
|
75
|
+
|
76
|
+
should "assign gemspec" do
|
77
|
+
assert_same @gemspec, @command.gemspec
|
78
|
+
end
|
79
|
+
|
80
|
+
should "assign version" do
|
81
|
+
assert_same @version, @command.version
|
82
|
+
end
|
83
|
+
|
84
|
+
should "assign output" do
|
85
|
+
assert_same @output, @command.output
|
86
|
+
end
|
87
|
+
|
88
|
+
should "assign gemspec_helper" do
|
89
|
+
assert_same @gemspec_helper, @command.gemspec_helper
|
90
|
+
end
|
91
|
+
|
92
|
+
should "assign version_helper" do
|
93
|
+
assert_same @version_helper, @command.version_helper
|
94
|
+
end
|
95
|
+
|
96
|
+
should "return WriteGemspec" do
|
97
|
+
assert_kind_of Juwelier::Commands::WriteGemspec, @command
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Juwelier
|
4
|
+
module Commands
|
5
|
+
module Version
|
6
|
+
class TestBase < Test::Unit::TestCase
|
7
|
+
build_command_context "build for juwelier" do
|
8
|
+
setup do
|
9
|
+
@command = Juwelier::Commands::Version::Base.build_for(@juwelier)
|
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
|
+
|
28
|
+
context "commit_version" do
|
29
|
+
setup do
|
30
|
+
@dir = Object.new
|
31
|
+
stub(@repo).dir { @dir }
|
32
|
+
stub(@dir).path { Dir.pwd }
|
33
|
+
stub(@version_helper).path { Pathname.new 'VERSION' }
|
34
|
+
stub(@version_helper).to_s { '1.0.0' }
|
35
|
+
stub(@repo) do
|
36
|
+
add(anything)
|
37
|
+
commit(anything)
|
38
|
+
end
|
39
|
+
@command.base_dir = Dir.pwd
|
40
|
+
@command.commit_version
|
41
|
+
end
|
42
|
+
|
43
|
+
should "add VERSION" do
|
44
|
+
assert_received(@repo) {|repo| repo.add('VERSION')}
|
45
|
+
assert_received(@repo) {|repo| repo.commit('Version bump to 1.0.0')}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Juwelier
|
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 = Juwelier::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 Juwelier
|
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 = Juwelier::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 Juwelier
|
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 = Juwelier::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,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Juwelier
|
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, nil
|
10
|
+
|
11
|
+
command = Juwelier::Commands::Version::Write.new
|
12
|
+
command.version_helper = version_helper
|
13
|
+
command.major = 1
|
14
|
+
command.minor = 2
|
15
|
+
command.patch = 3
|
16
|
+
command.update_version
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,142 @@
|
|
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 = Juwelier::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 stub_options(options = {})
|
29
|
+
stub(options).opts { 'Usage:' }
|
30
|
+
|
31
|
+
options
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.should_exit_with_code(code)
|
35
|
+
should "exit with code #{code}" do
|
36
|
+
assert_equal code, @result
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
context "when options indicate version" do
|
42
|
+
setup do
|
43
|
+
stub(Juwelier::Generator::Application).build_opts do
|
44
|
+
stub_options(:show_version => true)
|
45
|
+
end
|
46
|
+
|
47
|
+
stub(Juwelier::Generator).new { raise "Shouldn't have made this far"}
|
48
|
+
|
49
|
+
assert_nothing_raised do
|
50
|
+
@result = run_application("-v")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
should_exit_with_code 1
|
55
|
+
|
56
|
+
should 'should puts option version' do
|
57
|
+
assert_match 'Version:', @stderr
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
context "when options indicate help usage" do
|
63
|
+
setup do
|
64
|
+
stub(Juwelier::Generator::Application).build_opts do
|
65
|
+
stub_options(:show_help => true)
|
66
|
+
end
|
67
|
+
|
68
|
+
stub(Juwelier::Generator).new { raise "Shouldn't have made this far"}
|
69
|
+
|
70
|
+
assert_nothing_raised do
|
71
|
+
@result = run_application("-h")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
should_exit_with_code 1
|
76
|
+
|
77
|
+
should 'should puts option usage' do
|
78
|
+
assert_match 'Usage:', @stderr
|
79
|
+
end
|
80
|
+
|
81
|
+
should 'not display anything on stdout' do
|
82
|
+
assert_equal '', @stdout.squeeze.strip
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "when options indicate an invalid argument" do
|
87
|
+
setup do
|
88
|
+
stub(Juwelier::Generator::Application).build_opts do
|
89
|
+
stub_options(:invalid_argument => '--invalid-argument')
|
90
|
+
end
|
91
|
+
|
92
|
+
stub(Juwelier::Generator).new { raise "Shouldn't have made this far"}
|
93
|
+
|
94
|
+
assert_nothing_raised do
|
95
|
+
@result = run_application("--invalid-argument")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
should_exit_with_code 1
|
100
|
+
|
101
|
+
should 'display invalid argument' do
|
102
|
+
assert_match '--invalid-argument', @stderr
|
103
|
+
end
|
104
|
+
|
105
|
+
should 'display usage on stderr' do
|
106
|
+
assert_match 'Usage:', @stderr
|
107
|
+
end
|
108
|
+
|
109
|
+
should 'not display anything on stdout' do
|
110
|
+
assert_equal '', @stdout.squeeze.strip
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
context "when options are good" do
|
116
|
+
setup do
|
117
|
+
@generator = "generator"
|
118
|
+
stub(@generator).run
|
119
|
+
stub(Juwelier::Generator).new { @generator }
|
120
|
+
|
121
|
+
@juwelier_options = stub_options :project_name => 'zomg'
|
122
|
+
stub(Juwelier::Generator::Application).build_options do
|
123
|
+
@juwelier_options
|
124
|
+
end
|
125
|
+
|
126
|
+
assert_nothing_raised do
|
127
|
+
@result = run_application("zomg")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
should_exit_with_code 0
|
132
|
+
|
133
|
+
should "create generator with options" do
|
134
|
+
assert_received(Juwelier::Generator) {|subject| subject.new(@juwelier_options) }
|
135
|
+
end
|
136
|
+
|
137
|
+
should "run generator" do
|
138
|
+
assert_received(@generator) {|subject| subject.run }
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestOptions < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
set_default_git_config
|
7
|
+
stub_git_config valid_git_config
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.should_have_testing_framework(testing_framework)
|
11
|
+
should "use #{testing_framework} for testing" do
|
12
|
+
assert_equal testing_framework.to_sym, @options[:testing_framework]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.should_have_docmentation_framework(documentation_framework)
|
17
|
+
should "use #{documentation_framework} for documentation" do
|
18
|
+
assert_equal documentation_framework.to_sym, @options[:documentation_framework]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup_options(*arguments)
|
23
|
+
stub(Juwelier::Generator::Options).git_config { valid_git_config }
|
24
|
+
@options = Juwelier::Generator::Options.new(["project_name"] + arguments)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.for_options(*options)
|
28
|
+
context options.join(' ') do
|
29
|
+
setup { setup_options *options }
|
30
|
+
yield
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "default options" do
|
35
|
+
setup { setup_options }
|
36
|
+
should_have_testing_framework :shoulda
|
37
|
+
should_have_docmentation_framework :rdoc
|
38
|
+
|
39
|
+
should 'not create repository' do
|
40
|
+
assert ! @options[:create_repo]
|
41
|
+
end
|
42
|
+
|
43
|
+
should "have project name" do
|
44
|
+
assert_equal "project_name", @options[:project_name]
|
45
|
+
end
|
46
|
+
|
47
|
+
should "use github username from git config" do
|
48
|
+
assert_equal @github_user, @options[:github_username]
|
49
|
+
end
|
50
|
+
should "use user name from git config" do
|
51
|
+
assert_equal @git_name, @options[:user_name]
|
52
|
+
end
|
53
|
+
|
54
|
+
should "use user email from git config" do
|
55
|
+
assert_equal @git_email, @options[:user_email]
|
56
|
+
end
|
57
|
+
|
58
|
+
should "use bundler" do
|
59
|
+
assert @options[:use_bundler]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
for_options "--bacon" do
|
64
|
+
should_have_testing_framework :bacon
|
65
|
+
end
|
66
|
+
|
67
|
+
for_options '--micronaut' do
|
68
|
+
should_have_testing_framework :micronaut
|
69
|
+
end
|
70
|
+
|
71
|
+
for_options '--minitest' do
|
72
|
+
should_have_testing_framework :minitest
|
73
|
+
end
|
74
|
+
|
75
|
+
for_options '--rspec' do
|
76
|
+
should_have_testing_framework :rspec
|
77
|
+
end
|
78
|
+
|
79
|
+
for_options '--shoulda' do
|
80
|
+
should_have_testing_framework :shoulda
|
81
|
+
end
|
82
|
+
|
83
|
+
for_options "--testunit" do
|
84
|
+
should_have_testing_framework :testunit
|
85
|
+
end
|
86
|
+
|
87
|
+
for_options "--testspec" do
|
88
|
+
should_have_testing_framework :testspec
|
89
|
+
end
|
90
|
+
|
91
|
+
for_options '--cucumber' do
|
92
|
+
should 'enable cucumber' do
|
93
|
+
assert_equal true, @options[:use_cucumber]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
for_options '--reek' do
|
98
|
+
should 'enable reek' do
|
99
|
+
assert_equal true, @options[:use_reek]
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
for_options '--roodi' do
|
104
|
+
should 'enable roodi' do
|
105
|
+
assert_equal true, @options[:use_roodi]
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
for_options '--create-repo' do
|
110
|
+
should 'create repository' do
|
111
|
+
assert @options[:create_repo]
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
for_options '--rdoc' do
|
116
|
+
should_have_docmentation_framework :rdoc
|
117
|
+
end
|
118
|
+
|
119
|
+
for_options '--yard' do
|
120
|
+
should_have_docmentation_framework :yard
|
121
|
+
end
|
122
|
+
|
123
|
+
for_options '--summary', 'zomg so awesome' do
|
124
|
+
should 'have summary zomg so awesome' do
|
125
|
+
assert_equal 'zomg so awesome', @options[:summary]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
for_options '--description', 'Descriptive' do
|
130
|
+
should 'have description Descriptive' do
|
131
|
+
assert_equal 'Descriptive', @options[:description]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
for_options '--directory', 'foo' do
|
136
|
+
should 'have directory foo' do
|
137
|
+
assert_equal 'foo', @options[:directory]
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
for_options '--version' do
|
142
|
+
should 'show version' do
|
143
|
+
assert @options[:show_version]
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
for_options '-v' do
|
148
|
+
should 'show version' do
|
149
|
+
assert @options[:show_version]
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
for_options '--help' do
|
154
|
+
should 'show help' do
|
155
|
+
assert @options[:show_help]
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
for_options '-h' do
|
160
|
+
should 'show help' do
|
161
|
+
assert @options[:show_help]
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
for_options '--zomg-invalid' do
|
166
|
+
should 'be an invalid argument' do
|
167
|
+
assert @options[:invalid_argument]
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
for_options '--user-name', 'myname' do
|
172
|
+
should "set user name" do
|
173
|
+
assert_equal 'myname', @options[:user_name]
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
for_options '--user-email', 'myname@mydomain.com' do
|
178
|
+
should "set user email" do
|
179
|
+
assert_equal 'myname@mydomain.com', @options[:user_email]
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
for_options '--homepage', 'http://zomg.com' do
|
184
|
+
should 'set hoempage' do
|
185
|
+
assert_equal 'http://zomg.com', @options[:homepage]
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
for_options '--git-remote', 'git@my-awesome-domain.com:zomg.git' do
|
190
|
+
should 'set the git remote' do
|
191
|
+
assert_equal 'git@my-awesome-domain.com:zomg.git', @options[:git_remote]
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
for_options '--github-username', 'mygithub' do
|
196
|
+
should "set github username" do
|
197
|
+
assert_equal 'mygithub', @options[:github_username]
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
for_options '--bundler' do
|
202
|
+
should "use bundler" do
|
203
|
+
assert @options[:use_bundler]
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
for_options '--no-bundler' do
|
208
|
+
should "not use bundler" do
|
209
|
+
assert !@options[:use_bundler]
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
context "merging options" do
|
214
|
+
should "take options from each" do
|
215
|
+
options = Juwelier::Generator::Options.new(["--rspec"]).
|
216
|
+
merge Juwelier::Generator::Options.new(["--create-repo"])
|
217
|
+
assert_equal :rspec, options[:testing_framework]
|
218
|
+
assert options[:create_repo]
|
219
|
+
end
|
220
|
+
|
221
|
+
should "shadow options" do
|
222
|
+
options = Juwelier::Generator::Options.new(["--bacon"]).
|
223
|
+
merge Juwelier::Generator::Options.new(["--rspec"])
|
224
|
+
assert_equal :rspec, options[:testing_framework]
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|