Sha256: ea270869442b21839bc6214080ee1f8200ba70a701078e07da9cf7735dc8fafd

Contents?: true

Size: 755 Bytes

Versions: 7

Compression:

Stored size: 755 Bytes

Contents

require 'spec_helper_models'

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

7 entries across 7 versions & 1 rubygems

Version Path
gaku-0.2.4 core/spec/models/state_spec.rb
gaku-0.2.3 core/spec/models/state_spec.rb
gaku-0.2.2 core/spec/models/state_spec.rb
gaku-0.2.1 core/spec/models/state_spec.rb
gaku-0.2.0 core/spec/models/state_spec.rb
gaku-0.1.1 core/spec/models/state_spec.rb
gaku-0.1.0 core/spec/models/state_spec.rb