polisher 0.5.1 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,5 +10,20 @@ module Polisher
10
10
  describe "#gems_owned_by" do
11
11
  it "retrieves gems owned by the specified user"
12
12
  end
13
+
14
+ describe "#versions_for" do
15
+ it "dispatches to bodhi to retrieve / return versions" do
16
+ Polisher::Bodhi.should_receive(:versions_for).with('rails').and_return(['1.0.0'])
17
+ described_class.versions_for('rails').should == ['1.0.0']
18
+ end
19
+
20
+ it "should invoke callback" do
21
+ Polisher::Bodhi.should_receive(:versions_for).with('rails').
22
+ and_yield(:bodhi, 'rails', ['1.0.0'])
23
+ cb = proc {}
24
+ cb.should_receive(:call).with(:fedora, 'rails', ['1.0.0'])
25
+ described_class.versions_for('rails', &cb)
26
+ end
27
+ end
13
28
  end # describe Fedora
14
29
  end # module Polisher
@@ -28,20 +28,67 @@ module Polisher
28
28
  end
29
29
  end
30
30
 
31
- describe "#clone" do
31
+ describe "::clone" do
32
32
  context "package directory does not exist" do
33
- it "uses package command to clone package"
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"
39
+ end
40
+ end
41
+
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"
34
47
  end
35
48
 
36
49
  context "dead.package file exists" do
37
- it "raises Exception"
50
+ 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)
54
+ lambda{
55
+ described_class.clone "rails"
56
+ }.should raise_error(Exception)
57
+ end
58
+ end
59
+
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
67
+
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"
38
74
  end
39
75
 
40
- it "checks out master branch"
41
- it "resets head"
42
- it "pulls from remote"
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"
82
+ end
43
83
 
44
- it "returns new GitPackage instance"
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'
91
+ end
45
92
  end
46
93
 
47
94
  describe "#update_to" do
@@ -51,23 +98,80 @@ module Polisher
51
98
  end
52
99
 
53
100
  describe "#build" do
54
- it "uses package command to build srpm"
55
- it "uses build command to build srpm"
101
+ it "uses package command to build srpm" do
102
+ AwesomeSpawn.should_receive(:run).with("/usr/bin/fedpkg srpm")
103
+ AwesomeSpawn.should_receive(:run).at_least(:once)
104
+ described_class.new.build
105
+ end
106
+
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")
109
+ AwesomeSpawn.should_receive(:run).at_least(:once)
110
+ described_class.new(:name => 'rails', :version => '1.0.0').build
111
+ end
56
112
  end
57
113
 
58
114
  describe "#has_check?" do
59
115
  context "package spec has %check section" do
60
- it "returns true"
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
61
120
  end
62
121
 
63
122
  context "package spec does not have a %check section" do
64
- it "returns false"
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
65
127
  end
66
128
  end
67
129
 
68
130
  describe "#commit" do
69
- it "git adds the sources, .gitignore, and spec files"
70
- it "commits the package"
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
135
+ end
136
+
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
141
+ end
142
+ end
143
+
144
+ describe "#version_for" do
145
+ 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 .")
147
+ described_class.version_for 'rails'
148
+ end
149
+
150
+ it "parses version from spec in git" do
151
+ 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
+
157
+ it "returns version of the package" do
158
+ 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)
162
+ described_class.version_for('rails').should == '1.0.0'
163
+ end
164
+
165
+ it "invokes callback with version of package" do
166
+ spec = Polisher::RPMSpec.new :version => '1.0.0'
167
+ 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)
170
+
171
+ cb = proc {}
172
+ cb.should_receive(:call).with(:git, 'rails', ['1.0.0'])
173
+ described_class.version_for('rails', &cb)
174
+ end
71
175
  end
72
176
 
73
177
  end # describe GitPackage
