rubygems-test 0.1.0

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.
data/.gemtest ADDED
File without changes
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Erik Hollensbe and Josiah Kiehl
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,59 @@
1
+ = rubygems-test - commands and facilities for automated rubygems testing.
2
+
3
+ == For users
4
+
5
+ This installs three major features:
6
+
7
+ * a 'gem test' command.
8
+ * the ability to test your gems on installation, and uninstall them if they fail testing.
9
+ * A facility to upload your test results to rubygems.org (coming soon, see http://github.com/bluepojo/gem-testers)
10
+
11
+ === .gemrc
12
+
13
+ You can insert several things in your .gemrc to make things simpler. These all
14
+ live in the 'test_options' subsection, e.g.:
15
+
16
+ test_options:
17
+ use_rake_test: false
18
+ auto_test_on_install: true
19
+ test_on_install: true
20
+ install_development_dependencies: true
21
+ upload_results: false
22
+ force_install: false
23
+ force_uninstall_on_failure: false
24
+
25
+ All options are *false* by default. For some of them, if the value is unknown
26
+ or +false+, you will be prompted when it is required for testing.
27
+
28
+ The options:
29
+
30
+ auto_test_on_install:: runs the unit tests when 'gem install' is invoked.
31
+ test_on_install:: offer to test on install in general. 'auto_test_on_install' overrides this.
32
+ install_development_dependencies:: automatically install the development dependencies when testing. This is recommended.
33
+ upload_results:: upload results to http://gem-testers.org.
34
+ upload_service_url:: Set to a URL, it will upload to that service instead.
35
+ force_install:: always install, even on test failures.
36
+ force_uninstall_on_failure:: force uninstall when tests fail.
37
+
38
+ == For gem developers
39
+
40
+ Want your gem to be testable?
41
+
42
+ * Create (and add to your files section in your specification!) a '.gemtest' empty file. This is what signals the rubygems-test engine to process your gem as testable.
43
+ * Ensure 'rake test' works and doesn't wipe out filesystems, databases, etc. Move those tests to another task.
44
+ * Be sure to include your Rakefile in your gem, along with your tests.
45
+ * Be sure to note any development dependencies that will be required for executing your rakefile and your tests in your gemspec. They will be installed as a part of the testing process.
46
+
47
+ == Note on Patches/Pull Requests
48
+
49
+ * Fork the project.
50
+ * Make your feature addition or bug fix.
51
+ * Add tests for it. This is important so I don't break it in a
52
+ future version unintentionally.
53
+ * Commit, do not mess with rakefile, version, or history.
54
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
55
+ * Send me a pull request. Bonus points for topic branches.
56
+
57
+ == Copyright
58
+
59
+ Copyright (c) 2010 Erik Hollensbe and Josiah Kiehl. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "rubygems-test"
8
+ gem.summary = %Q{Gem testing facility as a plugin}
9
+ gem.description = %Q{Test gems on your system, upload the data to a service. Uninstall failing gems.}
10
+ gem.email = "erik@hollensbe.org"
11
+ gem.homepage = "http://github.com/erikh/rubygems-test"
12
+ gem.authors = ["Erik Hollensbe", "Josiah Kiehl"]
13
+ gem.files = Dir[".gemtest"] + Dir["Rakefile"] + Dir["gems/**/*"] + Dir["lib/**/*.rb"] + Dir["test/**/*.rb"]
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ #
16
+ gem.add_dependency 'rake'
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+ require 'rake/testtask'
24
+ Rake::TestTask.new(:interactive_test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.test_files = Dir["test/test_*.rb"] + Dir["test/interactive_test_*.rb"]
27
+ test.verbose = true
28
+ end
29
+
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.test_files = Dir["test/test_*.rb"]
33
+ test.verbose = true
34
+ end
35
+
36
+ begin
37
+ require 'rcov/rcovtask'
38
+ Rcov::RcovTask.new do |test|
39
+ test.libs << 'test'
40
+ test.pattern = 'test/**/test_*.rb'
41
+ test.verbose = true
42
+ end
43
+ rescue LoadError
44
+ task :rcov do
45
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
46
+ end
47
+ end
48
+
49
+ task :test => :check_dependencies
50
+
51
+ task :default => :test
52
+
53
+ require 'rake/rdoctask'
54
+ Rake::RDocTask.new do |rdoc|
55
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
56
+
57
+ rdoc.rdoc_dir = 'rdoc'
58
+ rdoc.title = "rubygems-test #{version}"
59
+ rdoc.rdoc_files.include('README*')
60
+ rdoc.rdoc_files.include('lib/**/*.rb')
61
+ end
data/gems/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:gemtest) do |test|
5
+ test.libs << 'lib' << 'test'
6
+ test.pattern = 'test/**/test_*.rb'
7
+ test.verbose = true
8
+ end
@@ -0,0 +1,32 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "test-gem"
3
+ s.version = "0.0.0"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Erik Hollensbe"]
7
+ s.date = %q{2010-11-12}
8
+ s.description = "GEM_TEST_DESCRIPTION"
9
+ s.email = %q{erik@hollensbe.org}
10
+ s.files = [
11
+ <%= @files %>
12
+ ].flatten
13
+ s.homepage = %q{http://example.org}
14
+ s.rdoc_options = ["--charset=UTF-8"]
15
+ s.require_paths = ["lib"]
16
+ s.rubygems_version = %q{1.3.7}
17
+ s.summary = %q{Gem testing facility as a plugin}
18
+ s.rubyforge_project = %q[foo]
19
+
20
+ <%= @development_dependencies %>
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
+ else
28
+ end
29
+ else
30
+ end
31
+ end
32
+
Binary file
@@ -0,0 +1,7 @@
1
+ require 'test/unit'
2
+
3
+ class TestPass < Test::Unit::TestCase
4
+ def test_01_pass
5
+ assert true
6
+ end
7
+ end
@@ -0,0 +1,266 @@
1
+ require 'rubygems/version_option'
2
+ require 'rubygems/source_index'
3
+ require 'rubygems/specification'
4
+ require 'rubygems/dependency_installer'
5
+ require 'rubygems/user_interaction'
6
+ require 'fileutils'
7
+ require 'pathname'
8
+ require 'rbconfig'
9
+ require 'yaml'
10
+ require 'open3'
11
+ require 'net/http'
12
+ require 'uri'
13
+ require 'ostruct'
14
+
15
+ class Gem::TestError < Gem::Exception; end
16
+ class Gem::RakeNotFoundError < Gem::Exception; end
17
+
18
+ class Gem::Commands::TestCommand < Gem::Command
19
+ include Gem::VersionOption
20
+ include Gem::DefaultUserInteraction
21
+
22
+ # taken straight out of rake
23
+ DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze
24
+
25
+ def description
26
+ 'Run the tests for a specific gem'
27
+ end
28
+
29
+ def arguments
30
+ "GEM: name of gem"
31
+ end
32
+
33
+ def usage
34
+ "#{program_name} GEM -v VERSION"
35
+ end
36
+
37
+ def initialize(spec=nil, on_install=false)
38
+ options = { }
39
+
40
+ if spec
41
+ options[:name] = spec.name
42
+ options[:version] = spec.version
43
+ end
44
+
45
+ @on_install = on_install
46
+
47
+ super 'test', description, options
48
+ add_version_option
49
+ end
50
+
51
+ #
52
+ # Retrieve the source index
53
+ #
54
+ def source_index
55
+ @gsi = Gem::SourceIndex.from_gems_in(*Gem::SourceIndex.installed_spec_directories)
56
+ end
57
+
58
+ #
59
+ # Get the config in our namespace
60
+ #
61
+ def config
62
+ @config ||= Gem.configuration["test_options"] || { }
63
+ end
64
+
65
+ #
66
+ # find a gem given a name and version
67
+ #
68
+ def find_gem(name, version)
69
+ spec = source_index.find_name(name, version).last
70
+ unless spec and (spec.installation_path rescue nil)
71
+ alert_error "Could not find gem #{name} (#{version})"
72
+ raise Gem::GemNotFoundException, "Could not find gem #{name}, (#{version})"
73
+ end
74
+
75
+ return spec
76
+ end
77
+
78
+ #
79
+ # Locate the rakefile for a gem name and version
80
+ #
81
+ def find_rakefile(spec)
82
+ rakefile = DEFAULT_RAKEFILES.
83
+ map { |x| File.join(spec.full_gem_path, x) }.
84
+ find { |x| File.exist?(x) }
85
+
86
+ unless(File.exist?(rakefile) rescue nil)
87
+ alert_error "Couldn't find rakefile -- this gem cannot be tested. Aborting."
88
+ raise Gem::RakeNotFoundError, "Couldn't find rakefile, gem #{spec.name} (#{spec.version}) cannot be tested."
89
+ end
90
+ end
91
+
92
+ #
93
+ # Locate rake itself, prefer gems version.
94
+ #
95
+ def find_rake
96
+ rake_path = Gem.bin_path('rake') rescue File.join(RbConfig::CONFIG["bindir"], 'rake')
97
+
98
+ unless File.exist?(rake_path)
99
+ alert_error "Couldn't find rake; rubygems-test will not work without it. Aborting."
100
+ raise Gem::RakeNotFoundError, "Couldn't find rake; rubygems-test will not work without it."
101
+ end
102
+
103
+ return rake_path
104
+ end
105
+
106
+ #
107
+ # Install development dependencies for the gem we're about to test.
108
+ #
109
+ def install_dependencies(spec)
110
+ di = Gem::DependencyInstaller.new
111
+
112
+ spec.development_dependencies.each do |dep|
113
+ unless source_index.search(dep).last
114
+ if config["install_development_dependencies"]
115
+ say "Installing test dependency #{dep.name} (#{dep.requirement})"
116
+ di.install(dep)
117
+ else
118
+ if ask_yes_no("Install development dependency #{dep.name} (#{dep.requirement})?", true)
119
+ say "Installing test dependency #{dep.name} (#{dep.requirement})"
120
+ di.install(dep)
121
+ else
122
+ alert_error "Failed to install dependencies required to run tests. Aborting."
123
+ raise Gem::TestError
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ #
131
+ # Upload +yaml+ Results to +results_url+.
132
+ #
133
+
134
+ def upload_results(yaml)
135
+ begin
136
+ results_url = config["upload_service_url"] || 'http://gem-testers.org/test_results' # FIXME
137
+ url = URI.parse(results_url)
138
+ response = Net::HTTP.post_form url, {:results => yaml}
139
+ rescue Errno::ECONNREFUSED => e
140
+ say 'Unable to post test results. Can\'t connect to the results server.'
141
+ rescue => e
142
+ say e.message
143
+ else
144
+ case response
145
+ when Net::HTTPSuccess
146
+ body = YAML::load(response.body)
147
+ url = body[:data][0] if body[:data]
148
+ say "Test results posted successfully! \n\t#{url}"
149
+ when Net::HTTPRedirection
150
+ upload_results yaml, response.fetch('Location')
151
+ when Net::HTTPNotFound
152
+ say %q[Unable to find where to put the test results. Try: `gem update rubygems-test`]
153
+ when Net::HTTPClientError
154
+ say %q[Results server didn't like the results submission. Try: `gem update rubygems-test`]
155
+ when Net::HTTPServerError
156
+ say %q[Oof. Something went wrong on the results server processing these results. Sorry!]
157
+ else
158
+ say %q[Something weird happened. Probably a bug.]
159
+ end
160
+ end
161
+ end
162
+
163
+ #
164
+ # Gather system results, test results into a YAML format ready for delivery.
165
+ #
166
+ def gather_results(spec, output, result)
167
+ {
168
+ :arch => RbConfig::CONFIG["arch"],
169
+ :vendor => RbConfig::CONFIG["target_vendor"],
170
+ :os => RbConfig::CONFIG["target_os"],
171
+ :machine_arch => RbConfig::CONFIG["target_cpu"],
172
+ :name => spec.name,
173
+ :version => spec.version,
174
+ :platform => spec.platform,
175
+ :ruby_version => RUBY_VERSION,
176
+ :result => result,
177
+ :test_output => output
178
+ }.to_yaml
179
+ end
180
+
181
+
182
+ #
183
+ # Run the tests with the appropriate spec and rake_path, and capture all
184
+ # output.
185
+ #
186
+ def run_tests(spec, rake_path)
187
+ pwd = FileUtils.pwd
188
+
189
+ FileUtils.chdir(spec.full_gem_path)
190
+
191
+ output = ""
192
+ exit_status = nil
193
+
194
+ if spec.files.include?(".gemtest")
195
+ Open3.popen3(rake_path, "test", '--trace') do |stdin, stdout, stderr, thr|
196
+ loop do
197
+ if stdout.eof? and stderr.eof?
198
+ break
199
+ end
200
+
201
+ buf = ""
202
+
203
+ handles, _, _ = IO.select([stdout, stderr].reject { |x| x.closed? || x.eof? }, nil, nil, 0.1)
204
+
205
+ begin
206
+ handles.each { |io| io.readpartial(16384, buf) } if handles
207
+ rescue EOFError, IOError
208
+ next
209
+ end
210
+
211
+ output += buf
212
+
213
+ print buf
214
+ end
215
+
216
+ exit_status = thr.value
217
+ end
218
+
219
+ if config["upload_results"] or
220
+ (!config.has_key?("upload_results") and ask_yes_no("Upload these results to rubygems.org?", true))
221
+
222
+ upload_results(gather_results(spec, output, exit_status.exitstatus == 0))
223
+ end
224
+
225
+ if exit_status.exitstatus != 0
226
+ alert_error "Tests did not pass. Examine the output and report it to the author!"
227
+
228
+ FileUtils.chdir(pwd)
229
+
230
+ raise Gem::TestError
231
+ end
232
+ else
233
+ alert_warning "This gem has no tests! Please contact the author to gain testing and reporting!"
234
+ end
235
+
236
+ FileUtils.chdir(pwd)
237
+ end
238
+
239
+ #
240
+ # Execute routine. This is where the magic happens.
241
+ #
242
+ def execute
243
+ begin
244
+ version = options[:version] || Gem::Requirement.default
245
+
246
+ (get_all_gem_names rescue [options[:name]]).each do |name|
247
+ spec = find_gem(name, version)
248
+
249
+ # we find rake and the rakefile first to eliminate needlessly installing
250
+ # dependencies.
251
+ find_rakefile(spec)
252
+ rake_path = find_rake
253
+
254
+ install_dependencies(spec)
255
+
256
+ run_tests(spec, rake_path)
257
+ end
258
+ rescue Exception => e
259
+ if @on_install
260
+ raise e
261
+ else
262
+ terminate_interaction 1
263
+ end
264
+ end
265
+ end
266
+ end
@@ -0,0 +1,25 @@
1
+ require 'rubygems/uninstaller'
2
+ require 'rubygems/commands/test_command'
3
+
4
+ Gem.post_install do |gem|
5
+ options = Gem.configuration["test_options"] || { }
6
+
7
+ if options["auto_test_on_install"] or options["test_on_install"]
8
+ if options["auto_test_on_install"] or
9
+ gem.ui.ask_yes_no("Test #{gem.spec.name} (#{gem.spec.version})?", true)
10
+
11
+ begin
12
+ Gem::Commands::TestCommand.new(gem.spec, true).execute
13
+ rescue Gem::RakeNotFoundError, Gem::TestError
14
+ if (options.has_key?("force_install") and !options["force_install"]) or
15
+ options["force_uninstall_on_failure"] or
16
+ gem.ui.ask_yes_no("Testing #{gem.spec.name} (#{gem.spec.version}) failed. Uninstall?", false)
17
+
18
+ # FIXME ask drbrain how to do this more better.
19
+ at_exit { Gem::Uninstaller.new(gem.spec.name, :version => gem.spec.version).uninstall }
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems/command_manager'
2
+ require 'rubygems/on_install_test'
3
+
4
+ # shamelessly taken from gemcutter.
5
+
6
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.3.6')
7
+ %w[test].each do |command|
8
+ Gem::CommandManager.instance.register_command command.to_sym
9
+ end
10
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,72 @@
1
+ require 'rubygems'
2
+ require 'rubygems/builder'
3
+ require 'rubygems/installer'
4
+ require 'rubygems/uninstaller'
5
+ require 'test/unit'
6
+ require 'erb'
7
+ require 'tempfile'
8
+ require 'fileutils'
9
+
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
11
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
12
+
13
+ require 'rubygems/commands/test_command'
14
+
15
+ class Test::Unit::TestCase
16
+ def install_stub_gem(hash)
17
+ file = Tempfile.new("rubygems-test")
18
+ file.write(template_gemspec(hash))
19
+ path = file.path
20
+ file.close
21
+
22
+ pwd = FileUtils.pwd
23
+ FileUtils.chdir('gems')
24
+
25
+ spec = eval File.read(path)
26
+ filename = Gem::Builder.new(spec).build
27
+ Gem::Installer.new(filename).install
28
+
29
+ FileUtils.chdir(pwd)
30
+ end
31
+
32
+ def uninstall_stub_gem
33
+ Gem::Uninstaller.new("test-gem").uninstall
34
+ end
35
+
36
+ def template_gemspec(hash)
37
+ erb = ERB.new(File.read(File.join('gems', 'template.gemspec')))
38
+
39
+ @development_dependencies = ""
40
+ (hash[:development_dependencies] || []).each do |dep|
41
+ @development_dependencies += "s.add_development_dependency '#{dep}'\n"
42
+ end
43
+
44
+ @files = hash[:files] || "'Rakefile', Dir['test/**/*']"
45
+
46
+ if @files.kind_of?(Array)
47
+ @files = @files.map { |x| "'#{x}'" }.join(",\n")
48
+ end
49
+
50
+ return erb.result(binding)
51
+ end
52
+
53
+ def set_configuration(hash)
54
+ Gem.configuration["test_options"] = hash
55
+ Gem.configuration.verbose = false
56
+ end
57
+
58
+ def setup
59
+ set_configuration({ })
60
+ end
61
+ end
62
+
63
+ class Test::Unit::TestCase::Interactive < Test::Unit::TestCase
64
+ def setup
65
+ super
66
+
67
+ require 'rubygems/on_install_test'
68
+ puts
69
+ puts "----- This test is interactive -----"
70
+ puts
71
+ end
72
+ end
@@ -0,0 +1,13 @@
1
+ require 'helper'
2
+
3
+ class TestRubyGemsOnInstallTest < Test::Unit::TestCase::Interactive
4
+ def test_01_successfully_uninstalls_on_test_failure
5
+ set_configuration({ "force_uninstall_on_failure" => true, "auto_test_on_install" => true })
6
+ install_stub_gem(:files => [])
7
+ end
8
+
9
+ def test_02_successfully_installs_on_test_pass
10
+ set_configuration({ "auto_test_on_install" => true, "upload_results" => false })
11
+ install_stub_gem(:files => %w[test/test_pass.rb Rakefile])
12
+ end
13
+ end
@@ -0,0 +1,85 @@
1
+ require 'helper'
2
+ require 'rbconfig'
3
+ require 'yaml'
4
+
5
+ class TestExecute < Test::Unit::TestCase
6
+ def setup
7
+ super
8
+ @test = Gem::Commands::TestCommand.new
9
+ end
10
+
11
+ def test_01_config
12
+ set_configuration({ "auto_test_on_install" => true })
13
+ assert @test.config
14
+ assert @test.config.has_key?("auto_test_on_install")
15
+ assert @test.config["auto_test_on_install"]
16
+ end
17
+
18
+ def test_02_gem_command_attributes
19
+ assert_equal @test.description, "Run the tests for a specific gem"
20
+ assert_equal @test.arguments, "GEM: name of gem"
21
+ assert_equal @test.usage, "#{@test.program_name} GEM -v VERSION"
22
+ end
23
+
24
+ def test_03_source_index
25
+ install_stub_gem({ })
26
+
27
+ assert @test.source_index
28
+ assert_kind_of Array, @test.source_index.find_name("test-gem", Gem::Version.new("0.0.0"))
29
+ assert_kind_of Gem::Specification, @test.source_index.find_name("test-gem", Gem::Version.new("0.0.0")).last
30
+
31
+ uninstall_stub_gem
32
+ end
33
+
34
+ def test_04_find_gem
35
+ install_stub_gem({ })
36
+
37
+ assert_kind_of Gem::Specification, @test.find_gem("test-gem", "0.0.0")
38
+
39
+ uninstall_stub_gem
40
+
41
+ assert_raises(Gem::GemNotFoundException) { @test.find_gem("test-gem", "0.0.0") }
42
+ end
43
+
44
+ def test_05_find_rakefile
45
+ install_stub_gem({ :files => ["Rakefile"] })
46
+
47
+ assert_nothing_raised { @test.find_rakefile(@test.find_gem("test-gem", "0.0.0")) }
48
+
49
+ uninstall_stub_gem
50
+ install_stub_gem({ :files => "" })
51
+
52
+ assert_raises(Gem::RakeNotFoundError) { @test.find_rakefile(@test.find_gem("test-gem", "0.0.0")) }
53
+
54
+ uninstall_stub_gem
55
+ end
56
+
57
+ def test_06_find_rake
58
+ # XXX how do I test this fully without nuking rake?
59
+ assert_nothing_raised { @test.find_rake }
60
+ assert_not_nil @test.find_rake
61
+ end
62
+
63
+ def test_07_gather_results
64
+ install_stub_gem({})
65
+
66
+ spec = @test.find_gem("test-gem", "0.0.0")
67
+ output = "foo"
68
+
69
+ hash = {
70
+ :arch => RbConfig::CONFIG["arch"],
71
+ :vendor => RbConfig::CONFIG["target_vendor"],
72
+ :os => RbConfig::CONFIG["target_os"],
73
+ :machine_arch => RbConfig::CONFIG["target_cpu"],
74
+ :ruby_version => RUBY_VERSION,
75
+ :result => true,
76
+ :name => spec.name,
77
+ :version => spec.version,
78
+ :platform => spec.platform,
79
+ :test_output => output
80
+ }
81
+
82
+
83
+ assert_equal YAML.load(@test.gather_results(spec, output, true)), hash
84
+ end
85
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubygems-test
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Erik Hollensbe
13
+ - Josiah Kiehl
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-15 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rake
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Test gems on your system, upload the data to a service. Uninstall failing gems.
35
+ email: erik@hollensbe.org
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - LICENSE
42
+ - README.rdoc
43
+ files:
44
+ - .gemtest
45
+ - Rakefile
46
+ - gems/Rakefile
47
+ - gems/template.gemspec
48
+ - gems/test-gem-0.0.0.gem
49
+ - gems/test/test_pass.rb
50
+ - lib/rubygems/commands/test_command.rb
51
+ - lib/rubygems/on_install_test.rb
52
+ - lib/rubygems_plugin.rb
53
+ - test/helper.rb
54
+ - test/interactive_test_on-install.rb
55
+ - test/test_execute.rb
56
+ - LICENSE
57
+ - README.rdoc
58
+ has_rdoc: true
59
+ homepage: http://github.com/erikh/rubygems-test
60
+ licenses: []
61
+
62
+ post_install_message:
63
+ rdoc_options: []
64
+
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ requirements: []
84
+
85
+ rubyforge_project:
86
+ rubygems_version: 1.3.7
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Gem testing facility as a plugin
90
+ test_files:
91
+ - test/helper.rb
92
+ - test/interactive_test_on-install.rb
93
+ - test/test_execute.rb