From 2e0cced64c0ac763492fdd563641264a03364134 Mon Sep 17 00:00:00 2001 From: Kevin Olbrich Date: Fri, 30 Dec 2016 18:40:53 -0500 Subject: [PATCH] Remove 'kind_of' method. It was inconsistent and caused some strange problems. Fixes #144 (#150) --- Gemfile | 2 ++ lib/ruby_units/unit.rb | 9 --------- spec/ruby_units/complex_spec.rb | 4 ++-- spec/ruby_units/math_spec.rb | 2 +- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 6a2db6d6..e133fc28 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,7 @@ source 'https://rubygems.org' +ruby RUBY_VERSION + group :development do gem 'bundler', '~> 1.0' gem 'guard-rspec' diff --git a/lib/ruby_units/unit.rb b/lib/ruby_units/unit.rb index a45fc733..8e559f31 100644 --- a/lib/ruby_units/unit.rb +++ b/lib/ruby_units/unit.rb @@ -426,15 +426,6 @@ def self.use_definition(definition) # @return [String] attr_accessor :unit_name - # needed to make complex units play nice -- otherwise not detected as a complex_generic - # @param [Class] - # @return [Boolean] - def kind_of?(klass) - # rubocop:disable Style/ClassCheck - scalar.kind_of?(klass) - # rubocop:enable Style/ClassCheck - end - # Used to copy one unit to another # @param [Unit] from Unit to copy definition from # @return [Unit] diff --git a/spec/ruby_units/complex_spec.rb b/spec/ruby_units/complex_spec.rb index af7ff923..82bb89c5 100644 --- a/spec/ruby_units/complex_spec.rb +++ b/spec/ruby_units/complex_spec.rb @@ -12,8 +12,8 @@ describe 'Complex Unit' do subject { Complex(1.0, -1.0).to_unit } - it { is_expected.to be_instance_of Unit } - it(:scalar) { is_expected.to be_kind_of Complex } + it { is_expected.to be_a Unit } + it { expect(subject.scalar).to be_a Complex } it { is_expected.to eq('1-1i'.to_unit) } it { is_expected.to be === '1-1i'.to_unit } diff --git a/spec/ruby_units/math_spec.rb b/spec/ruby_units/math_spec.rb index e33ceeaf..f7f65922 100644 --- a/spec/ruby_units/math_spec.rb +++ b/spec/ruby_units/math_spec.rb @@ -4,7 +4,7 @@ describe '#sqrt' do specify { expect(Math.sqrt(RubyUnits::Unit.new('1 mm^6'))).to eq(RubyUnits::Unit.new('1 mm^3')) } specify { expect(Math.sqrt(4)).to eq(2) } - specify { expect(Math.sqrt(RubyUnits::Unit.new('-9 mm^2'))).to be_kind_of(Complex) } + specify { expect(Math.sqrt(RubyUnits::Unit.new('-9 mm^2')).scalar).to be_kind_of(Complex) } end describe '#cbrt' do