jeweler 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,55 +6,16 @@ class Jeweler
6
6
  rubyforge_command_context "running" do
7
7
  setup do
8
8
  stub(@gemspec_helper).gem_path { 'pkg/zomg-1.1.1.gem' }
9
- stub(@command).sudo_wrapper { 'sudo gem install --local pkg/zomg-1.1.1.gem' }
9
+ stub(@command).gem_command { 'gem' }
10
10
  stub(@command).sh
11
11
 
12
12
  @command.run
13
13
  end
14
14
 
15
- should "call sudo wrapper with gem install --local" do
16
- assert_received(@command) {|command| command.sudo_wrapper('gem install --local pkg/zomg-1.1.1.gem') }
17
- end
18
-
19
- should "call sh with output of sudo wrapper" do
20
- assert_received(@command) {|command| command.sh 'sudo gem install --local pkg/zomg-1.1.1.gem' }
21
- end
22
- end
23
-
24
- rubyforge_command_context "use_sudo?" do
25
- should "be false on mswin" do
26
- stub(@command).host_os { "i386-mswin32" }
27
- assert ! @command.use_sudo?
28
- end
29
-
30
- should "be false on windows" do
31
- stub(@command).host_os { "windows" }
32
- assert ! @command.use_sudo?
33
- end
34
-
35
- should "be false on cygwin" do
36
- stub(@command).host_os { "cygwin" }
37
- assert ! @command.use_sudo?
38
- end
39
-
40
- should "be true on basically anything else" do
41
- stub(@command).host_os { "darwin9" }
42
- assert @command.use_sudo?
43
- end
44
- end
45
-
46
- rubyforge_command_context "sudo_wrapper" do
47
- should "prefix sudo if needed" do
48
- stub(@command).use_sudo? { true }
49
- assert_equal "sudo blarg", @command.sudo_wrapper("blarg")
50
- end
51
-
52
- should "not prefix with sudo if unneeded" do
53
- stub(@command).use_sudo? { false }
54
- assert_equal "blarg", @command.sudo_wrapper("blarg")
15
+ should "call sh with gem install" do
16
+ assert_received(@command) {|command| command.sh 'gem install pkg/zomg-1.1.1.gem' }
55
17
  end
56
18
  end
57
-
58
19
 
59
20
  build_command_context "build for jeweler" do
60
21
  setup do
@@ -34,9 +34,15 @@ class TestOptions < Test::Unit::TestCase
34
34
  setup { setup_options }
35
35
  should_have_testing_framework :shoulda
36
36
  should_have_docmentation_framework :rdoc
37
+
37
38
  should 'not create repository' do
38
39
  assert ! @options[:create_repo]
39
40
  end
41
+
42
+ should 'use gemcutter' do
43
+ assert @options[:gemcutter]
44
+ end
45
+
40
46
  should "have project name" do
41
47
  assert_equal "project_name", @options[:project_name]
42
48
  end
@@ -116,6 +122,18 @@ class TestOptions < Test::Unit::TestCase
116
122
  end
117
123
  end
118
124
 
125
+ for_options '--no-gemcutter' do
126
+ should 'enable rubyforge' do
127
+ assert ! @options[:gemcutter]
128
+ end
129
+ end
130
+
131
+ for_options '--gemcutter' do
132
+ should 'enable rubyforge' do
133
+ assert @options[:gemcutter]
134
+ end
135
+ end
136
+
119
137
  for_options '--rdoc' do
120
138
  should_have_docmentation_framework :rdoc
121
139
  end
@@ -2,60 +2,230 @@ require 'test_helper'
2
2
 
3
3
  class TestSpecification < Test::Unit::TestCase
4
4
  def setup
5
- remove_tmpdir!
6
- path = File.join(FIXTURE_DIR, "existing-project-with-version-yaml")
7
- Git.init(path)
8
- FileUtils.cp_r path, tmp_dir
9
- #breakpoint
5
+ @project = create_construct
6
+ end
10
7
 
8
+ def teardown
9
+ @project.destroy!
10
+ end
11
11
 
12
- @spec = Gem::Specification.new
13
- @spec.extend(Jeweler::Specification)
14
- @spec.set_jeweler_defaults(tmp_dir)
12
+ def build_jeweler_gemspec(&block)
13
+ gemspec = if block
14
+ Gem::Specification.new(&block)
15
+ else
16
+ Gem::Specification.new()
17
+ end
18
+ gemspec.extend(Jeweler::Specification)
19
+ gemspec
15
20
  end
16
21
 
17
- def teardown
18
- remove_tmpdir!
22
+ context "basic defaults" do
23
+ setup do
24
+ @gemspec = build_jeweler_gemspec
25
+ end
26
+
27
+ should "make files a FileList" do
28
+ assert_equal FileList, @gemspec.files.class
29
+ end
30
+
31
+ should "make test_files a FileList" do
32
+ assert_equal FileList, @gemspec.test_files.class
33
+ end
34
+
35
+ should "make extra_rdoc_files a FileList" do
36
+ assert_equal FileList, @gemspec.extra_rdoc_files.class
37
+ end
38
+
39
+ should "enable rdoc" do
40
+ assert @gemspec.has_rdoc
41
+ end
19
42
  end
