diff --git a/.rubocop.yml b/.rubocop.yml index 6037b5c..b3598f6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,6 +2,7 @@ AllCops: TargetRubyVersion: 2.4 Exclude: - 'bin/**/*' + - 'Guardfile' inherit_mode: merge: diff --git a/README.md b/README.md index ce88b12..d0d738d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Proof of concept type-checking library for Ruby 2.6. Works with previous version class A using Typerb - def strong_type_call(some_arg) + def call(some_arg) some_arg.type!(String, Symbol) end @@ -26,7 +26,7 @@ A.new.call_with_respond_checks(1) #=> TypeError: 'Integer should respond to all This is equivalent to: ```ruby class A - def strong_type_call(some_arg) + def call(some_arg) raise TypeError, "`some_arg` should be String or Symbol, not #{some_arg.class}" unless [String, Symbol].include?(some_arg.class) end diff --git a/lib/typerb.rb b/lib/typerb.rb index b5a0e29..5d82b68 100644 --- a/lib/typerb.rb +++ b/lib/typerb.rb @@ -41,6 +41,5 @@ def respond_to!(*methods) exception.set_backtrace(caller) raise exception end - end end diff --git a/spec/typerb_spec.rb b/spec/typerb_spec.rb index 4b79ac0..0db9ddb 100644 --- a/spec/typerb_spec.rb +++ b/spec/typerb_spec.rb @@ -166,7 +166,7 @@ def initialize(arg1, arg2) expect(kls.new(1, '1').arg2).to eq '1' end - context "respond_to!" do + context 'respond_to!' do it 'raises TypeError if object does not respond to specified method' do kls = Class.new do using Typerb @@ -177,7 +177,7 @@ def initialize(arg) end end expect { kls.new(123) }.to raise_error(TypeError, 'Integer should respond to all methods: strip') - expect { kls.new("foo") }.not_to raise_error + expect { kls.new('foo') }.not_to raise_error end it 'raises TypeError if object does not respond to specified methods' do @@ -190,11 +190,7 @@ def initialize(arg) end end expect { kls.new(123) }.to raise_error(TypeError, 'Integer should respond to all methods: strip, downcase, chars') - expect { kls.new("foo") }.not_to raise_error + expect { kls.new('foo') }.not_to raise_error end - - - end - end diff --git a/typerb.gemspec b/typerb.gemspec index 193eee6..b1ca6c1 100644 --- a/typerb.gemspec +++ b/typerb.gemspec @@ -25,13 +25,13 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_development_dependency 'bundler', '>= 1.17' + spec.add_development_dependency 'guard' + spec.add_development_dependency 'guard-rspec' spec.add_development_dependency 'pry' spec.add_development_dependency 'rake', '>= 10.0' spec.add_development_dependency 'rspec', '>= 3.0' spec.add_development_dependency 'rubocop' spec.add_development_dependency 'super_awesome_print' - spec.add_development_dependency 'guard' - spec.add_development_dependency 'guard-rspec' spec.required_ruby_version = '>= 2.4' end