@@ -0,0 +1,71 @@
1
+ # Polisher Koji Spec
2
+ #
3
+ # Licensed under the MIT license
4
+ # Copyright (C) 2013 Red Hat, Inc.
5
+
6
+ require 'polisher/koji'
7
+
8
+ module Polisher
9
+ describe Koji do
10
+ describe "::has_build?" do
11
+ context "retrieved versions includes the specified version" do
12
+ it "returns true" do
13
+ described_class.should_receive(:versions_for).and_return(['1.0.0'])
14
+ described_class.has_build?('foobar', '1.0.0').should be_true
15
+ end
16
+ end
17
+
18
+ context "retrieved versions does not include the specified version" do
19
+ it "returns false" do
20
+ described_class.should_receive(:versions_for).and_return(['1.0.1'])
21
+ described_class.has_build?('foobar', '1.0.1').should be_true
22
+ end
23
+ end
24
+ end
25
+
26
+ describe "#has_build_satisfying?" do
27
+ context "retrieved versions satisfy the specified dependency" do
28
+ it "returns true" do
29
+ described_class.should_receive(:versions_for).and_return(['1.0.0'])
30
+ described_class.has_build_satisfying?('foobar', '> 0.9.0').should be_true
31
+ end
32
+ end
33
+
34
+ context "retrieved versions does not satisfy the specified dependency" do
35
+ it "returns false" do
36
+ described_class.should_receive(:versions_for).and_return(['1.0.0'])
37
+ described_class.has_build_satisfying?('foobar', '< 0.9.0').should be_false
38
+ end
39
+ end
40
+ end
41
+
42
+ describe "#versions_for" do
43
+ before(:each) do
44
+ @client = double(XMLRPC::Client)
45
+ described_class.should_receive(:client).and_return(@client)
46
+ end
47
+
48
+ it "uses xmlrpc client to retreive versions" do
49
+ expected = ['listTagged', described_class.koji_tag, nil, false,
50
+ nil, false, "rubygem-rails"]
51
+ @client.should_receive(:call).with(*expected).and_return([])
52
+ described_class.versions_for 'rails'
53
+ end
54
+
55
+ it "returns versions" do
56
+ versions = [{'version' => '1.0.0'}]
57
+ @client.should_receive(:call).and_return(versions)
58
+ described_class.versions_for('rails').should == ['1.0.0']
59
+ end
60
+
61
+ it "invokes block with versions" do
62
+ versions = [{'version' => '1.0.0'}]
63
+ @client.should_receive(:call).and_return(versions)
64
+
65
+ cb = proc {}
66
+ cb.should_receive(:call).with(:koji, 'rails', ['1.0.0'])
67
+ described_class.versions_for('rails', &cb)
68
+ end
69
+ end
70
+ end # describe Koji
71
+ end # module Polisher
@@ -3,7 +3,10 @@
3
3
  # Licensed under the MIT license
4
4
  # Copyright (C) 2013 Red Hat, Inc.
5
5
 
6
+ require 'spec_helper'
7
+
6
8
  require 'polisher/rpmspec'
9
+ require 'polisher/gem'
7
10
 
8
11
  module Polisher
9
12
  describe RPMSpec do
@@ -73,11 +76,14 @@ module Polisher
73
76
  it "updates dependencies from gem" do
74
77
  spec = Polisher::RPMSpec.new :requires => ['rubygem(rake)', 'rubygem(activerecord)'],
75
78
  :build_requires => []
76
- gem = Polisher::Gem.new :deps => ['rake', 'rails'], :dev_deps => ['rspec']
79
+ gem = Polisher::Gem.new :deps => [::Gem::Dependency.new('rake'),
80
+ ::Gem::Dependency.new('rails', '~> 10')],
81
+ :dev_deps => [::Gem::Dependency.new('rspec', :development)]
77
82
 
78
83
  spec.update_to(gem)
79
- spec.requires.should == ['rubygem(activerecord)', 'rubygem(rake)', 'rubygem(rails)']
80
- spec.build_requires.should == ['rubygem(rspec)']
84
+ spec.requires.should == ['rubygem(activerecord)', 'rubygem(rake) >= 0',
85
+ 'rubygem(rails) => 10', 'rubygem(rails) < 11']
86
+ spec.build_requires.should == ['rubygem(rspec) >= 0']
81
87
  end