43
+
44
+ context "there aren't any executables in the project directory" do
45
+ setup do
46
+ @project.directory 'bin'
47
+ end
20
48
 
21
- context "Gem::Specification with Jeweler monkey-patches" do
22
- context "when setting defaults" do
23
- should_eventually "should populate `files'" do
24
- # this implementation changed to use ruby-git
25
- assert_equal %w{Rakefile VERSION.yml bin/foo_the_ultimate_bin lib/foo_the_ultimate_lib.rb }, @spec.files.sort
49
+ context "and there hasn't been any set on the gemspec" do
50
+ setup do
51
+ @gemspec = build_jeweler_gemspec
52
+ @gemspec.set_jeweler_defaults(@project)
26
53
  end
27
54
 
28
- should "should populate `executables'" do
29
- assert_equal %w{ foo_the_ultimate_bin }, @spec.executables
55
+
56
+ should "have empty gemspec executables" do
57
+ assert_equal [], @gemspec.executables
30
58
  end
59
+ end
31
60
 
32
- context "with values already set" do
33
- setup do
34
- @spec.files = %w{ hey_include_me_in_gemspec }
35
- @spec.set_jeweler_defaults(fixture_dir)
61
+ context "and has been previously set executables" do
62
+ setup do
63
+ @gemspec = build_jeweler_gemspec do |gemspec|
64
+ gemspec.executables = %w(non-existant)
36
65
  end
66
+ @gemspec.set_jeweler_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
+ end
37
82
 
38
- should "not re-populate `files'" do
39
- assert_equal %w{ hey_include_me_in_gemspec }, @spec.files
83
+ context "and there hasn't been any set on the gemspec" do
84
+ setup do
85
+ @gemspec = build_jeweler_gemspec
86
+ @gemspec.set_jeweler_defaults(@project)
87
+ end
88
+
89
+ should "have the executables in the gemspec" do
90
+ assert_equal %w(burnination trogdor), @gemspec.executables
91
+ end
92
+ end
93
+ context "and has been previously set executables" do
94
+ setup do
95
+ @gemspec = build_jeweler_gemspec do |gemspec|
96
+ gemspec.executables = %w(burnination)
40
97
  end
98
+ @gemspec.set_jeweler_defaults(@project)
99
+ end
100
+ should "have only the original executables in the gemspec" do
101
+ assert_equal %w(burnination), @gemspec.executables
41
102
  end
103
+ end
104
+ end
42
105
 
43
- context "for rdoc" do
44
- should "be enabled" do
45
- assert @spec.has_rdoc
106
+ context "there are mutiple extconf.rb in the project directory" do
107
+ setup do
108
+ @project.directory('ext') do |ext|
109
+ ext.file 'extconf.rb'
110
+ ext.directory('trogdor_native') do |trogdor_native|
111
+ trogdor_native.file 'extconf.rb'
46
112
  end
113
+ end
114
+ end
47
115
 
48
- should "be utf-8" do
49
- assert @spec.rdoc_options.include?('--charset=UTF-8')
116
+ context "and there hasn't been any extensions set on the gemspec" do
117
+ setup do
118
+ @gemspec = build_jeweler_gemspec
119
+ @gemspec.set_jeweler_defaults(@project)
120
+ end
121
+
122
+ should "have all the extconf.rb files in extensions" do
123
+ assert_equal %w(ext/extconf.rb ext/trogdor_native/extconf.rb), @gemspec.extensions
124
+ end
125
+
126
+ end
127
+
128
+ end
129
+
130
+ context "there are some files and is setup for git" do
131
+ setup do
132
+ @project.file 'Rakefile'
133
+ @project.directory('lib') do |lib|
134
+ lib.file 'example.rb'
135
+ end
136
+
137
+ repo = Git.init(@project)
138
+ repo.add('.')
139
+ repo.commit('Initial commit')
140
+ end
141
+
142
+ context "and the files defaults are used" do
143
+ setup do
144
+ @gemspec = build_jeweler_gemspec
145
+ @gemspec.set_jeweler_defaults(@project, @project)
146
+ end
147
+
148
+ should "populate files from git" do
149
+ assert_equal %w(Rakefile lib/example.rb), @gemspec.files
150
+ end
151
+ end
152
+
153
+ context "and the files specified manually" do
154
+ setup do
155
+ @gemspec = build_jeweler_gemspec do |gemspec|
156
+ gemspec.files = %w(Rakefile)
50
157
  end
158
+ @gemspec.set_jeweler_defaults(@project, @project)
159
+ end
160
+
161
+ should "not be overridden by files from git" do
162
+ assert_equal %w(Rakefile), @gemspec.files
51
163
  end
52
164
  end
53
165
 
