diff --git a/.gitignore b/.gitignore index 340e704..b5aecf7 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ # rspec failure tracking .rspec_status + +.ruby-version diff --git a/.ruby-version b/.ruby-version index 6a6a3d8..338a5b5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.1 +2.6.6 diff --git a/Gemfile.lock b/Gemfile.lock index 0092aa8..e843cba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - typerb (0.2.1) + typerb (0.3.0) GEM remote: https://rubygems.org/ diff --git a/lib/typerb.rb b/lib/typerb.rb index 8db412c..da9b658 100644 --- a/lib/typerb.rb +++ b/lib/typerb.rb @@ -5,7 +5,7 @@ require 'typerb/exceptional' module Typerb - refine Object do + refine BasicObject do def type!(*klasses) raise ArgumentError, 'provide at least one class' if klasses.empty? return self if klasses.any? { |kls| is_a?(kls) } diff --git a/lib/typerb/version.rb b/lib/typerb/version.rb index 1c57351..20c740b 100644 --- a/lib/typerb/version.rb +++ b/lib/typerb/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Typerb - VERSION = '0.2.1' + VERSION = '0.3.0' end diff --git a/spec/typerb_spec.rb b/spec/typerb_spec.rb index 47460e9..c282bc2 100644 --- a/spec/typerb_spec.rb +++ b/spec/typerb_spec.rb @@ -152,6 +152,19 @@ def initialize(arg) end expect { kls.new('hello') }.to raise_error(ArgumentError, 'provide at least one class') end + + it 'works with BasicObject' do + require 'tempfile' + kls = Class.new do + using Typerb + + def initialize(arg) + arg.type!(Tempfile) + @arg = arg + end + end + expect { kls.new(Tempfile.new) }.not_to raise_error + end end context 'not_nil!' do