polisher 0.6.1 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  # Polisher Upstream Operations
2
2
  #
3
3
  # Licensed under the MIT license
4
- # Copyright (C) 2013 Red Hat, Inc.
4
+ # Copyright (C) 2013-2014 Red Hat, Inc.
5
5
 
6
6
  require 'polisher/gem'
7
7
  require 'polisher/gemfile'
@@ -1,7 +1,7 @@
1
1
  # Polisher Vendor Operations
2
2
  #
3
3
  # Licensed under the MIT license
4
- # Copyright (C) 2013 Red Hat, Inc.
4
+ # Copyright (C) 2013-2014 Red Hat, Inc.
5
5
 
6
6
  module Polisher
7
7
  class Vendor
@@ -1,3 +1,3 @@
1
- class Polisher
2
- VERSION = "0.6.1"
1
+ module Polisher
2
+ VERSION = "0.7.1"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  # Helpers to check versions
2
2
  #
3
3
  # Licensed under the MIT license
4
- # Copyright (C) 2013 Red Hat, Inc.
4
+ # Copyright (C) 2013-2014 Red Hat, Inc.
5
5
 
6
6
  require 'polisher/gem'
7
7
  require 'polisher/fedora'
@@ -17,6 +17,7 @@ module Polisher
17
17
  FEDORA_TARGET = :fedora
18
18
  GIT_TARGET = :git
19
19
  YUM_TARGET = :yum
20
+ BODHI_TARGET = :bodhi # fedora dispatches to bodhi to not enabled by default
20
21
  ALL_TARGETS = [GEM_TARGET, KOJI_TARGET, FEDORA_TARGET,
21
22
  GIT_TARGET, YUM_TARGET]
22
23
 
@@ -63,6 +64,10 @@ module Polisher
63
64
  versions.merge! :yum => [Yum.version_for(name, &bl)]
64
65
  end
65
66
 
67
+ if @check_list.include?(BODHI_TARGET)
68
+ versions.merge! :bodhi => Bodhi.versions_for(name, &bl)
69
+ end
70
+
66
71
  #bodhi_version = Bodhi.versions_for(name, &bl)
67
72
  #errata_version = Errata.version_for('url?', name, &bl)
68
73
 
@@ -1,7 +1,7 @@
1
1
  # Polisher Yum Operations
2
2
  #
3
3
  # Licensed under the MIT license
4
- # Copyright (C) 2013 Red Hat, Inc.
4
+ # Copyright (C) 2013-2014 Red Hat, Inc.
5
5
 
6
6
  require 'awesome_spawn'
7
7
 
@@ -1,7 +1,7 @@
1
1
  # Polisher Bodhi Spec
2
2
  #
3
3
  # Licensed under the MIT license
4
- # Copyright (C) 2013 Red Hat, Inc.
4
+ # Copyright (C) 2013-2014 Red Hat, Inc.
5
5
 
6
6
  require 'polisher/bodhi'
7
7
 
@@ -1,7 +1,7 @@
1
1
  # Polisher Core Extensions Specs
2
2
  #
3
3
  # Licensed under the MIT license
4
- # Copyright (C) 2013 Red Hat, Inc.
4
+ # Copyright (C) 2013-2014 Red Hat, Inc.
5
5
 
6
6
  require 'spec_helper'
7
7
  require 'polisher/core'
@@ -52,13 +52,13 @@ describe String do
52
52
  describe "unrpmize" do
53
53
  it "returns string with rpm macros removed/replaced" do
54
54
  "%doc ".unrpmize.should == ""
55
- "%{_bindir}".unrpmize.should == "/bin"
55
+ "%{_bindir}".unrpmize.should == "bin"
56
56
  end
57
57
  end
58
58
 
59
59
  describe "#rpmize" do
60
60
  it "returns string with rpm macros swapped in" do
61
- "/bin".rpmize.should == "%{_bindir}"
61
+ "bin".rpmize.should == "%{_bindir}"
62
62
  end
63
63
  end
64
64
  end # describe String
@@ -1,7 +1,7 @@
1
1
  # Polisher Errata Spec
2
2
  #
3
3
  # Licensed under the MIT license
4
- # Copyright (C) 2013 Red Hat, Inc.
4
+ # Copyright (C) 2013-2014 Red Hat, Inc.
5
5
 
