gohanlonllc-jeweler 0.11.1.20090513153819
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.
- 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 +5 -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 +205 -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/bump_timestamp.rb +14 -0
- data/lib/jeweler/commands/version/write.rb +12 -0
- data/lib/jeweler/commands/write_gemspec.rb +39 -0
- data/lib/jeweler/commands.rb +13 -0
- data/lib/jeweler/errors.rb +20 -0
- data/lib/jeweler/gemspec_helper.rb +76 -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/generator.rb +284 -0
- data/lib/jeweler/rubyforge_tasks.rb +46 -0
- data/lib/jeweler/specification.rb +65 -0
- data/lib/jeweler/tasks.rb +131 -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 +140 -0
- data/lib/jeweler.rb +155 -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 +229 -0
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestGenerator < Test::Unit::TestCase
|
4
|
+
def build_generator(testing_framework = nil, options = {})
|
5
|
+
stub.instance_of(Git::Lib).parse_config '~/.gitconfig' do
|
6
|
+
{'user.name' => 'John Doe', 'user.email' => 'john@example.com', 'github.user' => 'johndoe', 'github.token' => 'yyz'}
|
7
|
+
end
|
8
|
+
|
9
|
+
options[:testing_framework] = testing_framework
|
10
|
+
Jeweler::Generator.new('the-perfect-gem', options)
|
11
|
+
end
|
12
|
+
|
13
|
+
context "initialize" do
|
14
|
+
should "raise error if nil repo name given" do
|
15
|
+
assert_raise Jeweler::NoGitHubRepoNameGiven do
|
16
|
+
Jeweler::Generator.new(nil)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
should "raise error if blank repo name given" do
|
21
|
+
assert_raise Jeweler::NoGitHubRepoNameGiven do
|
22
|
+
Jeweler::Generator.new("")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
should "have shoulda as default framework" do
|
27
|
+
assert_equal :shoulda, build_generator.testing_framework
|
28
|
+
end
|
29
|
+
|
30
|
+
should "have repository name as default target dir" do
|
31
|
+
assert_equal 'the-perfect-gem', build_generator.target_dir
|
32
|
+
end
|
33
|
+
|
34
|
+
should "have TODO as default summary" do
|
35
|
+
assert_equal "TODO", build_generator.summary
|
36
|
+
end
|
37
|
+
|
38
|
+
should "not create repo by default" do
|
39
|
+
assert ! build_generator.should_create_repo
|
40
|
+
end
|
41
|
+
|
42
|
+
should "not use cucumber by default" do
|
43
|
+
assert ! build_generator.should_use_cucumber
|
44
|
+
end
|
45
|
+
|
46
|
+
should "raise error for invalid testing frameworks" do
|
47
|
+
assert_raise ArgumentError do
|
48
|
+
build_generator(:zomg_invalid)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
should "have the correct git remote" do
|
54
|
+
assert_equal 'git@github.com:johndoe/the-perfect-gem.git', build_generator.git_remote
|
55
|
+
end
|
56
|
+
|
57
|
+
should "have the correct project homepage" do
|
58
|
+
assert_equal 'http://github.com/johndoe/the-perfect-gem', build_generator.project_homepage
|
59
|
+
end
|
60
|
+
|
61
|
+
should "have the correct constant name" do
|
62
|
+
assert_equal "ThePerfectGem", build_generator.constant_name
|
63
|
+
end
|
64
|
+
|
65
|
+
should "have the correct file name prefix" do
|
66
|
+
assert_equal "the_perfect_gem", build_generator.file_name_prefix
|
67
|
+
end
|
68
|
+
|
69
|
+
should "have the correct require name" do
|
70
|
+
assert_equal "the-perfect-gem", build_generator.require_name
|
71
|
+
end
|
72
|
+
|
73
|
+
should "have the correct lib file name" do
|
74
|
+
assert_equal "the-perfect-gem.rb", build_generator.lib_filename
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.should_have_generator_attribute(attribute, value)
|
78
|
+
should "have #{value} for #{attribute}" do
|
79
|
+
assert_equal value, build_generator(@framework).send(attribute)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "shoulda" do
|
84
|
+
setup { @framework = :shoulda }
|
85
|
+
should_have_generator_attribute :test_task, 'test'
|
86
|
+
should_have_generator_attribute :test_dir, 'test'
|
87
|
+
should_have_generator_attribute :default_task, 'test'
|
88
|
+
should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
|
89
|
+
should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
|
90
|
+
should_have_generator_attribute :test_pattern, 'test/**/*_test.rb'
|
91
|
+
should_have_generator_attribute :test_filename, 'the-perfect-gem_test.rb'
|
92
|
+
should_have_generator_attribute :test_helper_filename, 'test_helper.rb'
|
93
|
+
end
|
94
|
+
|
95
|
+
context "testunit" do
|
96
|
+
setup { @framework = :testunit }
|
97
|
+
should_have_generator_attribute :test_task, 'test'
|
98
|
+
should_have_generator_attribute :test_dir, 'test'
|
99
|
+
should_have_generator_attribute :default_task, 'test'
|
100
|
+
should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
|
101
|
+
should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
|
102
|
+
should_have_generator_attribute :test_pattern, 'test/**/*_test.rb'
|
103
|
+
should_have_generator_attribute :test_filename, 'the-perfect-gem_test.rb'
|
104
|
+
should_have_generator_attribute :test_helper_filename, 'test_helper.rb'
|
105
|
+
end
|
106
|
+
|
107
|
+
context "minitest" do
|
108
|
+
setup { @framework = :minitest }
|
109
|
+
should_have_generator_attribute :test_task, 'test'
|
110
|
+
should_have_generator_attribute :test_dir, 'test'
|
111
|
+
should_have_generator_attribute :default_task, 'test'
|
112
|
+
should_have_generator_attribute :feature_support_require, 'mini/test'
|
113
|
+
should_have_generator_attribute :feature_support_extend, 'Mini::Test::Assertions'
|
114
|
+
should_have_generator_attribute :test_pattern, 'test/**/*_test.rb'
|
115
|
+
should_have_generator_attribute :test_filename, 'the-perfect-gem_test.rb'
|
116
|
+
should_have_generator_attribute :test_helper_filename, 'test_helper.rb'
|
117
|
+
end
|
118
|
+
|
119
|
+
context "bacon" do
|
120
|
+
setup { @framework = :bacon }
|
121
|
+
should_have_generator_attribute :test_task, 'spec'
|
122
|
+
should_have_generator_attribute :test_dir, 'spec'
|
123
|
+
should_have_generator_attribute :default_task, 'spec'
|
124
|
+
should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
|
125
|
+
should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
|
126
|
+
should_have_generator_attribute :test_pattern, 'spec/**/*_spec.rb'
|
127
|
+
should_have_generator_attribute :test_filename, 'the-perfect-gem_spec.rb'
|
128
|
+
should_have_generator_attribute :test_helper_filename, 'spec_helper.rb'
|
129
|
+
end
|
130
|
+
|
131
|
+
context "rspec" do
|
132
|
+
setup { @framework = :rspec }
|
133
|
+
should_have_generator_attribute :test_task, 'spec'
|
134
|
+
should_have_generator_attribute :test_dir, 'spec'
|
135
|
+
should_have_generator_attribute :default_task, 'spec'
|
136
|
+
should_have_generator_attribute :feature_support_require, 'spec/expectations'
|
137
|
+
should_have_generator_attribute :feature_support_extend, nil
|
138
|
+
should_have_generator_attribute :test_pattern, 'spec/**/*_spec.rb'
|
139
|
+
should_have_generator_attribute :test_filename, 'the-perfect-gem_spec.rb'
|
140
|
+
should_have_generator_attribute :test_helper_filename, 'spec_helper.rb'
|
141
|
+
end
|
142
|
+
|
143
|
+
context "micronaut" do
|
144
|
+
setup { @framework = :micronaut }
|
145
|
+
should_have_generator_attribute :test_task, 'examples'
|
146
|
+
should_have_generator_attribute :test_dir, 'examples'
|
147
|
+
should_have_generator_attribute :default_task, 'examples'
|
148
|
+
should_have_generator_attribute :feature_support_require, 'micronaut/expectations'
|
149
|
+
should_have_generator_attribute :feature_support_extend, 'Micronaut::Matchers'
|
150
|
+
should_have_generator_attribute :test_pattern, 'examples/**/*_example.rb'
|
151
|
+
should_have_generator_attribute :test_filename, 'the-perfect-gem_example.rb'
|
152
|
+
should_have_generator_attribute :test_helper_filename, 'example_helper.rb'
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestGeneratorInitialization < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@project_name = 'the-perfect-gem'
|
6
|
+
@git_name = 'foo'
|
7
|
+
@git_email = 'bar@example.com'
|
8
|
+
@github_user = 'technicalpickles'
|
9
|
+
@github_token = 'zomgtoken'
|
10
|
+
end
|
11
|
+
|
12
|
+
def stub_git_config(options = {})
|
13
|
+
stub.instance_of(Git::Lib).parse_config('~/.gitconfig') { options }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "given a nil github repo name" do
|
17
|
+
setup do
|
18
|
+
stub_git_config
|
19
|
+
|
20
|
+
@block = lambda { }
|
21
|
+
end
|
22
|
+
|
23
|
+
should 'raise NoGithubRepoNameGiven' do
|
24
|
+
assert_raise Jeweler::NoGitHubRepoNameGiven do
|
25
|
+
Jeweler::Generator.new(nil)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "without git user's name set" do
|
31
|
+
setup do
|
32
|
+
stub_git_config 'user.email' => @git_email
|
33
|
+
end
|
34
|
+
|
35
|
+
should 'raise an NoGitUserName' do
|
36
|
+
assert_raise Jeweler::NoGitUserName do
|
37
|
+
Jeweler::Generator.new(@project_name)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "without git user's email set" do
|
43
|
+
setup do
|
44
|
+
stub_git_config 'user.name' => @git_name
|
45
|
+
end
|
46
|
+
|
47
|
+
should 'raise NoGitUserName' do
|
48
|
+
assert_raise Jeweler::NoGitUserEmail do
|
49
|
+
Jeweler::Generator.new(@project_name)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "without github username set" do
|
55
|
+
setup do
|
56
|
+
stub_git_config 'user.email' => @git_email, 'user.name' => @git_name
|
57
|
+
end
|
58
|
+
|
59
|
+
should 'raise NotGitHubUser' do
|
60
|
+
assert_raise Jeweler::NoGitHubUser do
|
61
|
+
Jeweler::Generator.new(@project_name)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "without github token set" do
|
67
|
+
setup do
|
68
|
+
stub_git_config 'user.name' => @git_name, 'user.email' => @git_email, 'github.user' => @github_user
|
69
|
+
end
|
70
|
+
|
71
|
+
should 'raise NoGitHubToken if creating repo' do
|
72
|
+
assert_raise Jeweler::NoGitHubToken do
|
73
|
+
Jeweler::Generator.new(@project_name, :create_repo => true)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "with valid git user configuration" do
|
79
|
+
setup do
|
80
|
+
stub_git_config 'user.name' => @git_name, 'user.email' => @git_email, 'github.user' => @github_user, 'github.token' => @github_token
|
81
|
+
end
|
82
|
+
|
83
|
+
context "for technicalpickle's the-perfect-gem repository" do
|
84
|
+
setup do
|
85
|
+
@generator = Jeweler::Generator.new(@project_name)
|
86
|
+
end
|
87
|
+
|
88
|
+
should "assign user's name from git config" do
|
89
|
+
assert_equal @git_name, @generator.user_name
|
90
|
+
end
|
91
|
+
|
92
|
+
should "assign email from git config" do
|
93
|
+
assert_equal @git_email, @generator.user_email
|
94
|
+
end
|
95
|
+
|
96
|
+
should "assign github remote" do
|
97
|
+
assert_equal 'git@github.com:technicalpickles/the-perfect-gem.git', @generator.git_remote
|
98
|
+
end
|
99
|
+
|
100
|
+
should "assign github username from git config" do
|
101
|
+
assert_equal @github_user, @generator.github_username
|
102
|
+
end
|
103
|
+
|
104
|
+
should "determine project name as the-perfect-gem" do
|
105
|
+
assert_equal @project_name, @generator.project_name
|
106
|
+
end
|
107
|
+
|
108
|
+
should "determine target directory as the same as the github repository name" do
|
109
|
+
assert_equal @generator.project_name, @generator.target_dir
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestGeneratorMixins < Test::Unit::TestCase
|
4
|
+
|
5
|
+
[Jeweler::Generator::BaconMixin, Jeweler::Generator::MicronautMixin,
|
6
|
+
Jeweler::Generator::RspecMixin, Jeweler::Generator::ShouldaMixin,
|
7
|
+
Jeweler::Generator::TestunitMixin, Jeweler::Generator::MinitestMixin].each do |mixin|
|
8
|
+
context "#{mixin}" do
|
9
|
+
%w(default_task feature_support_require feature_support_extend
|
10
|
+
test_dir test_task test_pattern test_filename
|
11
|
+
test_helper_filename).each do |method|
|
12
|
+
should "define #{method}" do
|
13
|
+
assert mixin.method_defined?(method)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
# Use vendored gem because of limited gem availability on runcoderun
|
2
|
+
# This is loosely based on 'vendor everything'.
|
3
|
+
Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', '**')].each do |dir|
|
4
|
+
lib = "#{dir}/lib"
|
5
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'test/unit'
|
9
|
+
|
10
|
+
require 'rubygems'
|
11
|
+
require 'shoulda'
|
12
|
+
begin
|
13
|
+
require 'ruby-debug'
|
14
|
+
rescue LoadError
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'rr'
|
18
|
+
require 'redgreen'
|
19
|
+
require 'time'
|
20
|
+
|
21
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
22
|
+
require 'jeweler'
|
23
|
+
|
24
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
25
|
+
require 'shoulda_macros/jeweler_macros'
|
26
|
+
|
27
|
+
TMP_DIR = File.expand_path('../tmp', __FILE__)
|
28
|
+
FIXTURE_DIR = File.expand_path('../fixtures', __FILE__)
|
29
|
+
|
30
|
+
class RubyForgeStub
|
31
|
+
attr_accessor :userconfig, :autoconfig
|
32
|
+
def initialize
|
33
|
+
@userconfig = {}
|
34
|
+
@autoconfig = {}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
require 'output_catcher'
|
39
|
+
|
40
|
+
class Test::Unit::TestCase
|
41
|
+
include RR::Adapters::TestUnit unless include?(RR::Adapters::TestUnit)
|
42
|
+
|
43
|
+
def tmp_dir
|
44
|
+
TMP_DIR
|
45
|
+
end
|
46
|
+
|
47
|
+
def fixture_dir
|
48
|
+
File.join(FIXTURE_DIR, 'bar')
|
49
|
+
end
|
50
|
+
|
51
|
+
def remove_tmpdir!
|
52
|
+
FileUtils.rm_rf(tmp_dir)
|
53
|
+
end
|
54
|
+
|
55
|
+
def create_tmpdir!
|
56
|
+
FileUtils.mkdir_p(tmp_dir)
|
57
|
+
end
|
58
|
+
|
59
|
+
def build_spec(*files)
|
60
|
+
Gem::Specification.new do |s|
|
61
|
+
s.name = "bar"
|
62
|
+
s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
63
|
+
s.email = "josh@technicalpickles.com"
|
64
|
+
s.homepage = "http://github.com/technicalpickles/jeweler"
|
65
|
+
s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
66
|
+
s.authors = ["Josh Nichols"]
|
67
|
+
s.files = FileList[*files] unless files.empty?
|
68
|
+
s.version = '0.1.1'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.rubyforge_command_context(description, &block)
|
73
|
+
context description do
|
74
|
+
setup do
|
75
|
+
@command = eval(self.class.name.gsub(/::Test/, '::')).new
|
76
|
+
|
77
|
+
if @command.respond_to? :gemspec=
|
78
|
+
@gemspec = Object.new
|
79
|
+
@command.gemspec = @gemspec
|
80
|
+
end
|
81
|
+
|
82
|
+
if @command.respond_to? :gemspec_helper=
|
83
|
+
@gemspec_helper = Object.new
|
84
|
+
@command.gemspec_helper = @gemspec_helper
|
85
|
+
end
|
86
|
+
|
87
|
+
if @command.respond_to? :rubyforge=
|
88
|
+
@rubyforge = RubyForgeStub.new
|
89
|
+
@command.rubyforge = @rubyforge
|
90
|
+
end
|
91
|
+
|
92
|
+
if @command.respond_to? :output
|
93
|
+
@output = StringIO.new
|
94
|
+
@command.output = @output
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "", &block
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.build_command_context(description, &block)
|
103
|
+
context description do
|
104
|
+
setup do
|
105
|
+
|
106
|
+
@repo = Object.new
|
107
|
+
@version_helper = Object.new
|
108
|
+
@gemspec = Object.new
|
109
|
+
@commit = Object.new
|
110
|
+
@version = Object.new
|
111
|
+
@output = Object.new
|
112
|
+
@base_dir = Object.new
|
113
|
+
@gemspec_helper = Object.new
|
114
|
+
@rubyforge = Object.new
|
115
|
+
|
116
|
+
@jeweler = Object.new
|
117
|
+
|
118
|
+
stub(@jeweler).repo { @repo }
|
119
|
+
stub(@jeweler).version_helper { @version_helper }
|
120
|
+
stub(@jeweler).gemspec { @gemspec }
|
121
|
+
stub(@jeweler).commit { @commit }
|
122
|
+
stub(@jeweler).version { @version }
|
123
|
+
stub(@jeweler).output { @output }
|
124
|
+
stub(@jeweler).gemspec_helper { @gemspec_helper }
|
125
|
+
stub(@jeweler).base_dir { @base_dir }
|
126
|
+
stub(@jeweler).rubyforge { @rubyforge }
|
127
|
+
end
|
128
|
+
|
129
|
+
context "", &block
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestJeweler < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def build_jeweler(base_dir = nil)
|
6
|
+
base_dir ||= non_git_dir_path
|
7
|
+
FileUtils.mkdir_p base_dir
|
8
|
+
|
9
|
+
Jeweler.new(build_spec, base_dir)
|
10
|
+
end
|
11
|
+
|
12
|
+
def git_dir_path
|
13
|
+
File.join(tmp_dir, 'git')
|
14
|
+
end
|
15
|
+
|
16
|
+
def non_git_dir_path
|
17
|
+
File.join(tmp_dir, 'nongit')
|
18
|
+
end
|
19
|
+
|
20
|
+
def build_git_dir
|
21
|
+
|
22
|
+
FileUtils.mkdir_p git_dir_path
|
23
|
+
Dir.chdir git_dir_path do
|
24
|
+
Git.init
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_non_git_dir
|
29
|
+
FileUtils.mkdir_p non_git_dir_path
|
30
|
+
end
|
31
|
+
|
32
|
+
should "raise an error if a nil gemspec is given" do
|
33
|
+
assert_raises Jeweler::GemspecError do
|
34
|
+
Jeweler.new(nil)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
should "know if it is in a git repo" do
|
39
|
+
build_git_dir
|
40
|
+
|
41
|
+
assert build_jeweler(git_dir_path).in_git_repo?
|
42
|
+
end
|
43
|
+
|
44
|
+
should "know if it is not in a git repo" do
|
45
|
+
build_non_git_dir
|
46
|
+
|
47
|
+
jeweler = build_jeweler(non_git_dir_path)
|
48
|
+
assert ! jeweler.in_git_repo?, "jeweler doesn't know that #{jeweler.base_dir} is not a git repository"
|
49
|
+
end
|
50
|
+
|
51
|
+
should "build and run write gemspec command when writing gemspec" do
|
52
|
+
jeweler = build_jeweler
|
53
|
+
|
54
|
+
command = Object.new
|
55
|
+
mock(command).run
|
56
|
+
|
57
|
+
mock(Jeweler::Commands::WriteGemspec).build_for(jeweler) { command }
|
58
|
+
|
59
|
+
jeweler.write_gemspec
|
60
|
+
end
|
61
|
+
|
62
|
+
should "build and run validate gemspec command when validating gemspec" do
|
63
|
+
jeweler = build_jeweler
|
64
|
+
|
65
|
+
command = Object.new
|
66
|
+
mock(command).run
|
67
|
+
|
68
|
+
mock(Jeweler::Commands::ValidateGemspec).build_for(jeweler) { command }
|
69
|
+
|
70
|
+
jeweler.validate_gemspec
|
71
|
+
end
|
72
|
+
|
73
|
+
should "build and run build gem command when building gem" do
|
74
|
+
jeweler = build_jeweler
|
75
|
+
|
76
|
+
command = Object.new
|
77
|
+
mock(command).run
|
78
|
+
|
79
|
+
mock(Jeweler::Commands::BuildGem).build_for(jeweler) { command }
|
80
|
+
|
81
|
+
jeweler.build_gem
|
82
|
+
end
|
83
|
+
|
84
|
+
should "build and run build gem command when installing gem" do
|
85
|
+
jeweler = build_jeweler
|
86
|
+
|
87
|
+
command = Object.new
|
88
|
+
mock(command).run
|
89
|
+
|
90
|
+
mock(Jeweler::Commands::InstallGem).build_for(jeweler) { command }
|
91
|
+
|
92
|
+
jeweler.install_gem
|
93
|
+
end
|
94
|
+
|
95
|
+
should "build and run bump major version command when bumping major version" do
|
96
|
+
jeweler = build_jeweler
|
97
|
+
|
98
|
+
command = Object.new
|
99
|
+
mock(command).run
|
100
|
+
|
101
|
+
mock(Jeweler::Commands::Version::BumpMajor).build_for(jeweler) { command }
|
102
|
+
|
103
|
+
jeweler.bump_major_version
|
104
|
+
end
|
105
|
+
|
106
|
+
should "build and run bump minor version command when bumping minor version" do
|
107
|
+
jeweler = build_jeweler
|
108
|
+
|
109
|
+
command = Object.new
|
110
|
+
mock(command).run
|
111
|
+
|
112
|
+
mock(Jeweler::Commands::Version::BumpMinor).build_for(jeweler) { command }
|
113
|
+
|
114
|
+
jeweler.bump_minor_version
|
115
|
+
end
|
116
|
+
|
117
|
+
should "build and run write version command when writing version" do
|
118
|
+
jeweler = build_jeweler
|
119
|
+
|
120
|
+
command = Object.new
|
121
|
+
mock(command).run
|
122
|
+
mock(command).major=(1)
|
123
|
+
mock(command).minor=(5)
|
124
|
+
mock(command).patch=(2)
|
125
|
+
|
126
|
+
mock(Jeweler::Commands::Version::Write).build_for(jeweler) { command }
|
127
|
+
|
128
|
+
jeweler.write_version(1, 5, 2)
|
129
|
+
end
|
130
|
+
|
131
|
+
should "build and run release command when running release" do
|
132
|
+
jeweler = build_jeweler
|
133
|
+
|
134
|
+
command = Object.new
|
135
|
+
mock(command).run
|
136
|
+
|
137
|
+
mock(Jeweler::Commands::Release).build_for(jeweler) { command }
|
138
|
+
|
139
|
+
jeweler.release
|
140
|
+
end
|
141
|
+
|
142
|
+
should "build and run release to rubyforge command when running release to rubyforge" do
|
143
|
+
jeweler = build_jeweler
|
144
|
+
|
145
|
+
command = Object.new
|
146
|
+
mock(command).run
|
147
|
+
|
148
|
+
mock(Jeweler::Commands::ReleaseToRubyforge).build_for(jeweler) { command }
|
149
|
+
|
150
|
+
jeweler.release_gem_to_rubyforge
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
should "respond to gemspec_helper" do
|
155
|
+
assert_respond_to build_jeweler, :gemspec_helper
|
156
|
+
end
|
157
|
+
|
158
|
+
should "respond to version_helper" do
|
159
|
+
assert_respond_to build_jeweler, :version_helper
|
160
|
+
end
|
161
|
+
|
162
|
+
should "respond to repo" do
|
163
|
+
assert_respond_to build_jeweler, :repo
|
164
|
+
end
|
165
|
+
|
166
|
+
should "respond to commit" do
|
167
|
+
assert_respond_to build_jeweler, :commit
|
168
|
+
end
|
169
|
+
|
170
|
+
should "respond to rubyforge" do
|
171
|
+
assert_respond_to build_jeweler, :rubyforge
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestOptions < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def self.should_have_testing_framework(testing_framework)
|
6
|
+
should "use #{testing_framework} for testing" do
|
7
|
+
assert_equal testing_framework.to_sym, @options[:testing_framework]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def setup_options(*arguments)
|
12
|
+
@options = Jeweler::Generator::Options.new(arguments)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.for_options(*options)
|
16
|
+
context options.join(' ') do
|
17
|
+
setup { setup_options *options }
|
18
|
+
yield
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "default options" do
|
23
|
+
setup { setup_options }
|
24
|
+
should_have_testing_framework :shoulda
|
25
|
+
should 'not create repository' do
|
26
|
+
assert ! @options[:create_repo]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
for_options '--shoulda' do
|
31
|
+
should_have_testing_framework :shoulda
|
32
|
+
end
|
33
|
+
|
34
|
+
for_options "--bacon" do
|
35
|
+
should_have_testing_framework :bacon
|
36
|
+
end
|
37
|
+
|
38
|
+
for_options "--testunit" do
|
39
|
+
should_have_testing_framework :testunit
|
40
|
+
end
|
41
|
+
|
42
|
+
for_options '--minitest' do
|
43
|
+
should_have_testing_framework :minitest
|
44
|
+
end
|
45
|
+
|
46
|
+
for_options '--rspec' do
|
47
|
+
should_have_testing_framework :rspec
|
48
|
+
end
|
49
|
+
|
50
|
+
for_options '--micronaut' do
|
51
|
+
should_have_testing_framework :micronaut
|
52
|
+
end
|
53
|
+
|
54
|
+
for_options '--cucumber' do
|
55
|
+
should 'enable cucumber' do
|
56
|
+
assert_equal true, @options[:use_cucumber]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
for_options '--create-repo' do
|
61
|
+
should 'create repository' do
|
62
|
+
assert @options[:create_repo]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
for_options '--rubyforge' do
|
67
|
+
should 'enable rubyforge' do
|
68
|
+
assert @options[:rubyforge]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
for_options '--summary', 'zomg so awesome' do
|
73
|
+
should 'have summary zomg so awesome' do
|
74
|
+
assert_equal 'zomg so awesome', @options[:summary]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
for_options '--directory', 'foo' do
|
79
|
+
should 'have directory foo' do
|
80
|
+
assert_equal 'foo', @options[:directory]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
for_options '--help' do
|
85
|
+
should 'show help' do
|
86
|
+
assert @options[:show_help]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
for_options '-h' do
|
91
|
+
should 'show help' do
|
92
|
+
assert @options[:show_help]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
for_options '--zomg-invalid' do
|
97
|
+
should 'be an invalid argument' do
|
98
|
+
assert @options[:invalid_argument]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "merging options" do
|
103
|
+
should "take options from each" do
|
104
|
+
options = Jeweler::Generator::Options.new(["--rspec"]).
|
105
|
+
merge Jeweler::Generator::Options.new(["--create-repo"])
|
106
|
+
assert_equal :rspec, options[:testing_framework]
|
107
|
+
assert options[:create_repo]
|
108
|
+
end
|
109
|
+
|
110
|
+
should "shadow options" do
|
111
|
+
options = Jeweler::Generator::Options.new(["--bacon"]).
|
112
|
+
merge Jeweler::Generator::Options.new(["--rspec"])
|
113
|
+
assert_equal :rspec, options[:testing_framework]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|