54
- should "allow the user to concat files to the existing `files' array" do
55
- before = @spec.files.dup
56
- @spec.files << 'extra'
166
+ end
167
+
168
+ context "there are some files and is setup for git with ignored files" do
169
+ setup do
170
+ @project.file '.gitignore', 'ignored'
171
+ @project.file 'ignored'
172
+ @project.file 'Rakefile'
173
+ @project.directory('lib') do |lib|
174
+ lib.file 'example.rb'
175
+ end
176
+
177
+ repo = Git.init(@project)
178
+ repo.add('.')
179
+ repo.commit('Initial commit')
180
+
181
+
182
+ @gemspec = build_jeweler_gemspec
183
+ @gemspec.set_jeweler_defaults(@project, @project)
184
+ end
185
+
186
+ should "populate files from git excluding ignored" do
187
+ assert_equal %w(.gitignore Rakefile lib/example.rb), @gemspec.files
188
+ end
189
+ end
190
+
191
+ context "there are some files and is setup for git and working in a sub directory" do
192
+ setup do
193
+ @subproject = File.join(@project, 'subproject')
194
+ @project.file 'Rakefile'
195
+ @project.file 'README'
196
+ @project.directory 'subproject' do |subproject|
197
+ subproject.file 'README'
198
+ subproject.directory('lib') do |lib|
199
+ lib.file 'subproject_example.rb'
200
+ end
201
+ end
202
+
203
+ repo = Git.init(@project)
204
+ repo.add('.')
205
+ repo.commit('Initial commit')
206
+
207
+ @gemspec = build_jeweler_gemspec
208
+ @gemspec.set_jeweler_defaults(@subproject, @project)
209
+ end
210
+
211
+ should "populate files from git relative to sub directory" do
212
+ assert_equal %w(lib/subproject_example.rb README).sort, @gemspec.files.sort
213
+ end
214
+ end
215
+
216
+ context "there are some files and is not setup for git" do
217
+ setup do
218
+ @project.file 'Rakefile'
219
+ @project.directory('lib') do |lib|
220
+ lib.file 'example.rb'
221
+ end
222
+
223
+ @gemspec = build_jeweler_gemspec
224
+ @gemspec.set_jeweler_defaults(@project, @project)
225
+ end
57
226
 
58
- assert_equal before + %w{ extra }, @spec.files
227
+ should "not populate files" do
228
+ assert_equal [], @gemspec.files.sort
59
229
  end
60
230
  end
61
231
  end
@@ -12,6 +12,8 @@ begin
12
12
  require 'shoulda'
13
13
  require 'rr'
14
14
  require 'redgreen'
15
+ require 'construct'
16
+ require 'git'
15
17
  rescue LoadError => e
16
18
  puts "*" * 80
17
19
  puts "Some dependencies needed to run tests were missing. Run the following command to find them:"
@@ -42,6 +44,7 @@ end
42
44
 
43
45
  class Test::Unit::TestCase
44
46
  include RR::Adapters::TestUnit unless include?(RR::Adapters::TestUnit)
47
+ include Construct::Helpers
45
48
 
46
49
  def tmp_dir
47
50
  TMP_DIR
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class TestJeweler < Test::Unit::TestCase
4
4
 
5
5
  def build_jeweler(base_dir = nil)
6
- base_dir ||= non_git_dir_path
6
+ base_dir ||= git_dir_path
7
7
  FileUtils.mkdir_p base_dir
8
8
 
9
9
  Jeweler.new(build_spec, base_dir)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jeweler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Nichols
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-18 00:00:00 -04:00
12
+ date: 2009-11-19 00:00:00 -08:00
13
13
  default_executable: jeweler
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -92,6 +92,36 @@ dependencies:
92
92
  - !ruby/object:Gem::Version
93
93
  version: "0"
94
94
  version:
95
+ - !ruby/object:Gem::Dependency
96
+ name: devver-construct
97
+ type: :development
98
+ version_requirement:
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: "0"
104
+ version:
105
+ - !ruby/object:Gem::Dependency
106
+ name: yard
107
+ type: :development
108
+ version_requirement:
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ version:
115
+ - !ruby/object:Gem::Dependency
116
+ name: cucumber
117
+ type: :development
118
+ version_requirement:
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: "0"
124
+ version:
95
125
  description: Simple and opinionated helper for creating Rubygem projects on GitHub
96
126
  email: josh@technicalpickles.com
97
127
  executables:
@@ -176,10 +206,12 @@ files:
176
206
  - lib/jeweler/templates/bacon/helper.rb
177
207
  - lib/jeweler/templates/features/default.feature
178
208
  - lib/jeweler/templates/features/support/env.rb
209
+ - lib/jeweler/templates/jeweler_tasks.erb
179
210
  - lib/jeweler/templates/micronaut/flunking.rb
180
211
  - lib/jeweler/templates/micronaut/helper.rb
181
212
  - lib/jeweler/templates/minitest/flunking.rb
182
213
  - lib/jeweler/templates/minitest/helper.rb
214
+ - lib/jeweler/templates/other_tasks.erb
183
215
  - lib/jeweler/templates/riot/flunking.rb
184
216
  - lib/jeweler/templates/riot/helper.rb
185
217
  - lib/jeweler/templates/rspec/flunking.rb