6
6
  require 'polisher/errata'
7
7
 
@@ -1,7 +1,7 @@
1
1
  # Polisher Fedora Spec
2
2
  #
3
3
  # Licensed under the MIT license
4
- # Copyright (C) 2013 Red Hat, Inc.
4
+ # Copyright (C) 2013-2014 Red Hat, Inc.
5
5
 
6
6
  require 'polisher/fedora'
7
7
 
@@ -1,14 +1,16 @@
1
1
  # Polisher Gem Specs
2
2
  #
3
3
  # Licensed under the MIT license
4
- # Copyright (C) 2013 Red Hat, Inc.
4
+ # Copyright (C) 2013-2014 Red Hat, Inc.
5
+
6
+ require 'spec_helper'
5
7
 
6
8
  require 'polisher/gem'
7
9
 
8
10
  module Polisher
9
11
  describe Gem do
10
12
  describe "#initialize" do
11
- it "sets gemfile attributes" do
13
+ it "sets gem attributes" do
12
14
  gem = Polisher::Gem.new :name => 'rails',
13
15
  :version => '4.0.0',
14
16
  :deps => ['activesupport', 'activerecord'],
@@ -20,6 +22,27 @@ module Polisher
20
22
  end
21
23
  end
22
24
 
25
+ describe "#ignorable_file?" do
26
+ context "args matches an ignorable file" do
27
+ it "returns true" do
28
+ Polisher::Gem.ignorable_file?('foo.gemspec').should be_true
29
+ Polisher::Gem.ignorable_file?('Gemfile').should be_true
30
+ end
31
+ end
32
+
33
+ context "args does not match an ignorable file" do
34
+ it "returns false" do
35
+ Polisher::Gem.ignorable_file?('.rvmra').should be_false
36
+ Polisher::Gem.ignorable_file?('foo.gemspoc').should be_false
37
+ end
38
+ end
39
+ end
40
+
41
+ describe "#local_versions_for" do
42
+ it "returns versions of specified gem in local db"
43
+ it "invokes cb with versions retrieved"
44
+ end
45
+
23
46
  describe "#parse" do
24
47
  it "returns new gem" do
25
48
  gem = Polisher::Gem.parse
@@ -47,20 +70,68 @@ module Polisher
47
70
  end
48
71
  end
49
72
 
50
- describe "#retrieve" do
51
- before(:each) do
52
- @local_gem = Polisher::Test::LOCAL_GEM
53
73
 
54
- # stub out expected calls to curl
55
- @curl1 = Curl::Easy.new
56
- @curl2 = Curl::Easy.new
74
+ describe "#download_gem" do
75
+ context "gem in GemCache" do
76
+ it "returns GemCache gem"
77
+ end
78
+
79
+ it "uses curl to download gem"
80
+ it "sets gem in gem cached"
81
+ it "returns downloaded gem binary contents"
82
+ end
83
+
84
+ describe "#download_gem_path" do
85
+ it "downloads gem" do
86
+ gem = Polisher::Gem.new
87
+ gem.should_receive(:download_gem)
88
+ gem.downloaded_gem_path
89
+ end
90
+
91
+ it "returns gem cache path for gem" do
92
+ # stub out d/l
93
+ gem = Polisher::Gem.new :name => 'rails', :version => '1.0'
94
+ gem.should_receive(:download_gem)
95
+ Polisher::GemCache.should_receive(:path_for).
96
+ with('rails', '1.0').
97
+ at_least(:once).
98
+ and_return('rails_path')
99
+ gem.downloaded_gem_path.should == 'rails_path'
100
+ end
101
+ end
102
+
103
+ describe "#gem_path" do
104
+ it "returns specified path" do
105
+ gem = Polisher::Gem.new :path => 'gem_path'
106
+ gem.gem_path.should == 'gem_path'
107
+ end
57
108
 
58
- Curl::Easy.should_receive(:http_get).with(@local_gem[:json_url]).and_return(@curl1)
59
- @curl1.should_receive(:body_str).and_return(@local_gem[:json])
109
+ context "specified path is null" do
110
+ it "returns downloaded gem path" do
111
+ gem = Polisher::Gem.new
112
+ gem.should_receive(:downloaded_gem_path).and_return('gem_path')
113
+ gem.gem_path.should == 'gem_path'
114
+ end
115
+ end
116
+ end
60
117
 
