mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-21 17:50:13 +01:00
Added Rspec and Webrat plugins and started porting Selenium on Rails tests to Rspec Plain Text Stories driving Webrat driving Selenium.
This commit is contained in:
parent
0600756bbf
commit
0f7d6f7a1d
602 changed files with 47788 additions and 29 deletions
6
vendor/plugins/rspec/lib/spec/interop/test/unit/autorunner.rb
vendored
Normal file
6
vendor/plugins/rspec/lib/spec/interop/test/unit/autorunner.rb
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class Test::Unit::AutoRunner
|
||||
remove_method :process_args
|
||||
def process_args(argv)
|
||||
true
|
||||
end
|
||||
end
|
||||
61
vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb
vendored
Normal file
61
vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
require 'test/unit/testcase'
|
||||
|
||||
module Test
|
||||
module Unit
|
||||
# This extension of the standard Test::Unit::TestCase makes RSpec
|
||||
# available from within, so that you can do things like:
|
||||
#
|
||||
# require 'test/unit'
|
||||
# require 'spec'
|
||||
#
|
||||
# class MyTest < Test::Unit::TestCase
|
||||
# it "should work with Test::Unit assertions" do
|
||||
# assert_equal 4, 2+1
|
||||
# end
|
||||
#
|
||||
# def test_should_work_with_rspec_expectations
|
||||
# (3+1).should == 5
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# See also Spec::Example::ExampleGroup
|
||||
class TestCase
|
||||
extend Spec::Example::ExampleGroupMethods
|
||||
include Spec::Example::ExampleMethods
|
||||
|
||||
before(:each) {setup}
|
||||
after(:each) {teardown}
|
||||
|
||||
class << self
|
||||
def suite
|
||||
Test::Unit::TestSuiteAdapter.new(self)
|
||||
end
|
||||
|
||||
def example_method?(method_name)
|
||||
should_method?(method_name) || test_method?(method_name)
|
||||
end
|
||||
|
||||
def test_method?(method_name)
|
||||
method_name =~ /^test[_A-Z]./ && (
|
||||
instance_method(method_name).arity == 0 ||
|
||||
instance_method(method_name).arity == -1
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(defined_description, &implementation)
|
||||
@_defined_description = defined_description
|
||||
@_implementation = implementation
|
||||
|
||||
@_result = ::Test::Unit::TestResult.new
|
||||
# @method_name is important to set here because it "complies" with Test::Unit's interface.
|
||||
# Some Test::Unit extensions depend on @method_name being present.
|
||||
@method_name = @_defined_description
|
||||
end
|
||||
|
||||
def run(ignore_this_argument=nil)
|
||||
super()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
6
vendor/plugins/rspec/lib/spec/interop/test/unit/testresult.rb
vendored
Normal file
6
vendor/plugins/rspec/lib/spec/interop/test/unit/testresult.rb
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class Test::Unit::TestResult
|
||||
alias_method :tu_passed?, :passed?
|
||||
def passed?
|
||||
return tu_passed? & ::Spec.run
|
||||
end
|
||||
end
|
||||
34
vendor/plugins/rspec/lib/spec/interop/test/unit/testsuite_adapter.rb
vendored
Normal file
34
vendor/plugins/rspec/lib/spec/interop/test/unit/testsuite_adapter.rb
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
module Test
|
||||
module Unit
|
||||
class TestSuiteAdapter < TestSuite
|
||||
attr_reader :example_group, :examples
|
||||
alias_method :tests, :examples
|
||||
def initialize(example_group)
|
||||
@example_group = example_group
|
||||
@examples = example_group.examples
|
||||
end
|
||||
|
||||
def name
|
||||
example_group.description
|
||||
end
|
||||
|
||||
def run(*args)
|
||||
return true unless args.empty?
|
||||
example_group.run
|
||||
end
|
||||
|
||||
def size
|
||||
example_group.number_of_examples
|
||||
end
|
||||
|
||||
def delete(example)
|
||||
examples.delete example
|
||||
end
|
||||
|
||||
def empty?
|
||||
examples.empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
61
vendor/plugins/rspec/lib/spec/interop/test/unit/ui/console/testrunner.rb
vendored
Normal file
61
vendor/plugins/rspec/lib/spec/interop/test/unit/ui/console/testrunner.rb
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
require 'test/unit/ui/console/testrunner'
|
||||
|
||||
module Test
|
||||
module Unit
|
||||
module UI
|
||||
module Console
|
||||
class TestRunner
|
||||
|
||||
alias_method :started_without_rspec, :started
|
||||
def started_with_rspec(result)
|
||||
@result = result
|
||||
@need_to_output_started = true
|
||||
end
|
||||
alias_method :started, :started_with_rspec
|
||||
|
||||
alias_method :test_started_without_rspec, :test_started
|
||||
def test_started_with_rspec(name)
|
||||
if @need_to_output_started
|
||||
if @rspec_io
|
||||
@rspec_io.rewind
|
||||
output(@rspec_io.read)
|
||||
end
|
||||
output("Started")
|
||||
@need_to_output_started = false
|
||||
end
|
||||
test_started_without_rspec(name)
|
||||
end
|
||||
alias_method :test_started, :test_started_with_rspec
|
||||
|
||||
alias_method :test_finished_without_rspec, :test_finished
|
||||
def test_finished_with_rspec(name)
|
||||
test_finished_without_rspec(name)
|
||||
@ran_test = true
|
||||
end
|
||||
alias_method :test_finished, :test_finished_with_rspec
|
||||
|
||||
alias_method :finished_without_rspec, :finished
|
||||
def finished_with_rspec(elapsed_time)
|
||||
@ran_test ||= false
|
||||
if @ran_test
|
||||
finished_without_rspec(elapsed_time)
|
||||
end
|
||||
end
|
||||
alias_method :finished, :finished_with_rspec
|
||||
|
||||
alias_method :setup_mediator_without_rspec, :setup_mediator
|
||||
def setup_mediator_with_rspec
|
||||
orig_io = @io
|
||||
@io = StringIO.new
|
||||
setup_mediator_without_rspec
|
||||
ensure
|
||||
@rspec_io = @io
|
||||
@io = orig_io
|
||||
end
|
||||
alias_method :setup_mediator, :setup_mediator_with_rspec
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue