Sha256: af2a542e8dfc9032f92771a9d7438116ad8905048a87a5ed48ecd308f3902791

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 KB

Contents

module CloudSesame
  module Query
    module AST
      describe NumericValue do

        describe 'compile' do
          let(:value) { 20 }
          subject { NumericValue.new(value) }
          it 'should return the data in string format' do
            expect(subject.compile).to eq "#{ value }"
          end
        end

        describe '==' do

          context 'when value comparing with is a integer' do
            subject { NumericValue.new(20) }

            it 'should return true if data equals to the value' do
              expect(subject == 20).to eq true
            end

            it 'should return false when data does not equal to the value' do
              expect(subject == 21).to eq false
            end

          end

          context 'when value comparing with is a float' do
            subject { NumericValue.new(0.99) }

            it 'should return true if data equals to the value' do
              expect(subject == 0.990).to eq true
            end

            it 'should return false when data does not equal to the value' do
              expect(subject == 1.0).to eq false
            end

          end

          context 'when value comparing with is a string' do
            subject { NumericValue.new("0.99") }

            it 'should return true if data equals to the value' do
              expect(subject == 0.990).to eq true
              expect(subject == "0.990").to eq true
            end

            it 'should return false when data does not equal to the value' do
              expect(subject == 1.0).to eq false
              expect(subject == "1.0").to eq false
            end
          end

        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
CloudSesame-0.5.4 spec/cloud_sesame/query/ast/numeric_value_spec.rb
CloudSesame-0.5.3 spec/cloud_sesame/query/ast/numeric_value_spec.rb