61
- Curl::Easy.should_receive(:new).with(@local_gem[:url]).and_return(@curl2)
62
- @curl2.should_receive(:http_get)
63
- @curl2.should_receive(:body_str).and_return(@local_gem[:contents])
118
+ describe "#unpack" do
119
+ it "unpacks gem at gem_path into temp dir"
120
+ it "returns tmp dir"
121
+ context "block specified" do
122
+ it "invokes block with tmp dir"
123
+ it "removes tmp dir"
124
+ it "returns nil"
125
+ end
126
+ end
127
+
128
+ describe "#file_paths" do
129
+ it "returns list of file paths in gem"
130
+ end
131
+
132
+ describe "#retrieve" do
133
+ before(:each) do
134
+ @local_gem = Polisher::Test::LOCAL_GEM
64
135
  end
65
136
 
66
137
  it "returns gem retrieved from rubygems" do
@@ -71,12 +142,83 @@ module Polisher
71
142
  gem.deps.should == @local_gem[:deps]
72
143
  gem.dev_deps.should == @local_gem[:dev_deps]
73
144
  end
145
+ end
74
146
 
75
- it "sets gem files" do
76
- gem = Polisher::Gem.retrieve(@local_gem[:name])
77
- gem.should be_an_instance_of(Polisher::Gem)
78
- gem.files.should == @local_gem[:files]
147
+ describe "#versions" do
148
+ it "looks up and returns versions for gemname in polisher version checker"
149
+
150
+ context "recursive is true" do
151
+ it "appends versions of gem dependencies to versions list"
152
+ context "dev_deps is true" do
153
+ it "appends versions of gem dev dependencies to versions list"
154
+ end
79
155
  end
80
156
  end
157
+
158
+ describe "#vendored_file_paths" do
159
+ it "returns file marks in gem marked as vendored" do
160
+ expected = [ 'vendor/foo.rb', 'vendor/bar/foo.rb']
161
+ paths = ['foo.rb'] + expected
162
+ gem = Polisher::Gem.new
163
+ gem.should_receive(:file_paths).and_return(paths)
164
+ gem.vendored_file_paths.should == expected
165
+ end
166
+ end
167
+
168
+ describe "#vendored" do
169
+ it "returns list of vendored modules in gem" do
170
+ gem = Polisher::Gem.new
171
+ vendored = ['vendor/thor.rb', 'vendor/thor/foo.rb', 'vendor/biz/baz.rb']
172
+ gem.should_receive(:vendored_file_paths).and_return(vendored)
173
+ gem.vendored.should == {'thor' => nil, 'biz' => nil}
174
+ end
175
+
176
+ context "vendored module has VERSION.rb file" do
177
+ it "returns version of vendored gems"
178
+ end
179
+ end
180
+
181
+ describe "#diff" do
182
+ before(:each) do
183
+ @gem1 = Polisher::Gem.new
184
+ @gem2 = Polisher::Gem.new
185
+
186
+ @result = AwesomeSpawn::CommandResult.new '', 'diff_out', '', 0
187
+ end
188
+
189
+ it "runs diff against unpacked local and other gems and returns output" do
190
+ @gem1.should_receive(:unpack).and_return('dir1')
191
+ @gem2.should_receive(:unpack).and_return('dir2')
192
+ AwesomeSpawn.should_receive(:run).
193
+ with("#{Polisher::Gem::DIFF_CMD} -r dir1 dir2").
194
+ and_return(@result)
195
+ @gem1.diff(@gem2).should == @result.output
196
+ end
197
+
198
+ it "removes unpacked gem dirs" do
199
+ @gem1.should_receive(:unpack).and_return('dir1')
200
+ @gem2.should_receive(:unpack).and_return('dir2')
201
+ AwesomeSpawn.should_receive(:run).and_return(@result)
202
+ FileUtils.should_receive(:rm_rf).with('dir1')
203
+ FileUtils.should_receive(:rm_rf).with('dir2')
204
+ # XXX for the GemCache dir cleaning:
205
+ FileUtils.should_receive(:rm_rf).at_least(:once)
206
+ @gem1.diff(@gem2)
207
+ end
208
+
209
+ context "error during operations" do
210
+ it "removes unpacked gem dirs" do
211
+ @gem1.should_receive(:unpack).and_return('dir1')
212
+ @gem2.should_receive(:unpack).and_return('dir2')
213
+ AwesomeSpawn.should_receive(:run).
214
+ and_raise(AwesomeSpawn::CommandResultError.new('', ''))
215
+ FileUtils.should_receive(:rm_rf).with('dir1')
216
+ FileUtils.should_receive(:rm_rf).with('dir2')
217
+ FileUtils.should_receive(:rm_rf).at_least(:once)
218
+ @gem1.diff(@gem2)
219
+ end
220
+ end
221
+ end
222
+
81
223
  end # describe Gem
