Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rspec/rspec-rails
...
head fork: rspec/rspec-rails
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 2 files changed
  • 0 commit comments
  • 1 contributor
View
38 lib/rspec/rails/adapters.rb
@@ -15,21 +15,47 @@ 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
View
28 spec/rspec/rails/assertion_adapter_spec.rb
@@ -0,0 +1,28 @@
+require "spec_helper"
+
+describe RSpec::Rails::TestUnitAssertionAdapter do
+ include RSpec::Rails::TestUnitAssertionAdapter
+
+ Test::Unit::Assertions.public_instance_methods.select{|m| m.to_s =~ /^assert/}.each do |m|
+ if m.to_s == "assert_equal"
+ it "exposes #{m} to host examples" do
+ assert_equal 3,3
+ expect do
+ assert_equal 3,4
+ end.to raise_error(ActiveSupport::TestCase::Assertion)
+ end
+ else
+ it "exposes #{m} to host examples" do
+ methods.should include(m)
+ end
+ end
+ end
+
+ it "does not expose internal methods of MiniTest" do
+ methods.should_not include("_assertions")
+ end
+
+ it "does not expose MiniTest's message method" do
+ methods.should_not include("message")
+ end
+end

No commit comments for this range

Something went wrong with that request. Please try again.