juwelier 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +2 -0
  3. data/.document +8 -0
  4. data/.semver +5 -0
  5. data/.travis.yml +7 -0
  6. data/.yardopts +2 -0
  7. data/ChangeLog.markdown +230 -0
  8. data/Gemfile +40 -0
  9. data/LICENSE.txt +20 -0
  10. data/README.markdown +252 -0
  11. data/Rakefile +78 -0
  12. data/bin/juwelier +9 -0
  13. data/features/generator/cucumber.feature +103 -0
  14. data/features/generator/directory_layout.feature +86 -0
  15. data/features/generator/dotdocument.feature +13 -0
  16. data/features/generator/env_options.feature +9 -0
  17. data/features/generator/gemfile.feature +81 -0
  18. data/features/generator/git.feature +102 -0
  19. data/features/generator/license.feature +20 -0
  20. data/features/generator/rakefile.feature +158 -0
  21. data/features/generator/readme.feature +12 -0
  22. data/features/generator/test.feature +54 -0
  23. data/features/generator/test_helper.feature +149 -0
  24. data/features/placeholder.feature +5 -0
  25. data/features/step_definitions/debug_steps.rb +6 -0
  26. data/features/step_definitions/filesystem_steps.rb +70 -0
  27. data/features/step_definitions/generator_steps.rb +387 -0
  28. data/features/step_definitions/task_steps.rb +6 -0
  29. data/features/support/env.rb +41 -0
  30. data/features/tasks/build_gem.feature +9 -0
  31. data/features/tasks/version.feature +31 -0
  32. data/features/tasks/version_bumping.feature +49 -0
  33. data/juwelier.gemspec +241 -0
  34. data/lib/juwelier.rb +178 -0
  35. data/lib/juwelier/commands.rb +20 -0
  36. data/lib/juwelier/commands/build_gem.rb +40 -0
  37. data/lib/juwelier/commands/check_dependencies.rb +66 -0
  38. data/lib/juwelier/commands/install_gem.rb +31 -0
  39. data/lib/juwelier/commands/release_gemspec.rb +87 -0
  40. data/lib/juwelier/commands/release_to_git.rb +64 -0
  41. data/lib/juwelier/commands/release_to_rubygems.rb +28 -0
  42. data/lib/juwelier/commands/validate_gemspec.rb +30 -0
  43. data/lib/juwelier/commands/version/base.rb +55 -0
  44. data/lib/juwelier/commands/version/bump_major.rb +13 -0
  45. data/lib/juwelier/commands/version/bump_minor.rb +12 -0
  46. data/lib/juwelier/commands/version/bump_patch.rb +14 -0
  47. data/lib/juwelier/commands/version/write.rb +12 -0
  48. data/lib/juwelier/commands/write_gemspec.rb +39 -0
  49. data/lib/juwelier/errors.rb +8 -0
  50. data/lib/juwelier/gemcutter_tasks.rb +8 -0
  51. data/lib/juwelier/gemspec_helper.rb +87 -0
  52. data/lib/juwelier/generator.rb +304 -0
  53. data/lib/juwelier/generator/application.rb +63 -0
  54. data/lib/juwelier/generator/bacon_mixin.rb +43 -0
  55. data/lib/juwelier/generator/github_mixin.rb +22 -0
  56. data/lib/juwelier/generator/micronaut_mixin.rb +41 -0
  57. data/lib/juwelier/generator/minitest_mixin.rb +42 -0
  58. data/lib/juwelier/generator/options.rb +172 -0
  59. data/lib/juwelier/generator/rdoc_mixin.rb +13 -0
  60. data/lib/juwelier/generator/riot_mixin.rb +42 -0
  61. data/lib/juwelier/generator/rspec_mixin.rb +42 -0
  62. data/lib/juwelier/generator/shindo_mixin.rb +44 -0
  63. data/lib/juwelier/generator/shoulda_mixin.rb +42 -0
  64. data/lib/juwelier/generator/testspec_mixin.rb +42 -0
  65. data/lib/juwelier/generator/testunit_mixin.rb +39 -0
  66. data/lib/juwelier/generator/yard_mixin.rb +15 -0
  67. data/lib/juwelier/rubyforge_tasks.rb +95 -0
  68. data/lib/juwelier/rubygems_dot_org_tasks.rb +38 -0
  69. data/lib/juwelier/rubygems_tasks.rb +38 -0
  70. data/lib/juwelier/specification.rb +110 -0
  71. data/lib/juwelier/tasks.rb +239 -0
  72. data/lib/juwelier/templates/.document +5 -0
  73. data/lib/juwelier/templates/.gitignore +49 -0
  74. data/lib/juwelier/templates/Gemfile +12 -0
  75. data/lib/juwelier/templates/LICENSE.txt +20 -0
  76. data/lib/juwelier/templates/README.rdoc +19 -0
  77. data/lib/juwelier/templates/Rakefile +9 -0
  78. data/lib/juwelier/templates/bacon/flunking.rb +7 -0
  79. data/lib/juwelier/templates/bacon/helper.rb +10 -0
  80. data/lib/juwelier/templates/bundler_setup.erb +10 -0
  81. data/lib/juwelier/templates/features/default.feature +9 -0
  82. data/lib/juwelier/templates/features/support/env.rb +11 -0
  83. data/lib/juwelier/templates/juwelier_tasks.erb +31 -0
  84. data/lib/juwelier/templates/micronaut/flunking.rb +7 -0
  85. data/lib/juwelier/templates/micronaut/helper.rb +19 -0
  86. data/lib/juwelier/templates/minitest/flunking.rb +7 -0
  87. data/lib/juwelier/templates/minitest/helper.rb +13 -0
  88. data/lib/juwelier/templates/other_tasks.erb +70 -0
  89. data/lib/juwelier/templates/riot/flunking.rb +11 -0
  90. data/lib/juwelier/templates/riot/helper.rb +5 -0
  91. data/lib/juwelier/templates/rspec/.rspec +1 -0
  92. data/lib/juwelier/templates/rspec/flunking.rb +7 -0
  93. data/lib/juwelier/templates/rspec/helper.rb +14 -0
  94. data/lib/juwelier/templates/shindo/flunking.rb +8 -0
  95. data/lib/juwelier/templates/shindo/helper.rb +7 -0
  96. data/lib/juwelier/templates/shoulda/flunking.rb +7 -0
  97. data/lib/juwelier/templates/shoulda/helper.rb +12 -0
  98. data/lib/juwelier/templates/simplecov.erb +16 -0
  99. data/lib/juwelier/templates/testspec/flunking.rb +7 -0
  100. data/lib/juwelier/templates/testspec/helper.rb +7 -0
  101. data/lib/juwelier/templates/testunit/flunking.rb +7 -0
  102. data/lib/juwelier/templates/testunit/helper.rb +11 -0
  103. data/lib/juwelier/version.rb +10 -0
  104. data/lib/juwelier/version_helper.rb +141 -0
  105. data/test/fixtures/bar/VERSION.yml +4 -0
  106. data/test/fixtures/bar/bin/foo_the_ultimate_bin +1 -0
  107. data/test/fixtures/bar/hey_include_me_in_gemspec +0 -0
  108. data/test/fixtures/bar/lib/foo_the_ultimate_lib.rb +1 -0
  109. data/test/fixtures/existing-project-with-version-constant/.document +5 -0
  110. data/test/fixtures/existing-project-with-version-constant/.gitignore +5 -0
  111. data/test/fixtures/existing-project-with-version-constant/LICENSE.txt +20 -0
  112. data/test/fixtures/existing-project-with-version-constant/README.rdoc +7 -0
  113. data/test/fixtures/existing-project-with-version-constant/Rakefile +85 -0
  114. data/test/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec +29 -0
  115. data/test/fixtures/existing-project-with-version-constant/lib/existing_project_with_version.rb +0 -0
  116. data/test/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb +7 -0
  117. data/test/fixtures/existing-project-with-version-constant/test/test_helper.rb +10 -0
  118. data/test/fixtures/existing-project-with-version-plaintext/.document +5 -0
  119. data/test/fixtures/existing-project-with-version-plaintext/.gitignore +5 -0
  120. data/test/fixtures/existing-project-with-version-plaintext/LICENSE.txt +20 -0
  121. data/test/fixtures/existing-project-with-version-plaintext/README.rdoc +7 -0
  122. data/test/fixtures/existing-project-with-version-plaintext/Rakefile +84 -0
  123. data/test/fixtures/existing-project-with-version-plaintext/VERSION +1 -0
  124. data/test/fixtures/existing-project-with-version-plaintext/existing-project-with-version.gemspec +29 -0
  125. data/test/fixtures/existing-project-with-version-plaintext/lib/existing_project_with_version.rb +0 -0
  126. data/test/fixtures/existing-project-with-version-plaintext/test/existing_project_with_version_test.rb +7 -0
  127. data/test/fixtures/existing-project-with-version-plaintext/test/test_helper.rb +10 -0
  128. data/test/fixtures/existing-project-with-version-yaml/.document +5 -0
  129. data/test/fixtures/existing-project-with-version-yaml/.gitignore +5 -0
  130. data/test/fixtures/existing-project-with-version-yaml/LICENSE.txt +20 -0
  131. data/test/fixtures/existing-project-with-version-yaml/README.rdoc +7 -0
  132. data/test/fixtures/existing-project-with-version-yaml/Rakefile +84 -0
  133. data/test/fixtures/existing-project-with-version-yaml/VERSION.yml +4 -0
  134. data/test/fixtures/existing-project-with-version-yaml/bin/foo_the_ultimate_bin +0 -0
  135. data/test/fixtures/existing-project-with-version-yaml/existing-project-with-version.gemspec +29 -0
  136. data/test/fixtures/existing-project-with-version-yaml/lib/existing_project_with_version.rb +0 -0
  137. data/test/fixtures/existing-project-with-version-yaml/test/existing_project_with_version_test.rb +7 -0
  138. data/test/fixtures/existing-project-with-version-yaml/test/test_helper.rb +10 -0
  139. data/test/geminstaller.yml +12 -0
  140. data/test/juwelier/commands/test_build_gem.rb +112 -0
  141. data/test/juwelier/commands/test_install_gem.rb +35 -0
  142. data/test/juwelier/commands/test_release_to_gemcutter.rb +39 -0
  143. data/test/juwelier/commands/test_release_to_git.rb +271 -0
  144. data/test/juwelier/commands/test_release_to_github.rb +477 -0
  145. data/test/juwelier/commands/test_validate_gemspec.rb +27 -0
  146. data/test/juwelier/commands/test_write_gemspec.rb +103 -0
  147. data/test/juwelier/commands/version/test_base.rb +53 -0
  148. data/test/juwelier/commands/version/test_bump_major.rb +22 -0
  149. data/test/juwelier/commands/version/test_bump_minor.rb +19 -0
  150. data/test/juwelier/commands/version/test_bump_patch.rb +20 -0
  151. data/test/juwelier/commands/version/test_write.rb +22 -0
  152. data/test/juwelier/generator/test_application.rb +142 -0
  153. data/test/juwelier/generator/test_options.rb +227 -0
  154. data/test/juwelier/test_gemspec_helper.rb +44 -0
  155. data/test/juwelier/test_generator.rb +140 -0
  156. data/test/juwelier/test_generator_initialization.rb +150 -0
  157. data/test/juwelier/test_generator_mixins.rb +23 -0
  158. data/test/juwelier/test_specification.rb +245 -0
  159. data/test/juwelier/test_tasks.rb +50 -0
  160. data/test/juwelier/test_version_helper.rb +214 -0
  161. data/test/shoulda_macros/juwelier_macros.rb +35 -0
  162. data/test/test_helper.rb +174 -0
  163. data/test/test_juwelier.rb +177 -0
  164. metadata +396 -0