82
224
  end # module Polisher
@@ -1,7 +1,7 @@
1
1
  # Polisher Gemfile Specs
2
2
  #
3
3
  # Licensed under the MIT license
4
- # Copyright (C) 2013 Red Hat, Inc.
4
+ # Copyright (C) 2013-2014 Red Hat, Inc.
5
5
 
6
6
  require 'polisher/gemfile'
7
7
 
@@ -23,7 +23,7 @@ module Polisher
23
23
  it "sets default gemfile version,files" do
24
24
  gemfile = Polisher::Gemfile.new
25
25
  gemfile.version.should be_nil
26
- gemfile.files.should == []
26
+ gemfile.file_paths.should == []
27
27
  end
28
28
  end
29
29
 
@@ -1,172 +1,376 @@
1
1
  # Polisher Git Spec
2
2
  #
3
3
  # Licensed under the MIT license
4
- # Copyright (C) 2013 Red Hat, Inc.
4
+ # Copyright (C) 2013-2014 Red Hat, Inc.
5
5
 
6
6
  require 'polisher/git'
7
7
 
8
8
  module Polisher
9
+ describe GitRepo do
10
+ describe "#initialize" do
11
+ it "initializes url" do
12
+ repo = described_class.new :url => 'repo_url'
13
+ repo.url.should == 'repo_url'
14
+ end
15
+ end
16
+
17
+ describe "#path" do
18
+ it "returns git cache path for url" do
19
+ repo = described_class.new :url => 'repo_url'
20
+ Polisher::GitCache.should_receive(:path_for).
21
+ with('repo_url').
22
+ and_return('repo_path')
23
+ repo.path.should == 'repo_path'
24
+ end
25
+ end
26
+
27
+ describe "#clone" do
28
+ it "runs git clone" do
29
+ expected = "/usr/bin/git clone repo_url repo_path"
30
+ AwesomeSpawn.should_receive(:run).with(expected)
31
+
32
+ repo = described_class.new :url => 'repo_url'
33
+ repo.should_receive(:path).and_return('repo_path')
34
+ repo.clone
35
+ end
36
+ end
37
+
38
+ describe "#cloned?" do
39
+ before(:each) do
40
+ @repo = described_class.new
41
+ @repo.should_receive(:path).and_return('repo_path')
42
+ end
43
+
44
+ context "repo path directory exists" do
45
+ it "returns true" do
46
+ File.should_receive(:directory?).with('repo_path').and_return(true)
47
+ @repo.should be_cloned
48
+ end
49
+ end
50
+
51
+ context "repo path directory does not exist" do
52
+ it "returns false" do
53
+ File.should_receive(:directory?).with('repo_path').and_return(false)
54
+ @repo.should_not be_cloned
55
+ end
56
+ end
57
+ end
58
+
59
+ describe "#in_repo" do
60
+ it "chdir to repo path, invokes block, restores dir" do
61
+ repo = described_class.new
62
+ Dir.mktmpdir do |dir|
63
+ repo.should_receive(:path).and_return(dir)
64
+ invoked = false
65
+ orig = Dir.pwd
66
+ repo.in_repo do
67
+ Dir.pwd.should == dir
68
+ invoked = true
69
+ end
70
+ Dir.pwd.should == orig
71
+ invoked.should be_true
72
+ end
73
+ end
74
+ end
75
+
76
+ describe "#reset!" do
77
+ it "resets git repo to head" do
78
+ expected = "/usr/bin/git reset HEAD~ --hard"
79
+ repo = described_class.new
80
+ repo.should_receive(:in_repo).and_yield
81
+ AwesomeSpawn.should_receive(:run).with(expected)
82
+ repo.reset!
83
+ end
84
+ end
85
+
86
+ describe "#pull" do
87
+ it "git pulls" do
88
+ expected = "/usr/bin/git pull"
89
+ repo = described_class.new
90
+ repo.should_receive(:in_repo).and_yield
91
+ AwesomeSpawn.should_receive(:run).with(expected)
92
+ repo.pull
93
+ end
94
+ end
95
+
96
+ describe "#checkout" do
97
+ it "git checks out target" do
98
+ expected = "/usr/bin/git checkout master"
99
+ repo = described_class.new
100
+ repo.should_receive(:in_repo).and_yield
101
+ AwesomeSpawn.should_receive(:run).with(expected)
102
+ repo.checkout('master')
103
+ end
104
+ end
105
+
106
+ describe "#commit" do
107
+ it "git commits with message" do
108
+ expected = "/usr/bin/git commit -m 'msg'"
109
+ repo = described_class.new
110
+ repo.should_receive(:in_repo).and_yield
111
+ AwesomeSpawn.should_receive(:run).with(expected)
112
+ repo.commit('msg')
113
+ end
114
+ end
115
+ end
116
+
9
117
  describe GitPackage do
