Skip to content

Instantly share code, notes, and snippets.

@utilum
Created December 21, 2016 16:16
Show Gist options
  • Save utilum/78918f1b64f8b61ee732cb266db7c43a to your computer and use it in GitHub Desktop.
Save utilum/78918f1b64f8b61ee732cb266db7c43a to your computer and use it in GitHub Desktop.
Test that although Complex and Rational raise on #dup, we consider them #duplicable?
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rails", github: "rails/rails"
end
require "active_support"
require "active_support/core_ext/object/duplicable"
require "minitest/autorun"
class BugTest < Minitest::Test
def test_complex_duplicable
assert_raises(TypeError) { Complex(1).dup }
refute Complex(1).duplicable?, "expected instance of Complex not to be `duplicable?`"
end
def test_rational_duplicable
assert_raises(TypeError) { Rational(1).dup }
refute Rational(1).duplicable?, "expected instance of Rational not to be `duplicable?`"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment