Sha256: 3df953044d3dfb54159b50388f8658b7fd1ade2bba6466733894e298d11e70c2

Contents?: true

Size: 857 Bytes

Versions: 2

Compression:

Stored size: 857 Bytes

Contents

require 'spec_helper'

describe LongitudeValidator do

  context "Longitude has a valid value" do
    let(:klass) do
      Class.new do
        include ActiveModel::Validations
        attr_accessor :lon, :name
        validates :lon, longitude: true
      end
    end

    subject { klass.new }

    it { should allow_value(-180).for(:lon) }
    it { should allow_value(180).for(:lon) }
    it { should allow_value(0).for(:lon) }
    it { should allow_value(9.33).for(:lon) }

    it { should_not allow_value('').for(:lon) }
    it { should_not allow_value(' ').for(:lon) }
    it { should_not allow_value(nil).for(:lon) }
    it { should_not allow_value(-181.1).for(:lon) }
    it { should_not allow_value(181.1).for(:lon) }

    it { should ensure_valid_longitude_format_of(:lon) }
    it { should_not ensure_valid_longitude_format_of(:name) }
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flash_validators-1.0.0 spec/lib/longitude_validator_spec.rb
flash_validators-0.0.1 spec/lib/longitude_validator_spec.rb