118
+ describe "#initialize" do
119
+ it "initializes name" do
120
+ pkg = described_class.new :name => 'pkg_name'
121
+ pkg.name.should == 'pkg_name'
122
+ end
123
+
124
+ it "initializes version" do
125
+ pkg = described_class.new :version => 'pkg_version'
126
+ pkg.version.should == 'pkg_version'
127
+ end
128
+ end
129
+
10
130
  describe "#rpm_name" do
11
131
  it "returns rubygem-gem_name" do
12
- pkg = Polisher::GitPackage.new :name => 'rails'
132
+ pkg = described_class.new :name => 'rails'
13
133
  pkg.rpm_name.should == 'rubygem-rails'
14
134
  end
15
135
  end
16
136
 
17
137
  describe "#srpm" do
18
138
  it "returns name of srpm" do
19
- pkg = Polisher::GitPackage.new :name => 'rails', :version => '1.0.0'
139
+ pkg = described_class.new :name => 'rails', :version => '1.0.0'
20
140
  pkg.srpm.should == 'rubygem-rails-1.0.0-1.*.src.rpm'
21
141
  end
22
142
  end
23
143
 
144
+ describe "#spec_file" do
145
+ it "returns name of spec file" do
146
+ pkg = described_class.new :name => 'rails'
147
+ pkg.spec_file.should == 'rubygem-rails.spec'
148
+ end
149
+ end
150
+
24
151
  describe "#spec" do
25
- it "returns name of spec" do
26
- pkg = Polisher::GitPackage.new :name => 'rails'
27
- pkg.spec.should == 'rubygem-rails.spec'
152
+ it "returns handle to parsed Polisher::RPMSpec"
153
+ end
154
+
155
+ describe "#pkg_files" do
156
+ it "returns spec, .gitignore, sources"
157
+ end
158
+
159
+ describe "#path" do
160
+ it "returns Git Cache path for rpm name"
161
+ end
162
+
163
+ describe "#git_clone" do
164
+ it "is an alias for superclass#clone"
165
+ end
166
+
167
+ describe "#clone" do
168
+ it "clones package" do
169
+ # stub out glob / rm_rf
170
+ Dir.should_receive(:glob).and_return([])
171
+ FileUtils.should_receive(:rm_rf).at_least(:once)
172
+
173
+ pkg = described_class.new :name => 'rails'
174
+ pkg.should_receive(:in_repo).and_yield
175
+
176
+ expected = '/usr/bin/fedpkg clone rubygem-rails'
177
+ AwesomeSpawn.should_receive(:run).with(expected)
178
+ pkg.clone
28
179
  end
180
+
181
+ it "moves files from pkg subdir to current dir"
182
+ it "rm's pkg subdir"
29
183
  end
30
184
 
