rspec 2.0 support
This commit is contained in:
parent
ca4b97443e
commit
05410b1af5
2
Rakefile
2
Rakefile
|
@ -11,7 +11,7 @@ begin
|
||||||
gem.homepage = "http://github.com/ngauthier/hydra"
|
gem.homepage = "http://github.com/ngauthier/hydra"
|
||||||
gem.authors = ["Nick Gauthier"]
|
gem.authors = ["Nick Gauthier"]
|
||||||
gem.add_development_dependency "shoulda", "= 2.10.3"
|
gem.add_development_dependency "shoulda", "= 2.10.3"
|
||||||
gem.add_development_dependency "rspec", "= 1.3.0"
|
gem.add_development_dependency "rspec", "= 2.0.0.beta.19"
|
||||||
gem.add_development_dependency "cucumber", "= 0.8.5"
|
gem.add_development_dependency "cucumber", "= 0.8.5"
|
||||||
gem.add_development_dependency "therubyracer", "= 0.7.4"
|
gem.add_development_dependency "therubyracer", "= 0.7.4"
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
||||||
|
|
||||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||||
s.authors = ["Nick Gauthier"]
|
s.authors = ["Nick Gauthier"]
|
||||||
s.date = %q{2010-08-20}
|
s.date = %q{2010-08-23}
|
||||||
s.default_executable = %q{warmsnake.rb}
|
s.default_executable = %q{warmsnake.rb}
|
||||||
s.description = %q{Spread your tests over multiple machines to test your code faster.}
|
s.description = %q{Spread your tests over multiple machines to test your code faster.}
|
||||||
s.email = %q{nick@smartlogicsolutions.com}
|
s.email = %q{nick@smartlogicsolutions.com}
|
||||||
|
@ -112,18 +112,18 @@ Gem::Specification.new do |s|
|
||||||
|
|
||||||
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
||||||
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
|
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||||
s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
|
s.add_development_dependency(%q<rspec>, ["= 2.0.0.beta.19"])
|
||||||
s.add_development_dependency(%q<cucumber>, ["= 0.8.5"])
|
s.add_development_dependency(%q<cucumber>, ["= 0.8.5"])
|
||||||
s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
|
s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||||
else
|
else
|
||||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||||
s.add_dependency(%q<rspec>, ["= 1.3.0"])
|
s.add_dependency(%q<rspec>, ["= 2.0.0.beta.19"])
|
||||||
s.add_dependency(%q<cucumber>, ["= 0.8.5"])
|
s.add_dependency(%q<cucumber>, ["= 0.8.5"])
|
||||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||||
s.add_dependency(%q<rspec>, ["= 1.3.0"])
|
s.add_dependency(%q<rspec>, ["= 2.0.0.beta.19"])
|
||||||
s.add_dependency(%q<cucumber>, ["= 0.8.5"])
|
s.add_dependency(%q<cucumber>, ["= 0.8.5"])
|
||||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||||
end
|
end
|
||||||
|
|
|
@ -107,7 +107,7 @@ module Hydra #:nodoc:
|
||||||
def run_rspec_file(file)
|
def run_rspec_file(file)
|
||||||
# pull in rspec
|
# pull in rspec
|
||||||
begin
|
begin
|
||||||
require 'spec'
|
require 'rspec'
|
||||||
require 'hydra/spec/hydra_formatter'
|
require 'hydra/spec/hydra_formatter'
|
||||||
# Ensure we override rspec's at_exit
|
# Ensure we override rspec's at_exit
|
||||||
require 'hydra/spec/autorun_override'
|
require 'hydra/spec/autorun_override'
|
||||||
|
@ -115,22 +115,15 @@ module Hydra #:nodoc:
|
||||||
return ex.to_s
|
return ex.to_s
|
||||||
end
|
end
|
||||||
hydra_output = StringIO.new
|
hydra_output = StringIO.new
|
||||||
Spec::Runner.options.instance_variable_set(:@formatters, [
|
|
||||||
Spec::Runner::Formatter::HydraFormatter.new(
|
config = [
|
||||||
Spec::Runner.options.formatter_options,
|
'-f', 'RSpec::Core::Formatters::HydraFormatter',
|
||||||
hydra_output
|
file
|
||||||
)
|
]
|
||||||
])
|
|
||||||
Spec::Runner.options.instance_variable_set(
|
RSpec.instance_variable_set(:@world, nil)
|
||||||
:@example_groups, []
|
RSpec::Core::Runner.run(config, hydra_output, hydra_output)
|
||||||
)
|
|
||||||
Spec::Runner.options.instance_variable_set(
|
|
||||||
:@files, [file]
|
|
||||||
)
|
|
||||||
Spec::Runner.options.instance_variable_set(
|
|
||||||
:@files_loaded, false
|
|
||||||
)
|
|
||||||
Spec::Runner.options.run_examples
|
|
||||||
hydra_output.rewind
|
hydra_output.rewind
|
||||||
output = hydra_output.read.chomp
|
output = hydra_output.read.chomp
|
||||||
output = "" if output.gsub("\n","") =~ /^\.*$/
|
output = "" if output.gsub("\n","") =~ /^\.*$/
|
||||||
|
|
|
@ -1,12 +1,3 @@
|
||||||
if defined?(Spec)
|
if defined?(RSpec)
|
||||||
module Spec
|
RSpec::Core::Runner.disable_autorun!
|
||||||
module Runner
|
|
||||||
class << self
|
|
||||||
# stop the auto-run at_exit
|
|
||||||
def run
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,23 @@
|
||||||
require 'spec/runner/formatter/progress_bar_formatter'
|
require 'rspec/core/formatters/progress_formatter'
|
||||||
module Spec
|
module RSpec
|
||||||
module Runner
|
module Core
|
||||||
module Formatter
|
module Formatters
|
||||||
class HydraFormatter < ProgressBarFormatter
|
class HydraFormatter < ProgressFormatter
|
||||||
|
def example_passed(example)
|
||||||
|
end
|
||||||
|
|
||||||
|
def example_pending(example)
|
||||||
|
end
|
||||||
|
|
||||||
|
def example_failed(example)
|
||||||
|
end
|
||||||
|
|
||||||
# Stifle the post-test summary
|
# Stifle the post-test summary
|
||||||
def dump_summary(duration, example, failure, pending)
|
def dump_summary(duration, example, failure, pending)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Stifle the output of pending examples
|
# Stifle pending specs
|
||||||
def example_pending(*args)
|
def dump_pending
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
require 'spec'
|
require 'rspec'
|
||||||
context "file writing" do
|
context "file writing" do
|
||||||
it "writes to a file" do
|
it "writes to a file" do
|
||||||
File.open(File.join(Dir.tmpdir, 'alternate_hydra_test.txt'), 'a') do |f|
|
File.open(File.join(Dir.tmpdir, 'alternate_hydra_test.txt'), 'a') do |f|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
require 'spec'
|
require 'rspec'
|
||||||
context "file writing" do
|
context "file writing" do
|
||||||
it "writes to a file" do
|
it "writes to a file" do
|
||||||
File.open(File.join(Dir.tmpdir, 'hydra_test.txt'), 'a') do |f|
|
File.open(File.join(Dir.tmpdir, 'hydra_test.txt'), 'a') do |f|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
require 'spec'
|
require 'rspec'
|
||||||
context "file writing" do
|
context "file writing" do
|
||||||
it "writes to a file" do
|
it "writes to a file" do
|
||||||
File.open(File.join(Dir.tmpdir, 'hydra_test.txt'), 'a') do |f|
|
File.open(File.join(Dir.tmpdir, 'hydra_test.txt'), 'a') do |f|
|
||||||
|
|
|
@ -50,6 +50,7 @@ class RunnerTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "run two rspec tests" do
|
should "run two rspec tests" do
|
||||||
|
puts "First test"
|
||||||
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
|
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
|
||||||
runner.run_file(rspec_file)
|
runner.run_file(rspec_file)
|
||||||
assert File.exists?(target_file)
|
assert File.exists?(target_file)
|
||||||
|
@ -60,7 +61,7 @@ class RunnerTest < Test::Unit::TestCase
|
||||||
runner.run_file(alternate_rspec_file)
|
runner.run_file(alternate_rspec_file)
|
||||||
assert File.exists?(alternate_target_file)
|
assert File.exists?(alternate_target_file)
|
||||||
assert_equal "HYDRA", File.read(alternate_target_file)
|
assert_equal "HYDRA", File.read(alternate_target_file)
|
||||||
assert !File.exists?(target_file)
|
assert !File.exists?(target_file), "Tests are double running!"
|
||||||
end
|
end
|
||||||
|
|
||||||
should "run rspec tests with pending examples" do
|
should "run rspec tests with pending examples" do
|
||||||
|
|
Loading…
Reference in New Issue