Class: Test::Unit::TestCase

Inherits:
Object show all
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

#location

Attributes included from Spec::Example::Subject::ExampleGroupMethods

#explicit_subject_block

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Spec::Example::ExampleGroupMethods

build_description_from, describe, described_class, described_type, description, description_args, description_parts, example, example_group_hierarchy, example_implementations, example_proxies, examples, include_constants_in, inherited, it_should_behave_like, let, let!, nested_descriptions, notify, number_of_examples, options, pending_implementation, set_description, xexample

Methods included from Spec::Example::ArgsAndOptions

#add_options, #args_and_options, #set_location

Methods included from Spec::Example::PredicateMatchers

#define_methods_from_predicate_matchers, #predicate_matchers

Methods included from Spec::Example::Subject::ExampleGroupMethods

#its, #subject

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

#description, #eval_each_fail_fast, #eval_each_fail_slow, #execute, #expect, #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

#pending

Methods included from Spec::Matchers

#be, #be_a, #be_a_kind_of, #be_an_instance_of, #be_close, #change, clear_generated_description, #eql, #equal, #exist, generated_description, #have, #have_at_least, #have_at_most, #include, #match, #method_missing, #raise_exception, #respond_to, #satisfy, #simple_matcher, #throw_symbol, #wrap_expectation

Methods included from Spec::Matchers::DSL

#create, #define

Methods included from Spec::Example::Subject::ExampleMethods

#__should_for_example_group__, #__should_not_for_example_group__, #should, #should_not, #subject

Constructor Details

#initialize(description, &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.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

Returns:

  • (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

.suiteObject



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

Returns:

  • (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./ && (
    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