31
- describe "::clone" do
32
- context "package directory does not exist" do
33
- it "uses package command to clone package" do
34
- File.should_receive(:directory?).with('rubygem-rails').and_return(false)
35
- AwesomeSpawn.should_receive(:run).with("/usr/bin/fedpkg clone rubygem-rails")
36
- Dir.should_receive(:chdir) # stub out chdir
37
- AwesomeSpawn.should_receive(:run).at_least(3).times
38
- described_class.clone "rails"
185
+ describe "#dead?" do
186
+ before(:each) do
187
+ @pkg = described_class.new
188
+ @pkg.should_receive(:in_repo).and_yield
189
+ end
190
+
191
+ context "dead.package exists" do
192
+ it "returns true" do
193
+ File.should_receive(:exists?).with('dead.package').and_return(true)
194
+ @pkg.should be_dead
195
+ end
196
+ end
197
+
198
+ context "dead.package does not exist" do
199
+ it "returns false" do
200
+ File.should_receive(:exists?).with('dead.package').and_return(false)
201
+ @pkg.should_not be_dead
202
+ end
203
+ end
204
+ end
205
+
206
+ describe "#fetch" do
207
+ before(:each) do
208
+ @pkg = described_class.new
209
+ end
210
+
211
+ context "pkg not cloned" do
212
+ it "clones package" do
213
+ @pkg.should_receive(:dead?).and_return(false)
214
+ @pkg.should_receive(:reset!)
215
+ @pkg.should_receive(:checkout)
216
+ @pkg.should_receive(:pull)
217
+
218
+ @pkg.should_receive(:cloned?).and_return(false)
219
+ @pkg.should_receive(:clone)
220
+ @pkg.fetch
39
221
  end
40
222
  end
41
223
 
42
- it "changes dir to the pkg dir" do
43
- File.should_receive(:directory?).and_return(true) # stub out pull
44
- Dir.should_receive(:chdir).with('rubygem-rails')
45
- AwesomeSpawn.should_receive(:run).at_least(3).times # stub out calls to run
46
- described_class.clone "rails"
224
+ context "pkg cloned" do
225
+ it "does not clone pkg" do
226
+ @pkg.should_receive(:dead?).and_return(false)
227
+ @pkg.should_receive(:reset!)
228
+ @pkg.should_receive(:checkout)
229
+ @pkg.should_receive(:pull)
230
+
231
+ @pkg.should_receive(:cloned?).and_return(true)
232
+ @pkg.should_not_receive(:clone)
233
+ @pkg.fetch
234
+ end
47
235
  end
48
236
 
49
- context "dead.package file exists" do
237
+ context "pkg dead" do
50
238
  it "raises Exception" do
51
- File.should_receive(:directory?).and_return(true) # stub out pull
52
- Dir.should_receive(:chdir) # stub out chdir
53
- File.should_receive(:exists?).with('dead.package').and_return(true)
239
+ @pkg.should_receive(:cloned?).and_return(true)
240
+ @pkg.should_receive(:dead?).and_return(true)
54
241
  lambda{
55
- described_class.clone "rails"
242
+ @pkg.fetch
56
243
  }.should raise_error(Exception)
57
244
  end
58
245
  end
59
246
 
60
- it "checks out master branch" do
61
- File.should_receive(:directory?).and_return(true) # stub out pull
62
- Dir.should_receive(:chdir).with('rubygem-rails')
63
- AwesomeSpawn.should_receive(:run).with("/usr/bin/git checkout master")
64
- AwesomeSpawn.should_receive(:run).at_least(2).times # stub out calls to run
65
- described_class.clone "rails"
66
- end
247
+ it "checks out master" do
248
+ @pkg.should_receive(:cloned?).and_return(true)
249
+ @pkg.should_receive(:dead?).and_return(false)
250
+ @pkg.should_receive(:reset!)
251
+ @pkg.should_receive(:pull)
67
252
 
68
- it "resets head" do
69
- File.should_receive(:directory?).and_return(true) # stub out pull
70
- Dir.should_receive(:chdir).with('rubygem-rails')
71
- AwesomeSpawn.should_receive(:run).with("/usr/bin/git reset HEAD~ --hard")
72
- AwesomeSpawn.should_receive(:run).at_least(2).times # stub out calls to run
73
- described_class.clone "rails"
253
+ @pkg.should_receive(:checkout).with('master')
254
+ @pkg.fetch
74
255
  end
75
256
 
