jeweler 0.11.0 → 0.11.1

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.
@@ -61,7 +61,11 @@ class Jeweler
61
61
  end
62
62
  end
63
63
 
64
- @opts.parse!(args)
64
+ begin
65
+ @opts.parse!(args)
66
+ rescue OptionParser::InvalidOption => e
67
+ self[:invalid_argument] = e.message
68
+ end
65
69
  end
66
70
 
67
71
  def merge(other)
@@ -0,0 +1,39 @@
1
+ class Jeweler
2
+ class Generator
3
+ module RspecMixin
4
+
5
+ def default_task
6
+ 'spec'
7
+ end
8
+
9
+ def feature_support_require
10
+ 'spec/expectations'
11
+ end
12
+
13
+ def feature_support_extend
14
+ nil # Cucumber is smart enough extend Spec::Expectations on its own
15
+ end
16
+
17
+ def test_dir
18
+ 'spec'
19
+ end
20
+
21
+ def test_task
22
+ 'spec'
23
+ end
24
+
25
+ def test_pattern
26
+ 'spec/**/*_spec.rb'
27
+ end
28
+
29
+ def test_filename
30
+ "#{require_name}_spec.rb"
31
+ end
32
+
33
+ def test_helper_filename
34
+ "spec_helper.rb"
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ class Jeweler
2
+ class Generator
3
+ module ShouldaMixin
4
+
5
+ def default_task
6
+ 'test'
7
+ end
8
+
9
+ def feature_support_require
10
+ 'test/unit/assertions'
11
+ end
12
+
13
+ def feature_support_extend
14
+ 'Test::Unit::Assertions'
15
+ end
16
+
17
+ def test_dir
18
+ 'test'
19
+ end
20
+
21
+ def test_task
22
+ 'test'
23
+ end
24
+
25
+ def test_pattern
26
+ 'test/**/*_test.rb'
27
+ end
28
+
29
+ def test_filename
30
+ "#{require_name}_test.rb"
31
+ end
32
+
33
+ def test_helper_filename
34
+ "test_helper.rb"
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ class Jeweler
2
+ class Generator
3
+ module TestunitMixin
4
+
5
+ def default_task
6
+ 'test'
7
+ end
8
+
9
+ def feature_support_require
10
+ 'test/unit/assertions'
11
+ end
12
+
13
+ def feature_support_extend
14
+ 'Test::Unit::Assertions'
15
+ end
16
+
17
+ def test_dir
18
+ 'test'
19
+ end
20
+
21
+ def test_task
22
+ 'test'
23
+ end
24
+
25
+ def test_pattern
26
+ 'test/**/*_test.rb'
27
+ end
28
+
29
+ def test_filename
30
+ "#{require_name}_test.rb"
31
+ end
32
+
33
+ def test_helper_filename
34
+ "test_helper.rb"
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -1,4 +1,4 @@
1
- = <%= github_repo_name %>
1
+ = <%= project_name %>
2
2
 
3
3
  Description goes here.
4
4
 
@@ -4,62 +4,62 @@ require 'rake'
4
4
  begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
- gem.name = "<%= github_repo_name %>"
7
+ gem.name = "<%= project_name %>"
8
8
  gem.summary = %Q{<%= summary %>}
9
9
  gem.email = "<%= user_email %>"
10
- gem.homepage = "<%= github_url %>"
10
+ gem.homepage = "<%= project_homepage %>"
11
11
  gem.authors = ["<%= user_name %>"]
12
12
  <% if should_setup_rubyforge %>
13
- gem.rubyforge_project = "<%= github_repo_name %>"
14
- <% end %>
13
+ gem.rubyforge_project = "<%= project_name %>"
14
+ <% end %>
15
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
16
  end
17
17
  rescue LoadError
18
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
18
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
19
  end
20
20
 
21
- <% case testing_framework.to_sym %>
21
+ <% case testing_framework %>
22
22
  <% when :rspec %>
23
23
  require 'spec/rake/spectask'
