Sha256: e20f8f9279cb3c29cbeb27332f1bbe8e4695722409d2aa2064ed9490c4975cce

Contents?: true

Size: 748 Bytes

Versions: 3

Compression:

Stored size: 748 Bytes

Contents

require 'spec_helper'

describe Gaku::State do

  describe 'associations' do
    it { should belong_to :country }
  end

  describe 'validations' do
    it { should validate_presence_of :name }
    it { should validate_presence_of :country_iso }
  end

  before(:all) { Gaku::State.destroy_all }

  it 'can find a state by name or abbr' do
    state = create(:state, name: 'California', abbr: 'CA')
    Gaku::State.find_all_by_name_or_abbr('California').should include(state)
    Gaku::State.find_all_by_name_or_abbr('CA').should include(state)
  end

  it 'can find all states group by country numcode' do
    state = create(:state)
    Gaku::State.states_group_by_country_iso.should == { state.country_iso => [[state.id, state.name]] }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gaku-0.0.3 core/spec/models/state_spec.rb
gaku-0.0.2 core/spec/models/state_spec.rb
gaku-0.0.1 core/spec/models/state_spec.rb