76
- it "pulls from remote" do
77
- File.should_receive(:directory?).and_return(true) # stub out pull
78
- Dir.should_receive(:chdir).with('rubygem-rails')
79
- AwesomeSpawn.should_receive(:run).with("/usr/bin/git pull")
80
- AwesomeSpawn.should_receive(:run).at_least(2).times # stub out calls to run
81
- described_class.clone "rails"
257
+ it "resets HEAD" do
258
+ @pkg.should_receive(:cloned?).and_return(true)
259
+ @pkg.should_receive(:dead?).and_return(false)
260
+ @pkg.should_receive(:checkout)
261
+ @pkg.should_receive(:pull)
262
+
263
+ @pkg.should_receive(:reset!)
264
+ @pkg.fetch
82
265
  end
83
266
 
84
- it "returns new GitPackage instance" do
85
- File.should_receive(:directory?).and_return(true) # stub out pull
86
- Dir.should_receive(:chdir).with('rubygem-rails')
87
- AwesomeSpawn.should_receive(:run).at_least(3).times # stub out calls to run
88
- pkg = described_class.clone("rails")
89
- pkg.should be_an_instance_of(described_class)
90
- pkg.name.should == 'rails'
267
+ it "pulls repo" do
268
+ @pkg.should_receive(:cloned?).and_return(true)
269
+ @pkg.should_receive(:dead?).and_return(false)
270
+ @pkg.should_receive(:reset!)
271
+ @pkg.should_receive(:checkout)
272
+
273
+
274
+ @pkg.should_receive(:pull)
275
+ @pkg.fetch
91
276
  end
92
277
  end
93
278
 
279
+ describe "#update_spec_to" do
280
+ it "updates spec version"
281
+ it "updates spec release"
282
+ end
283
+
284
+ describe "#gen_sources_for" do
285
+ it "writes gem md5sum to sources file"
286
+ end
287
+
288
+ describe "#ignore" do
289
+ it "adds gem to .gitignore file"
290
+ end
291
+
94
292
  describe "#update_to" do
95
293
  it "updates rpm spec"
96
- it "updates sources file"
97
- it "updates .gitignore file"
294
+ it "generates new sources file"
295
+ it "ignores gem"
98
296
  end
99
297
 
100
- describe "#build" do
101
- it "uses package command to build srpm" do
102
- AwesomeSpawn.should_receive(:run).with("/usr/bin/fedpkg srpm")
298
+ describe "#commit" do
299
+ it "git adds the pkg_files" do
300
+ pkg = described_class.new(:name => 'rails')
301
+ pkg.should_receive(:in_repo).at_least(:once).and_yield
302
+ pkg.should_receive(:pkg_files).and_return(['pkg_files'])
303
+ expected = "/usr/bin/git add pkg_files"
304
+ AwesomeSpawn.should_receive(:run).with(expected)
103
305
  AwesomeSpawn.should_receive(:run).at_least(:once)
104
- described_class.new.build
306
+ pkg.commit
105
307
  end
106
308
 
107
- it "uses build command to build srpm" do
108
- AwesomeSpawn.should_receive(:run).with("/usr/bin/koji build --scratch rawhide rubygem-rails-1.0.0-1.*.src.rpm")
309
+ it "commits the package with default msg" do
310
+ pkg = described_class.new(:name => 'rails', :version => '1.0.0')
311
+ pkg.should_receive(:in_repo).at_least(:once).and_yield
312
+ expected = "/usr/bin/git commit -m 'updated to 1.0.0'"
313
+ AwesomeSpawn.should_receive(:run).with(expected)
109
314
  AwesomeSpawn.should_receive(:run).at_least(:once)
110
- described_class.new(:name => 'rails', :version => '1.0.0').build
315
+ pkg.commit
111
316
  end
112
317
  end
113
318
 
114
- describe "#has_check?" do
115
- context "package spec has %check section" do
116
- it "returns true" do
117
- File.should_receive(:open).with("rubygem-rails.spec", "r").and_yield("%check")
118
- described_class.new(:name => "rails").has_check?.should be_true
119
- end
120
- end
121
-
122
- context "package spec does not have a %check section" do
123
- it "returns false" do
124
- File.should_receive(:open).with("rubygem-rails.spec", "r").and_yield("")
125
- described_class.new(:name => "rails").has_check?.should be_false
126
- end
319
+ describe "#build_srpm" do
320
+ it "uses package command to build srpm" do
321
+ pkg = described_class.new
322
+ pkg.should_receive(:in_repo).and_yield
323
+ AwesomeSpawn.should_receive(:run).with("/usr/bin/fedpkg srpm")
324
+ pkg.build_srpm
127
325
  end
