diff --git a/lib/toggles/feature.rb b/lib/toggles/feature.rb index 01fc80c..52959c2 100644 --- a/lib/toggles/feature.rb +++ b/lib/toggles/feature.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true - + module Feature Error = Class.new(StandardError) Unknown = Class.new(Error) @@ -75,8 +75,8 @@ def self.disabled?(*sym, **criteria) end } -Feature.operations[:gt] = ->(entity, attr_name, expected) { entity.send(attr_name) > expected } -Feature.operations[:lt] = ->(entity, attr_name, expected) { entity.send(attr_name) < expected } +Feature.operations[:gt] = ->(entity, attr_name, expected) { entity.send(attr_name) > expected.to_f } +Feature.operations[:lt] = ->(entity, attr_name, expected) { entity.send(attr_name) < expected.to_f } Feature.operations[:range] = lambda { |args| raise StandardError, 'Invalid range operation' if args.size != 2 diff --git a/lib/toggles/version.rb b/lib/toggles/version.rb index 7e150b1..85132c7 100644 --- a/lib/toggles/version.rb +++ b/lib/toggles/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Toggles - VERSION = '0.5.0' + VERSION = '0.6.0' end diff --git a/spec/toggles/feature/operation_spec.rb b/spec/toggles/feature/operation_spec.rb index a796e6b..1e3b8e1 100644 --- a/spec/toggles/feature/operation_spec.rb +++ b/spec/toggles/feature/operation_spec.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true - + RSpec.describe 'operations' do context 'and' do subject { Feature.operations[:and] } @@ -19,6 +19,10 @@ specify do expect(subject.call(double(id: 50), :id, 40)).to eq true expect(subject.call(double(id: 50), :id, 60)).to eq false + expect(subject.call(double(id: 5_500_000), :id, "6e+06")).to eq false + expect(subject.call(double(id: 5_500_000), :id, 6e+06)).to eq false + expect(subject.call(double(id: 6_500_000), :id, "6e+06")).to eq true + expect(subject.call(double(id: 6_500_000), :id, 6e+06)).to eq true end end @@ -38,6 +42,10 @@ specify do expect(subject.call(double(id: 50), :id, 60)).to eq true expect(subject.call(double(id: 50), :id, 40)).to eq false + expect(subject.call(double(id: 5_500_000), :id, "6e+06")).to eq true + expect(subject.call(double(id: 5_500_000), :id, 6e+06)).to eq true + expect(subject.call(double(id: 6_500_000), :id, "6e+06")).to eq false + expect(subject.call(double(id: 6_500_000), :id, 6e+06)).to eq false end end