82
88
 
83
89
  it "adds new files from gem" do
@@ -12,7 +12,9 @@ module Polisher
12
12
  :name => 'mysql',
13
13
  :version => '2.9.1',
14
14
  :deps => [],
15
- :dev_deps => ['rdoc', 'rake-compiler', 'hoe']
15
+ :dev_deps => [::Gem::Dependency.new('rdoc', '~> 3.10', :development),
16
+ ::Gem::Dependency.new('rake-compiler', '~> 0.8.1', :development),
17
+ ::Gem::Dependency.new('hoe', '~> 3.5', :development)]
16
18
  }
17
19
 
18
20
  GEM_JSON = {
@@ -20,7 +22,13 @@ module Polisher
20
22
  :json => File.read("#{SPEC_DIR}/data/rails.json"),
21
23
  :name => 'rails',
22
24
  :version => '4.0.1',
23
- :deps => ["actionmailer", "actionpack", "activerecord", "activesupport", "bundler", "railties", "sprockets-rails"],
25
+ :deps => [::Gem::Dependency.new("actionmailer", '= 4.0.1'),
26
+ ::Gem::Dependency.new("actionpack", '= 4.0.1'),
27
+ ::Gem::Dependency.new("activerecord", '= 4.0.1'),
28
+ ::Gem::Dependency.new("activesupport", '= 4.0.1'),
29
+ ::Gem::Dependency.new("bundler", "< 2.0", ">= 1.3.0"),
30
+ ::Gem::Dependency.new("railties", '= 4.0.1'),
31
+ ::Gem::Dependency.new("sprockets-rails", '~> 2.0.0')],
24
32
  :dev_deps => []
25
33
  }
26
34
 
@@ -31,7 +39,9 @@ module Polisher
31
39
  :contents => File.read("#{SPEC_DIR}/data/rspec-2.12.0.gem"),
32
40
  :name => 'rspec',
33
41
  :version => '2.12.0',
34
- :deps => ['rspec-core', 'rspec-expectations', 'rspec-mocks'],
42
+ :deps => [::Gem::Dependency.new('rspec-core', '~> 2.14.0'),
43
+ ::Gem::Dependency.new('rspec-expectations', '~> 2.14.0'),
44
+ ::Gem::Dependency.new('rspec-mocks', '~> 2.14.0')],
35
45
  :dev_deps => [],
36
46
  :files => ['/License.txt', '/README.md', '/lib', '/lib/rspec', '/lib/rspec/version.rb', '/lib/rspec.rb']
37
47
  }
@@ -0,0 +1,37 @@
1
+ # Polisher Yum Spec
2
+ #
3
+ # Licensed under the MIT license
4
+ # Copyright (C) 2013 Red Hat, Inc.
5
+
6
+ require 'polisher/yum'
7
+
8
+ module Polisher
9
+ describe Yum do
10
+ describe "#versions_for" do
11
+ before(:each) do
12
+ end
13
+
14
+ it "uses yum to retreive versions" do
15
+ expected = "/usr/bin/yum info rubygem-rails"
16
+ result = AwesomeSpawn::CommandResult.new expected, "", "", 0
17
+ AwesomeSpawn.should_receive(:run).with(expected).and_return(result)
18
+ described_class.version_for "rails"
19
+ end
20
+
21
+ it "returns versions" do
22
+ result = AwesomeSpawn::CommandResult.new "", "Version: 1.0.0", "", 0
23
+ AwesomeSpawn.should_receive(:run).and_return(result)
24
+ described_class.version_for("rails") == '1.0.0'
25
+ end
26
+
27
+ it "invokes block with versions" do
28
+ cb = proc {}
29
+ cb.should_receive(:call).with(:yum, 'rails', ['1.0.0'])
30
+
31
+ result = AwesomeSpawn::CommandResult.new "", "Version: 1.0.0", "", 0
32
+ AwesomeSpawn.should_receive(:run).and_return(result)
33
+ described_class.version_for("rails", &cb)
34
+ end
35
+ end
36
+ end # describe Koji
37
+ end # module Polisher
metadata CHANGED
@@ -1,15 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Frey
8
8
  - Mo Morsi