24
- Spec::Rake::SpecTask.new(:spec) do |spec|
25
- spec.libs << 'lib' << 'spec'
26
- spec.spec_files = FileList['spec/**/*_spec.rb']
24
+ Spec::Rake::SpecTask.new(:<%= test_task %>) do |<%= test_task %>|
25
+ <%= test_task %>.libs << 'lib' << '<%= test_dir %>'
26
+ <%= test_task %>.spec_files = FileList['<%= test_pattern %>']
27
27
  end
28
28
  <% when :micronaut %>
29
29
  require 'micronaut/rake_task'
30
- Micronaut::RakeTask.new(:examples) do |examples|
31
- examples.pattern = 'examples/**/*_example.rb'
32
- examples.ruby_opts << '-Ilib -Iexamples'
30
+ Micronaut::RakeTask.new(<%= test_task %>) do |<%= test_task %>|
31
+ <%= test_task %>.pattern = '<%= test_pattern %>'
32
+ <%= test_task %>.ruby_opts << '-Ilib -I<%= test_dir %>'
33
33
  end
34
34
  <% else %>
35
35
  require 'rake/testtask'
36
- Rake::TestTask.new(:<%= test_or_spec %>) do |<%= test_or_spec %>|
37
- <%= test_or_spec %>.libs << 'lib' << '<%= test_or_spec %>'
38
- <%= test_or_spec %>.pattern = '<%= test_or_spec %>/**/*_<%= test_or_spec %>.rb'
39
- <%= test_or_spec %>.verbose = true
36
+ Rake::TestTask.new(:<%= test_task %>) do |<%= test_task %>|
37
+ <%= test_task %>.libs << 'lib' << '<%= test_dir %>'
38
+ <%= test_task %>.pattern = '<%= test_pattern %>'
39
+ <%= test_task %>.verbose = true
40
40
  end
41
41
  <% end %>
42
42
 
43
- <% case testing_framework.to_sym %>
43
+ <% case testing_framework %>
44
44
  <% when :rspec %>
45
45
  Spec::Rake::SpecTask.new(:rcov) do |spec|
46
46
  spec.libs << 'lib' << 'spec'
47
- spec.pattern = 'spec/**/*_spec.rb'
47
+ spec.pattern = '<%= test_pattern %>'
48
48
  spec.rcov = true
49
49
  end
50
50
  <% when :micronaut %>
51
51
  Micronaut::RakeTask.new(:rcov) do |examples|
52
- examples.pattern = 'examples/**/*_example.rb'
53
- examples.rcov_opts = '-Ilib -Iexamples'
52
+ examples.pattern = '<%= test_pattern %>'
53
+ examples.rcov_opts = '-Ilib -I<%= test_dir %>'
54
54
  examples.rcov = true
55
55
  end
56
56
  <% else %>
57
57
  begin
58
58
  require 'rcov/rcovtask'
59
- Rcov::RcovTask.new do |<%= test_or_spec %>|
60
- <%= test_or_spec %>.libs << '<%= test_or_spec %>'
61
- <%= test_or_spec %>.pattern = '<%= test_or_spec %>/**/*_<%= test_or_spec %>.rb'
62
- <%= test_or_spec %>.verbose = true
59
+ Rcov::RcovTask.new do |<%= test_task %>|
60
+ <%= test_task %>.libs << '<%= test_dir %>'
61
+ <%= test_task %>.pattern = '<%= test_pattern %>'
62
+ <%= test_task %>.verbose = true
63
63
  end
64
64
  rescue LoadError
65
65
  task :rcov do
@@ -91,7 +91,7 @@ Rake::RDocTask.new do |rdoc|
91
91
  end
92
92
 
93
93
  rdoc.rdoc_dir = 'rdoc'
94
- rdoc.title = "<%= github_repo_name %> #{version}"
94
+ rdoc.title = "<%= project_name %> #{version}"
95
95
  rdoc.rdoc_files.include('README*')
96
96
  rdoc.rdoc_files.include('lib/**/*.rb')
97
97
  end
@@ -112,7 +112,7 @@ begin
112
112
  )
113
113
 
114
114
  host = "#{config['username']}@rubyforge.org"
