lib/rspec/rails/adapters.rb in rspec-rails-2.0.0.beta.19 vs lib/rspec/rails/adapters.rb in rspec-rails-2.0.0.beta.20
- old
+ new
@@ -13,23 +13,49 @@
def teardown(*methods)
methods.each {|method| after { send method } }
end
end
+
+ module InstanceMethods
+ def method_name
+ @example
+ end
+ end
end
module TestUnitAssertionAdapter
extend ActiveSupport::Concern
- def method_name
- @example
+
+ class AssertionDelegate
+ include Test::Unit::Assertions
end
- include Test::Unit::Assertions
+ module ClassMethods
+ def assertion_method_names
+ Test::Unit::Assertions.public_instance_methods.select{|m| m.to_s =~ /^assert/} +
+ [:build_message]
+ end
- included do
- before do
- @_result = Struct.new(:add_assertion).new
+ def define_assertion_delegators
+ assertion_method_names.each do |m|
+ class_eval <<-CODE
+ def #{m}(*args, &block)
+ assertion_delegate.send :#{m}, *args, &block
+ end
+ CODE
+ end
end
+ end
+
+ module InstanceMethods
+ def assertion_delegate
+ @assertion_delegate ||= AssertionDelegate.new
+ end
+ end
+
+ included do
+ define_assertion_delegators
end
end
end
end