9
+ - Joe Rafaniello
10
+ - Ken Dreyer
9
11
  autorequire:
10
12
  bindir: bin
11
13
  cert_chain: []
12
- date: 2013-12-05 00:00:00.000000000 Z
14
+ date: 2014-01-14 00:00:00.000000000 Z
13
15
  dependencies:
14
16
  - !ruby/object:Gem::Dependency
15
17
  name: json
@@ -109,6 +111,34 @@ dependencies:
109
111
  - - '>='
110
112
  - !ruby/object:Gem::Version
111
113
  version: '0'
114
+ - !ruby/object:Gem::Dependency
115
+ name: awesome_spawn
116
+ requirement: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :runtime
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ - !ruby/object:Gem::Dependency
129
+ name: gem2rpm
130
+ requirement: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ type: :runtime
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
112
142
  - !ruby/object:Gem::Dependency
113
143
  name: rspec
114
144
  requirement: !ruby/object:Gem::Requirement
@@ -123,10 +153,13 @@ dependencies:
123
153
  - - '>='
124
154
  - !ruby/object:Gem::Version
125
155
  version: 2.0.0
126
- description: Ruby Project Post-Publishing Processor
156
+ description: General API and utility scripts to manipulate and query ruby gems and
157
+ projects after being published
127
158
  email:
128
159
  - Fryguy@users.noreply.github.com
129
- - mmorsi@redhat.com
160
+ - mo@morsi.org
161
+ - jrafanie@redhat.com
162
+ - ktdreyer@ktdreyer.com
130
163
  executables:
131
164
  - binary_gem_resolver.rb
132
165
  - gem_dependency_checker.rb
@@ -138,6 +171,7 @@ files:
138
171
  - lib/polisher/core.rb
139
172
  - lib/polisher/bodhi.rb
140
173
  - lib/polisher/fedora.rb
174
+ - lib/polisher/version.rb
141
175
  - lib/polisher/apt.rb
142
176
  - lib/polisher/version_checker.rb
143
177
  - lib/polisher/vendor.rb
@@ -154,13 +188,23 @@ files:
154
188
  - lib/polisher/yum.rb
155
189
  - lib/polisher.rb
156
190
  - spec/git_spec.rb
191
+ - spec/bodhi_spec.rb
157
192
  - spec/spec_helper.rb
193
+ - spec/errata_spec.rb
158
194
  - spec/gemfile_spec.rb
195
+ - spec/koji_spec.rb
159
196
  - spec/gem_spec.rb
197
+ - spec/yum_spec.rb
160
198
  - spec/upstream_spec.rb
161
199
  - spec/rpmspec_spec.rb
162
200
  - spec/fedora_spec.rb
163
201
  - spec/core_spec.rb
202
+ - spec/data/rails.json
203
+ - spec/data/rubygem-activesupport.spec
204
+ - spec/data/Gemfile
205
+ - spec/data/rspec.json
206
+ - spec/data/mysql-2.9.1.gemspec
207
+ - spec/data/rspec-2.12.0.gem
164
208
  - LICENSE
165
209
  - Rakefile
166
210
  - README.md
@@ -168,7 +212,7 @@ files:
168
212
  - bin/gem_dependency_checker.rb
169
213
  - bin/git_gem_updater.rb
170
214
  - bin/ruby_rpm_spec_updater.rb
171
- homepage: http://github.com/ManageIQ/polisher
215
+ homepage: https://github.com/ManageIQ/polisher
172
216
  licenses:
173
217
  - MIT
174
218
  metadata: {}
@@ -191,7 +235,6 @@ rubyforge_project:
191
235
  rubygems_version: 2.0.11
192
236
  signing_key:
193
237
  specification_version: 4
194
- summary: General API and utility scripts to manipulate and query ruby gems and projects
195
- after being published
238
+ summary: Ruby Project Post-Publishing Processor
196
239
  test_files: []
197
240
  has_rdoc: