Class: Test::Unit::TestCase
- Extended by:
- Spec::Example::ExampleGroupMethods
- Includes:
- Spec::Example::ExampleMethods
- Defined in:
- lib/spec/interop/test/unit/testcase.rb
Overview
This extension of the standard Test::Unit::TestCase makes RSpec available from within, so that you can do things like:
require ‘spec/test/unit’
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
Instance Attribute Summary
Attributes included from Spec::Example::ExampleGroupMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(description, options = {}, &implementation) ⇒ TestCase
constructor
A new instance of TestCase.
- #run(ignore_this_argument = nil) ⇒ Object
Methods included from Spec::Example::ExampleGroupMethods
backtrace, describe, described_class, described_type, description, description_args, description_parts, example, example_descriptions, example_group_backtrace, example_group_hierarchy, example_implementations, examples, filtered_description, include_constants_in, inherited, it_should_behave_like, nested_descriptions, notify, number_of_examples, pending_implementation, set_description, xexample
Methods included from Spec::Example::PredicateMatchers
#define_methods_from_predicate_matchers, #predicate_matchers
Methods included from Spec::Example::Subject::ExampleGroupMethods
Methods included from Spec::Example::BeforeAndAfterHooks
#after_all_parts, #after_each_parts, after_suite_parts, #after_suite_parts, #append_after, #append_before, #before_all_parts, #before_each_parts, before_suite_parts, #before_suite_parts, #prepend_after, #prepend_before
Methods included from Spec::Example::ExampleMethods
#backtrace, #description, #eval_each_fail_fast, #eval_each_fail_slow, #execute, #implementation_backtrace, #instance_variable_hash, #options, #run_after_each, #run_before_each, #set_instance_variables_from_hash, #violated
Methods included from Spec::Example::ModuleReopeningFix
#child_modules, #include, #included
Methods included from Spec::Example::Pending
Methods included from Spec::Matchers
#be, #be_a, #be_close, #be_instance_of, #be_kind_of, #change, clear_generated_description, #eql, #equal, #exist, generated_description, #have, #have_at_least, #have_at_most, #include, last_matcher, last_matcher=, last_should, last_should=, #match, #method_missing, #raise_error, #respond_to, #satisfy, #simple_matcher, #throw_symbol, #wrap_expectation
Methods included from Spec::DSL::Matchers
Methods included from Spec::Example::Subject::ExampleMethods
#should, #should_not, #subject
Constructor Details
#initialize(description, options = {}, &implementation) ⇒ TestCase
Returns a new instance of TestCase.
43 44 45 46 47 48 |
# File 'lib/spec/interop/test/unit/testcase.rb', line 43 def initialize(description, ={}, &implementation) super # Some Test::Unit extensions depend on @method_name being present. @method_name = description @_result = ::Test::Unit::TestResult.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Spec::Matchers
Class Method Details
.example_method?(method_name) ⇒ Boolean
29 30 31 |
# File 'lib/spec/interop/test/unit/testcase.rb', line 29 def self.example_method?(method_name) should_method?(method_name) || test_method?(method_name) end |
.suite ⇒ Object
25 26 27 |
# File 'lib/spec/interop/test/unit/testcase.rb', line 25 def self.suite Test::Unit::TestSuiteAdapter.new(self) end |
.test_method?(method_name) ⇒ Boolean
33 34 35 36 37 38 |
# File 'lib/spec/interop/test/unit/testcase.rb', line 33 def self.test_method?(method_name) method_name =~ /^test[_A-Z]./ && ( instance_method(method_name).arity == 0 || instance_method(method_name).arity == -1 ) end |
Instance Method Details
#run(ignore_this_argument = nil) ⇒ Object
50 51 52 |
# File 'lib/spec/interop/test/unit/testcase.rb', line 50 def run(ignore_this_argument=nil) super() end |