@@ -0,0 +1,44 @@
1
+ require 'test_helper'
2
+
3
+ class TestGemspecHelper < Test::Unit::TestCase
4
+ def setup
5
+ Rake.application.instance_variable_set(:@rakefile, "Rakefile")
6
+ end
7
+
8
+ context "given a gemspec" do
9
+ setup do
10
+ @spec = build_spec
11
+ @helper = Juwelier::GemSpecHelper.new(@spec, File.dirname(__FILE__))
12
+ end
13
+
14
+ should 'have sane gemspec path' do
15
+ assert_equal "test/juwelier/#{@spec.name}.gemspec", @helper.path
16
+ end
17
+ end
18
+
19
+ context "#write" do
20
+ setup do
21
+ @spec = build_spec
22
+ @helper = Juwelier::GemSpecHelper.new(@spec, File.dirname(__FILE__))
23
+ FileUtils.rm_f(@helper.path)
24
+
25
+ @helper.write
26
+ end
27
+
28
+ teardown do
29
+ FileUtils.rm_f(@helper.path)
30
+ end
31
+
32
+ should "create gemspec file" do
33
+ assert File.exists?(@helper.path)
34
+ end
35
+
36
+ should "make valid spec" do
37
+ assert @helper.valid?
38
+ end
39
+
40
+ should "parse" do
41
+ @helper.parse
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,140 @@
1
+ require 'test_helper'
2
+
3
+ class TestGenerator < Test::Unit::TestCase
4
+ def build_generator(testing_framework = :shoulda, options = {})
5
+ options = {
6
+ :project_name => 'the-perfect-gem',
7
+ :user_name => 'John Doe',
8
+ :user_email => 'john@example.com',
9
+ :github_username => 'johndoe',
10
+ :documentation_framework => :rdoc
11
+ }.merge(options)
12
+
13
+ options[:testing_framework] = testing_framework
14
+ Juwelier::Generator.new(options)
15
+ end
16
+
17
+ should "have the correct constant name" do
18
+ assert_equal "ThePerfectGem", build_generator.constant_name
19
+ end
20
+
21
+ should "have the correct file name prefix" do
22
+ assert_equal "the_perfect_gem", build_generator.file_name_prefix
23
+ end
24
+
25
+ should "have the correct require name" do
26
+ assert_equal "the-perfect-gem", build_generator.require_name
27
+ end
28
+
29
+ should "have the correct lib file name" do
30
+ assert_equal "the-perfect-gem.rb", build_generator.lib_filename
31
+ end
32
+
33
+ should "have the correct git-remote" do
34
+ assert_equal 'user@host:/path/to/repo', build_generator(:shoulda, {:git_remote => "user@host:/path/to/repo"}).git_remote
35
+ assert_equal 'git@github.com:johndoe/the-perfect-gem.git', build_generator.git_remote
36
+ end
37
+
38
+ should "extract project name from absolut path" do
39
+ assert_equal "my-project", build_generator(:shoulda, {:project_name => "/tmp/my-project"}).project_name
40
+ end
41
+
42
+ should "extract project name from relative path" do
43
+ assert_equal "my-project", build_generator(:shoulda, {:project_name => "../my-project"}).project_name
44
+ end
45
+
46
+ should "extract project name from direct path" do
47
+ assert_equal "my-project", build_generator(:shoulda, {:project_name => "my-project"}).project_name
48
+ end
49
+
50
+ def self.should_have_generator_attribute(attribute, value)
51
+ should "have #{value} for #{attribute}" do
52
+ assert_equal value, build_generator(@framework).send(attribute)
53
+ end
54
+ end
55
+
56
+ context "shoulda" do
57
+ setup { @framework = :shoulda }
58
+ should_have_generator_attribute :test_task, 'test'
59
+ should_have_generator_attribute :test_dir, 'test'
60
+ should_have_generator_attribute :default_task, 'test'
61
+ should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
62
+ should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
63
+ should_have_generator_attribute :test_pattern, 'test/**/test_*.rb'
64
+ should_have_generator_attribute :test_filename, 'test_the-perfect-gem.rb'
65
+ should_have_generator_attribute :test_helper_filename, 'helper.rb'
66
+ end
67
+
68
+ context "testunit" do
69
+ setup { @framework = :testunit }
70
+ should_have_generator_attribute :test_task, 'test'
71
+ should_have_generator_attribute :test_dir, 'test'
72
+ should_have_generator_attribute :default_task, 'test'
73
+ should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
74
+ should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
75
+ should_have_generator_attribute :test_pattern, 'test/**/test_*.rb'
76
+ should_have_generator_attribute :test_filename, 'test_the-perfect-gem.rb'
77
+ should_have_generator_attribute :test_helper_filename, 'helper.rb'
78
+ end
79
+
80
+ context "minitest" do
81
+ setup { @framework = :minitest }
82
+ should_have_generator_attribute :test_task, 'test'
83
+ should_have_generator_attribute :test_dir, 'test'
84
+ should_have_generator_attribute :default_task, 'test'
85
+ should_have_generator_attribute :feature_support_require, 'minitest/unit'
86
+ should_have_generator_attribute :feature_support_extend, 'MiniTest::Assertions'
87
+ should_have_generator_attribute :test_pattern, 'test/**/test_*.rb'
88
+ should_have_generator_attribute :test_filename, 'test_the-perfect-gem.rb'
89
+ should_have_generator_attribute :test_helper_filename, 'helper.rb'
90
+ end
91
+
92
+ context "bacon" do
93
+ setup { @framework = :bacon }
94
+ should_have_generator_attribute :test_task, 'spec'
95
+ should_have_generator_attribute :test_dir, 'spec'
96
+ should_have_generator_attribute :default_task, 'spec'
97
+ should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
98
+ should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
99
+ should_have_generator_attribute :test_pattern, 'spec/**/*_spec.rb'
100
+ should_have_generator_attribute :test_filename, 'the-perfect-gem_spec.rb'
101
+ should_have_generator_attribute :test_helper_filename, 'spec_helper.rb'
102
+ end
103
+
104
+ context "rspec" do
105
+ setup { @framework = :rspec }
106
+ should_have_generator_attribute :test_task, 'spec'
107
+ should_have_generator_attribute :test_dir, 'spec'
108
+ should_have_generator_attribute :default_task, 'spec'
109
+ should_have_generator_attribute :feature_support_require, 'rspec/expectations'
110
+ should_have_generator_attribute :feature_support_extend, nil
111
+ should_have_generator_attribute :test_pattern, 'spec/**/*_spec.rb'
112
+ should_have_generator_attribute :test_filename, 'the-perfect-gem_spec.rb'
113
+ should_have_generator_attribute :test_helper_filename, 'spec_helper.rb'
114
+ end
115
+
116
+ context "micronaut" do
117
+ setup { @framework = :micronaut }
118
+ should_have_generator_attribute :test_task, 'examples'
119
+ should_have_generator_attribute :test_dir, 'examples'
120
+ should_have_generator_attribute :default_task, 'examples'
121
+ should_have_generator_attribute :feature_support_require, 'micronaut/expectations'
122
+ should_have_generator_attribute :feature_support_extend, 'Micronaut::Matchers'
123
+ should_have_generator_attribute :test_pattern, 'examples/**/*_example.rb'
124
+ should_have_generator_attribute :test_filename, 'the-perfect-gem_example.rb'
125
+ should_have_generator_attribute :test_helper_filename, 'example_helper.rb'
126
+ end
127
+
128
+ context "testspec" do
129
+ setup { @framework = :testspec }
130
+ should_have_generator_attribute :test_task, 'test'
131
+ should_have_generator_attribute :test_dir, 'test'
132
+ should_have_generator_attribute :default_task, 'test'
133
+ should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
134
+ should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
135
+ should_have_generator_attribute :test_pattern, 'test/**/*_test.rb'
136
+ should_have_generator_attribute :test_filename, 'the-perfect-gem_test.rb'
137
+ should_have_generator_attribute :test_helper_filename, 'test_helper.rb'
138
+ end
139
+
140
+ end
@@ -0,0 +1,150 @@
1
+ require 'test_helper'
2
+
3
+ class TestGeneratorInitialization < Test::Unit::TestCase
4
+ def setup
5
+ set_default_git_config
6
+ end
7
+
8
+ context "given a nil github repo name" do
9
+ setup do
10
+ stub_git_config
11
+ end
12
+
13
+ should 'raise NoGithubRepoNameGiven' do
14
+ assert_raise Juwelier::NoGitHubRepoNameGiven do
15
+ Juwelier::Generator.new()
16
+ end
17
+ end
18
+ end
19
+
20
+ context "without git user's name set" do
21
+ setup do
22
+ stub_git_config
23
+ end
24
+
25
+ should 'raise an NoGitUserName' do
26
+ assert_raise Juwelier::NoGitUserName do
27
+ Juwelier::Generator.new(:project_name => @project_name, :testing_framework => :shoulda, :documentation_framework => :rdoc)
28
+ end
29
+ end
30
+ end
31
+
32
+ context "without git user's email set" do
33
+ setup do
34
+ stub_git_config
35
+ end
36
+
37
+ should 'raise NoGitUserEmail' do
38
+ assert_raise Juwelier::NoGitUserEmail do
39
+ Juwelier::Generator.new(:project_name => @project_name, :user_name => @git_name, :testing_framework => :shoulda, :documentation_framework => :rdoc)
40
+ end
41
+ end
42
+ end
43
+
44
+ context "without github username set" do
45
+ setup do
46
+ stub_git_config
47
+ end
48
+
49
+ should 'raise NotGitHubUser' do
50
+ assert_raise Juwelier::NoGitHubUser do
51
+ Juwelier::Generator.new(:project_name => @project_name, :user_name => @git_name, :user_email => @git_email, :testing_framework => :shoulda, :documentation_framework => :rdoc)
52
+ end
53
+ end
54
+ end
55
+ def build_generator(options = {})
56
+ defaults = { :project_name => @project_name,
57
+ :user_name => @git_name,
58
+ :user_email => @git_email,
59
+ :github_username => @github_user,
60
+ :testing_framework => :shoulda,
61
+ :documentation_framework => :rdoc }
62
+
63
+ options = defaults.merge(options)
64
+ Juwelier::Generator.new(options)
65
+ end
66
+
67
+ context "default configuration" do
68
+ setup do
69
+ stub_git_config
70
+ @generator = build_generator
71
+ end
72
+
73
+ should "use shoulda for testing" do
74
+ assert_equal :shoulda, @generator.testing_framework
75
+ end
76
+
77
+ should "use rdoc for documentation" do
78
+ assert_equal :rdoc, @generator.documentation_framework
79
+ end
80
+
81
+ should "set todo in summary" do
82
+ assert_match /todo/i, @generator.summary
83
+ end
84
+
85
+ should "set todo in description" do
86
+ assert_match /todo/i, @generator.description
87
+ end
88
+
89
+ should "set target directory to the project name" do
90
+ assert_equal @project_name, File.split(@generator.target_dir).last
91
+ end
92
+
93
+ should "set user's name from git config" do
94
+ assert_equal @git_name, @generator.user_name
95
+ end
96
+
97
+ should "set email from git config" do
98
+ assert_equal @git_email, @generator.user_email
99
+ end
100
+
101
+ should "set origin remote as github, based on username and project name" do
102
+ assert_equal "git@github.com:#{@github_user}/#{@project_name}.git", @generator.git_remote
103
+ end
104
+
105
+ should "set homepage as github based on username and project name" do
106
+ assert_equal "http://github.com/#{@github_user}/#{@project_name}", @generator.homepage
107
+ end
108
+
109
+ should "set github username from git config" do
110
+ assert_equal @github_user, @generator.github_username
111
+ end
112
+
113
+ should "set project name as the-perfect-gem" do
114
+ assert_equal @project_name, @generator.project_name
115
+ end
116
+ end
117
+
118
+ context "using yard" do
119
+ setup do
120
+ @generator = build_generator(:documentation_framework => :yard)
121
+ end
122
+
123
+ should "set the doc_task to yardoc" do
124
+ assert_equal "yardoc", @generator.doc_task
125
+ end
126
+
127
+ end
128
+
129
+ context "using rdoc" do
130
+ setup do
131
+ @generator = build_generator(:documentation_framework => :rdoc)
132
+ end
133
+
134
+ should "set the doc_task to rdoc" do
135
+ assert_equal "rdoc", @generator.doc_task
136
+ end
137
+ end
138
+
139
+ context "using a custom homepage" do
140
+ setup do
141
+ @generator = build_generator(:homepage => 'http://zomg.com')
142
+ end
143
+
144
+ should "set the homepage" do
145
+ assert_equal "http://zomg.com", @generator.homepage
146
+ end
147
+
148
+ end
149
+
150
+ end
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+ class TestGeneratorMixins < Test::Unit::TestCase
4
+
5
+ [Juwelier::Generator::BaconMixin,
6
+ Juwelier::Generator::MicronautMixin,
7
+ Juwelier::Generator::MinitestMixin,
8
+ Juwelier::Generator::RspecMixin,
9
+ Juwelier::Generator::ShouldaMixin,
10
+ Juwelier::Generator::TestspecMixin,
11
+ Juwelier::Generator::TestunitMixin,
12
+ ].each do |mixin|
13
+ context "#{mixin}" do
14
+ %w(default_task feature_support_require feature_support_extend
15
+ test_dir test_task test_pattern test_filename
16
+ test_helper_filename).each do |method|
17
+ should "define #{method}" do
18
+ assert mixin.method_defined?(method)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,245 @@
1
+ require 'test_helper'
2
+
3
+ class TestSpecification < Test::Unit::TestCase
4
+ def setup
5
+ @project = create_construct
6
+ end
7
+
8
+ def teardown
9
+ @project.destroy!
10
+ end
11
+
12
+ def build_juwelier_gemspec(&block)
13
+ gemspec = if block
14
+ Gem::Specification.new(&block)
15
+ else
16
+ Gem::Specification.new()
17
+ end
18
+ gemspec.extend(Juwelier::Specification)
19
+ gemspec
20
+ end
21
+
22
+ should "be able to use to_ruby on a duped gemspec without error" do
23
+ gemspec = build_juwelier_gemspec
24
+ gemspec.files.include 'throwaway value'
25
+
26
+ gemspec.dup.to_ruby
27
+ end
28
+
29
+ context "basic defaults" do
30
+ setup do
31
+ @gemspec = build_juwelier_gemspec
32
+ end
33
+
34
+ should "make files a FileList" do
35
+ assert_equal FileList, @gemspec.files.class
36
+ end
37
+
38
+ should "make extra_rdoc_files a FileList" do
39
+ assert_equal FileList, @gemspec.extra_rdoc_files.class
40
+ end
41
+
42
+ end
43
+
44
+ context "there aren't any executables in the project directory" do
45
+ setup do
46
+ @project.directory 'bin'
47
+ end
48
+
49
+ context "and there hasn't been any set on the gemspec" do
50
+ setup do
51
+ @gemspec = build_juwelier_gemspec
52
+ @gemspec.set_juwelier_defaults(@project)
53
+ end
54
+
55
+
56
+ should "have empty gemspec executables" do
57
+ assert_equal [], @gemspec.executables
58
+ end
59
+ end
60
+
61
+ context "and has been previously set executables" do
62
+ setup do
63
+ @gemspec = build_juwelier_gemspec do |gemspec|
64
+ gemspec.executables = %w(non-existant)
65
+ end
66
+ @gemspec.set_juwelier_defaults(@project)
67
+ end
68
+
69
+ should "have only the original executables in the gemspec" do
70
+ assert_equal %w(non-existant), @gemspec.executables
71
+ end
72
+ end
73
+ end
74
+
75
+ context "there are multiple executables in the project directory" do
76
+ setup do
77
+ @project.directory('bin') do |bin|
78
+ bin.file 'burnination'
79
+ bin.file 'trogdor'
80
+ end
81
+ repo = Git.init(@project.to_s)
82
+ repo.config('user.name', 'who')
83
+ repo.config('user.email', 'who@where.com')
84
+ repo.add('bin/burnination')
85
+ repo.commit('Initial commit')
86
+ end
87
+
88
+ context "and there hasn't been any set on the gemspec" do
89
+ setup do
90
+ @gemspec = build_juwelier_gemspec
91
+ @gemspec.set_juwelier_defaults(@project)
92
+ end
93
+
94
+ should "have the executables under version control in the gemspec" do
95
+ assert_equal %w(burnination), @gemspec.executables
96
+ end
97
+ end
98
+ context "and has been previously set executables" do
99
+ setup do
100
+ @gemspec = build_juwelier_gemspec do |gemspec|
101
+ gemspec.executables = %w(burnination)
102
+ end
103
+ @gemspec.set_juwelier_defaults(@project)
104
+ end
105
+ should "have only the original executables in the gemspec" do
106
+ assert_equal %w(burnination), @gemspec.executables
107
+ end
108
+ end
109
+ end
110
+
111
+ context "there are mutiple extconf.rb and mkrf_conf.rb in the project directory" do
112
+ setup do
113
+ @project.directory('ext') do |ext|
114
+ ext.file 'extconf.rb'
115
+ ext.file 'mkrf_conf.rb'
116
+ ext.directory('trogdor_native') do |trogdor_native|
117
+ trogdor_native.file 'extconf.rb'
118
+ trogdor_native.file 'mkrf_conf.rb'
119
+ end
120
+ end
121
+ end
122
+
123
+ context "and there hasn't been any extensions set on the gemspec" do
124
+ setup do
125
+ @gemspec = build_juwelier_gemspec
126
+ @gemspec.set_juwelier_defaults(@project)
127
+ end
128
+
129
+ should "have all the extconf.rb and mkrf_config.rb files in extensions" do
130
+ assert_equal %w(ext/mkrf_conf.rb ext/trogdor_native/mkrf_conf.rb ext/extconf.rb ext/trogdor_native/extconf.rb).sort, @gemspec.extensions.sort
131
+ end
132
+
133
+ end
134
+
135
+ end
136
+
137
+ context "there are some files and is setup for git" do
138
+ setup do
139
+ @project.file 'Rakefile'
140
+ @project.directory('lib') do |lib|
141
+ lib.file 'example.rb'
142
+ end
143
+
144
+ repo = Git.init(@project.to_s)
145
+ repo.config('user.name', 'who')
146
+ repo.config('user.email', 'who@where.com')
147
+ repo.add('.')
148
+ repo.commit('Initial commit')
149
+ end
150
+
151
+ context "and the files defaults are used" do
152
+ setup do
153
+ @gemspec = build_juwelier_gemspec
154
+ @gemspec.set_juwelier_defaults(@project, @project)
155
+ end
156
+
157
+ should "populate files from git" do
158
+ assert_equal %w(Rakefile lib/example.rb), @gemspec.files.sort
159
+ end
160
+ end
161
+
162
+ context "and the files specified manually" do
163
+ setup do
164
+ @gemspec = build_juwelier_gemspec do |gemspec|
165
+ gemspec.files = %w(Rakefile)
166
+ end
167
+ @gemspec.set_juwelier_defaults(@project, @project)
168
+ end
169
+
170
+ should "not be overridden by files from git" do
171
+ assert_equal %w(Rakefile), @gemspec.files
172
+ end
173
+ end
174
+
175
+ end
176
+
177
+ context "there are some files and is setup for git with ignored files" do
178
+ setup do
179
+ @project.file '.gitignore', 'ignored'
180
+ @project.file 'ignored'
181
+ @project.file 'Rakefile'
182
+ @project.directory('lib') do |lib|
183
+ lib.file 'example.rb'
184
+ end
185
+
186
+ repo = Git.init(@project.to_s)
187
+ repo.config('user.name', 'who')
188
+ repo.config('user.email', 'who@where.com')
189
+ repo.add('.')
190
+ repo.commit('Initial commit')
191
+
192
+
193
+ @gemspec = build_juwelier_gemspec
194
+ @gemspec.set_juwelier_defaults(@project, @project)
195
+ end
196
+
197
+ should "populate files from git excluding ignored and .gitignore" do
198
+ assert_equal %w(Rakefile lib/example.rb), @gemspec.files.sort
199
+ end
200
+ end
201
+
202
+ context "there are some files and is setup for git and working in a sub directory" do
203
+ setup do
204
+ @subproject = File.join(@project, 'subproject')
205
+ @project.file 'Rakefile'
206
+ @project.file 'README'
207
+ @project.directory 'subproject' do |subproject|
208
+ subproject.file 'README'
209
+ subproject.directory('lib') do |lib|
210
+ lib.file 'subproject_example.rb'
211
+ end
212
+ end
213
+
214
+ repo = Git.init(@project.to_s)
215
+ repo.config('user.name', 'who')
216
+ repo.config('user.email', 'who@where.com')
217
+ repo.add('.')
218
+ repo.commit('Initial commit')
219
+
220
+ @gemspec = build_juwelier_gemspec
221
+ @gemspec.set_juwelier_defaults(@subproject, @project)
222
+ end
223
+
224
+ should "populate files from git relative to sub directory" do
225
+ assert_equal %w(lib/subproject_example.rb README).sort, @gemspec.files.sort
226
+ end
227
+ end
228
+
229
+ context "there are some files and is not setup for git" do
230
+ setup do
231
+ @project.file 'Rakefile'
232
+ @project.directory('lib') do |lib|
233
+ lib.file 'example.rb'
234
+ end
235
+
236
+ @gemspec = build_juwelier_gemspec
237
+ @gemspec.set_juwelier_defaults(@project, @project)
238
+ end
239
+
240
+ should "not populate files" do
241
+ assert_equal [], @gemspec.files.sort
242
+ end
243
+ end
244
+
245
+ end