115
- remote_dir = "/var/www/gforge-projects/<%= github_repo_name %>/"
115
+ remote_dir = "/var/www/gforge-projects/<%= project_name %>/"
116
116
  local_dir = 'rdoc'
117
117
 
118
118
  Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
@@ -3,6 +3,6 @@ require 'bacon'
3
3
 
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- require '<%= file_name_prefix %>'
6
+ require '<%= require_name %>'
7
7
 
8
8
  Bacon.summary_on_exit
@@ -1,11 +1,8 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
- require '<%= file_name_prefix %>'
2
+ require '<%= require_name %>'
3
3
 
4
4
  require '<%= feature_support_require %>'
5
+ <% if feature_support_extend %>
5
6
 
6
- World do |world|
7
- <% if feature_support_extend %>
8
- world.extend(<%= feature_support_extend %>)
9
- <% end %>
10
- world
11
- end
7
+ World(<%= feature_support_extend %>)
8
+ <% end %>
@@ -4,7 +4,7 @@ require 'micronaut'
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
6
 
7
- require '<%= file_name_prefix %>'
7
+ require '<%= require_name %>'
8
8
 
9
9
  def not_in_editor?
10
10
  !(ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM'))
@@ -3,7 +3,7 @@ require 'mini/test'
3
3
 
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- require '<%= file_name_prefix %>'
6
+ require '<%= require_name %>'
7
7
 
8
8
  class Mini::Test::TestCase
9
9
  end
@@ -2,7 +2,7 @@ require 'spec'
2
2
 
3
3
  $LOAD_PATH.unshift(File.dirname(__FILE__))
4
4
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
- require '<%= file_name_prefix %>'
5
+ require '<%= require_name %>'
6
6
 
7
7
  Spec::Runner.configure do |config|
8
8
 
@@ -4,7 +4,7 @@ require 'shoulda'
4
4
 
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require '<%= file_name_prefix %>'
7
+ require '<%= require_name %>'
8
8
 
9
9
  class Test::Unit::TestCase
10
10
  end
@@ -3,7 +3,7 @@ require 'test/unit'
3
3
 
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- require '<%= file_name_prefix %>'
6
+ require '<%= require_name %>'
7
7
 
8
8
  class Test::Unit::TestCase
9
9
  end
@@ -77,6 +77,32 @@ class TestApplication < Test::Unit::TestCase
77
77
  end
78
78
  end
79
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
+
80
106
  context "when called with repo name" do
81
107
  setup do
82
108
  @options = {:testing_framework => :shoulda}
@@ -32,5 +32,9 @@ class TestGemspecHelper < Test::Unit::TestCase
32
32
  should "make valid spec" do
33
33
  assert @helper.valid?
34
34
  end
35
+
36
+ should "parse" do
37
+ @helper.parse
38
+ end
35
39
  end
36
40
  end
@@ -50,134 +50,101 @@ class TestGenerator < Test::Unit::TestCase
50
50
  end
51
51
  end
52
52
 
53
- context "test_or_spec" do
54
- should "be test for shoulda" do
55
- assert_equal 'test', build_generator(:shoulda).test_or_spec
56
- end
57
-
58
- should "be test for testunit" do
59
- assert_equal 'test', build_generator(:testunit).test_or_spec
60
- end
61
-
62
- should "be test for minitest" do
63
- assert_equal 'test', build_generator(:minitest).test_or_spec
64
- end
65
-
66
- should "be spec for bacon" do
67
- assert_equal 'spec', build_generator(:bacon).test_or_spec
68
- end
69
-
70
- should "be spec for rspec" do
71
- assert_equal 'spec', build_generator(:rspec).test_or_spec
72
- end
73
-
74
- should "be example for micronaut" do
75
- assert_equal 'example', build_generator(:micronaut).test_or_spec
76
- end
53
+ should "have the correct git remote" do
54
+ assert_equal 'git@github.com:johndoe/the-perfect-gem.git', build_generator.git_remote
77
55
  end
78
56
 
79
- context "test_dir" do
80
- should "be test for shoulda" do
81
- assert_equal 'test', build_generator(:shoulda).test_dir
82
- end
83
-
84
- should "be test for testunit" do
85
- assert_equal 'test', build_generator(:testunit).test_dir
86
- end
87
-
88
- should "be test for minitest" do
89
- assert_equal 'test', build_generator(:minitest).test_dir
90
- end
91
-
92
- should "be spec for bacon" do
93
- assert_equal 'spec', build_generator(:bacon).test_dir
94
- end
95
-
96
- should "be spec for rspec" do
97
- assert_equal 'spec', build_generator(:rspec).test_dir
98
- end
99
-
100
- should "be examples for micronaut" do
101
- assert_equal 'examples', build_generator(:micronaut).test_dir
102
- end
57
+ should "have the correct project homepage" do
58
+ assert_equal 'http://github.com/johndoe/the-perfect-gem', build_generator.project_homepage
103
59
  end
104
60
 
105
- context "default_task" do
106
- should "be test for shoulda" do
107
- assert_equal 'test', build_generator(:shoulda).default_task
108
- end
109
-
110
- should "be test for testunit" do
111
- assert_equal 'test', build_generator(:testunit).default_task
112
- end
113
-
114
- should "be test for minitest" do
115
- assert_equal 'test', build_generator(:minitest).default_task
116
- end
117
-
118
- should "be spec for bacon" do
119
- assert_equal 'spec', build_generator(:bacon).default_task
120
- end
121
-
122
- should "be spec for rspec" do
123
- assert_equal 'spec', build_generator(:rspec).default_task
124
- end
125
-
126
- should "be examples for micronaut" do
127
- assert_equal 'examples', build_generator(:micronaut).default_task
128
- end
61
+ should "have the correct constant name" do
62
+ assert_equal "ThePerfectGem", build_generator.constant_name
129
63
  end
130
64
 
131
- context "feature_support_require" do
132
- should "be test/unit/assertions for shoulda" do
133
- assert_equal 'test/unit/assertions', build_generator(:shoulda).feature_support_require
134
- end
135
-
136
- should "be test/unit/assertions for testunit" do
137
- assert_equal 'test/unit/assertions', build_generator(:testunit).feature_support_require
138
- end
139
-
140
- should "be mini/test for minitest" do
141
- assert_equal 'mini/test', build_generator(:minitest).feature_support_require
142
- end
143
-
144
- should "be test/unit/assertions for bacon" do
145
- assert_equal 'test/unit/assertions', build_generator(:bacon).feature_support_require
146
- end
147
-
148
- should "be spec/expectations for rspec" do
149
- assert_equal 'spec/expectations', build_generator(:rspec).feature_support_require
150
- end
65
+ should "have the correct file name prefix" do
66
+ assert_equal "the_perfect_gem", build_generator.file_name_prefix
67
+ end
151
68
 
152
- should "be micronaut/expectations for micronaut" do
153
- assert_equal 'micronaut/expectations', build_generator(:micronaut).feature_support_require
154
- end
69
+ should "have the correct require name" do
70
+ assert_equal "the_perfect_gem", build_generator.require_name
155
71
  end
156
72
 
157
- context "feature_support_extend" do
158
- should "be Test::Unit::Assertions for shoulda" do
159
- assert_equal 'Test::Unit::Assertions', build_generator(:shoulda).feature_support_extend
73
+ def self.should_have_generator_attribute(attribute, value)
74
+ should "have #{value} for #{attribute}" do
75
+ assert_equal value, build_generator(@framework).send(attribute)
160
76
  end
77
+ end
161
78
 
162
- should "be Test::Unit::Assertions for testunit" do
163
- assert_equal 'Test::Unit::Assertions', build_generator(:testunit).feature_support_extend
164
- end
79
+ context "shoulda" do
80
+ setup { @framework = :shoulda }
81
+ should_have_generator_attribute :test_task, 'test'
82
+ should_have_generator_attribute :test_dir, 'test'
83
+ should_have_generator_attribute :default_task, 'test'
84
+ should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
85
+ should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
86
+ should_have_generator_attribute :test_pattern, 'test/**/*_test.rb'
87
+ should_have_generator_attribute :test_filename, 'the_perfect_gem_test.rb'
88
+ should_have_generator_attribute :test_helper_filename, 'test_helper.rb'
89
+ end
165
90
 
166
- should "be Mini::Test::Assertions for minitest" do
167
- assert_equal 'Mini::Test::Assertions', build_generator(:minitest).feature_support_extend
168
- end
91
+ context "testunit" do
92
+ setup { @framework = :testunit }
93
+ should_have_generator_attribute :test_task, 'test'
94
+ should_have_generator_attribute :test_dir, 'test'
95
+ should_have_generator_attribute :default_task, 'test'
96
+ should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
97
+ should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
98
+ should_have_generator_attribute :test_pattern, 'test/**/*_test.rb'
99
+ should_have_generator_attribute :test_filename, 'the_perfect_gem_test.rb'
100
+ should_have_generator_attribute :test_helper_filename, 'test_helper.rb'
101
+ end
169
102
 
170
- should "be Test::Unit::Assertions for bacon" do
171
- assert_equal 'Test::Unit::Assertions', build_generator(:bacon).feature_support_extend
172
- end
103
+ context "minitest" do
104
+ setup { @framework = :minitest }
105
+ should_have_generator_attribute :test_task, 'test'
106
+ should_have_generator_attribute :test_dir, 'test'
107
+ should_have_generator_attribute :default_task, 'test'
108
+ should_have_generator_attribute :feature_support_require, 'mini/test'
109
+ should_have_generator_attribute :feature_support_extend, 'Mini::Test::Assertions'
110
+ should_have_generator_attribute :test_pattern, 'test/**/*_test.rb'
111
+ should_have_generator_attribute :test_filename, 'the_perfect_gem_test.rb'
112
+ should_have_generator_attribute :test_helper_filename, 'test_helper.rb'
113
+ end
173
114
 
174
- should "be nil for rspec" do
175
- assert_equal nil, build_generator(:rspec).feature_support_extend
176
- end
115
+ context "bacon" do
116
+ setup { @framework = :bacon }
117
+ should_have_generator_attribute :test_task, 'spec'
118
+ should_have_generator_attribute :test_dir, 'spec'
119
+ should_have_generator_attribute :default_task, 'spec'
120
+ should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
121
+ should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
122
+ should_have_generator_attribute :test_pattern, 'spec/**/*_spec.rb'
123
+ should_have_generator_attribute :test_filename, 'the_perfect_gem_spec.rb'
124
+ should_have_generator_attribute :test_helper_filename, 'spec_helper.rb'
125
+ end
177
126
 
178
- should "be Micronaut::Matchers for micronaut" do
179
- assert_equal 'Micronaut::Matchers', build_generator(:micronaut).feature_support_extend
180
- end
127
+ context "rspec" do
128
+ setup { @framework = :rspec }
129
+ should_have_generator_attribute :test_task, 'spec'
130
+ should_have_generator_attribute :test_dir, 'spec'
131
+ should_have_generator_attribute :default_task, 'spec'
132
+ should_have_generator_attribute :feature_support_require, 'spec/expectations'
133
+ should_have_generator_attribute :feature_support_extend, nil
134
+ should_have_generator_attribute :test_pattern, 'spec/**/*_spec.rb'
135
+ should_have_generator_attribute :test_filename, 'the_perfect_gem_spec.rb'
136
+ should_have_generator_attribute :test_helper_filename, 'spec_helper.rb'
181
137
  end
182
138
 
139
+ context "micronaut" do
140
+ setup { @framework = :micronaut }
141
+ should_have_generator_attribute :test_task, 'examples'
142
+ should_have_generator_attribute :test_dir, 'examples'
143
+ should_have_generator_attribute :default_task, 'examples'
144
+ should_have_generator_attribute :feature_support_require, 'micronaut/expectations'
145
+ should_have_generator_attribute :feature_support_extend, 'Micronaut::Matchers'
146
+ should_have_generator_attribute :test_pattern, 'examples/**/*_example.rb'
147
+ should_have_generator_attribute :test_filename, 'the_perfect_gem_example.rb'
148
+ should_have_generator_attribute :test_helper_filename, 'example_helper.rb'
149
+ end
183
150
  end