128
326
  end
129
327
 
130
- describe "#commit" do
131
- it "git adds the sources, .gitignore, and spec files" do
132
- AwesomeSpawn.should_receive(:run).with("/usr/bin/git add rubygem-rails.spec sources .gitignore")
133
- AwesomeSpawn.should_receive(:run).at_least(:once)
134
- described_class.new(:name => 'rails').commit
328
+ describe "#scratch_build" do
329
+ it "uses build command to build srpm" do
330
+ pkg = described_class.new(:name => 'rails', :version => '1.0.0')
331
+ pkg.should_receive(:in_repo).and_yield
332
+ expected = "/usr/bin/koji build --scratch rawhide rubygem-rails-1.0.0-1.*.src.rpm"
333
+ AwesomeSpawn.should_receive(:run).with(expected)
334
+ pkg.scratch_build
135
335
  end
336
+ end
136
337
 
137
- it "commits the package" do
138
- AwesomeSpawn.should_receive(:run).with("/usr/bin/git commit -m 'updated to 1.0.0'")
139
- AwesomeSpawn.should_receive(:run).at_least(:once)
140
- described_class.new(:name => 'rails', :version => '1.0.0').commit
338
+ describe "#build" do
339
+ it "builds srpm and runs scratch build" do
340
+ pkg = described_class.new
341
+ pkg.should_receive(:build_srpm)
342
+ pkg.should_receive(:scratch_build)
343
+ pkg.build
141
344
  end
142
345
  end
143
346
 
144
347
  describe "#version_for" do
145
348
  it "uses git to retrieve the package" do
146
- AwesomeSpawn.should_receive(:run).with("/usr/bin/git clone #{described_class::DIST_GIT_URL}rubygem-rails.git .")
349
+ pkg = "#{described_class::DIST_GIT_URL}rubygem-rails.git"
350
+ dir = Polisher::GitCache.path_for('rubygem-rails')
351
+ expected = "/usr/bin/git clone #{pkg} #{dir}"
352
+ AwesomeSpawn.should_receive(:run).with(expected)
147
353
  described_class.version_for 'rails'
148
354
  end
149
355
 
150
- it "parses version from spec in git" do
356
+ it "returns version of the package" do
151
357
  AwesomeSpawn.should_receive(:run) # stub out run
152
- File.should_receive(:read).with("rubygem-rails.spec").and_return("contents")
153
- Polisher::RPMSpec.should_receive(:parse).with("contents").and_return(Polisher::RPMSpec.new)
154
- described_class.version_for 'rails'
155
- end
156
358
 
157
- it "returns version of the package" do
158
359
  spec = Polisher::RPMSpec.new :version => '1.0.0'
159
- AwesomeSpawn.should_receive(:run) # stub out run
160
- File.should_receive(:read).with("rubygem-rails.spec") # stub out read
161
- Polisher::RPMSpec.should_receive(:parse).and_return(spec)
360
+ pkg = described_class.new
361
+ described_class.should_receive(:new).and_return(pkg)
362
+ pkg.should_receive(:spec).and_return(spec)
363
+
162
364
  described_class.version_for('rails').should == '1.0.0'
163
365
  end
164
366
 
165
367
  it "invokes callback with version of package" do
166
- spec = Polisher::RPMSpec.new :version => '1.0.0'
167
368
  AwesomeSpawn.should_receive(:run) # stub out run
168
- File.should_receive(:read).with("rubygem-rails.spec") # stub out read
169
- Polisher::RPMSpec.should_receive(:parse).and_return(spec)
369
+
370
+ spec = Polisher::RPMSpec.new :version => '1.0.0'
371
+ pkg = described_class.new
372
+ described_class.should_receive(:new).and_return(pkg)
373
+ pkg.should_receive(:spec).and_return(spec)
170
374
 
171
375
  cb = proc {}
172
376
  cb.should_receive(:call).with(:git, 'rails', ['1.0.0'])