lib/rspec/rails/adapters.rb in rspec-rails-3.0.0.beta1 vs lib/rspec/rails/adapters.rb in rspec-rails-3.0.0.beta2

- old
+ new

@@ -1,16 +1,23 @@ require 'delegate' +require 'active_support' require 'active_support/concern' module RSpec module Rails if ::Rails::VERSION::STRING >= '4.1.0' gem 'minitest' require 'minitest/assertions' Assertions = Minitest::Assertions else - require 'test/unit/assertions' + begin + require 'test/unit/assertions' + rescue LoadError + # work around for Rubinius not having a std std-lib + require 'rubysl-test-unit' if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx' + require 'test/unit/assertions' + end Assertions = Test::Unit::Assertions end # @api private class AssertionDelegator < Module @@ -34,15 +41,13 @@ end assertion_modules.each do |mod| mod.public_instance_methods.each do |method| next if method == :method_missing || method == "method_missing" - class_eval <<-EOM, __FILE__, __LINE__ + 1 - def #{method}(*args, &block) - assertion_instance.send(:#{method}, *args, &block) - end - EOM + define_method(method.to_sym) do |*args, &block| + assertion_instance.send(method.to_sym, *args, &block) + end end end end end end @@ -99,24 +104,24 @@ # # Wraps `setup` calls from within Rails' testing framework in `before` # hooks. def setup(*methods) methods.each do |method| - if method.to_s =~ /^setup_(fixtures|controller_request_and_response)$/ - prepend_before { send method } + if method.to_s =~ /^setup_(with_controller|fixtures|controller_request_and_response)$/ + prepend_before { __send__ method } else - before { send method } + before { __send__ method } end end end # @api private # # Wraps `teardown` calls from within Rails' testing framework in # `after` hooks. def teardown(*methods) - methods.each { |method| after { send method } } + methods.each { |method| after { __send__ method } } end end # @api private def method_name @@ -140,14 +145,12 @@ end # @api private def define_assertion_delegators assertion_method_names.each do |m| - class_eval <<-CODE, __FILE__, __LINE__ + 1 - def #{m}(*args, &block) - assertion_delegator.send :#{m}, *args, &block - end - CODE + define_method(m.to_sym) do |*args, &block| + assertion_delegator.send(m.to_sym, *args, &block) + end end end end # @api private