Skip to content

Commit

Permalink
fix rubocop offences
Browse files Browse the repository at this point in the history
  • Loading branch information
slayer committed Nov 14, 2018
1 parent 450ed9c commit dfd1309
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ AllCops:
TargetRubyVersion: 2.4
Exclude:
- 'bin/**/*'
- 'Guardfile'

inherit_mode:
merge:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion lib/typerb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ def respond_to!(*methods)
exception.set_backtrace(caller)
raise exception
end

end
end
10 changes: 3 additions & 7 deletions spec/typerb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions typerb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit dfd1309

Please sign in to comment.