Sha256: 6585d8dfe746737ff440c9b7c1a551f5aa705be0d2fa3cce6948dc75238821e6

Contents?: true

Size: 748 Bytes

Versions: 1

Compression:

Stored size: 748 Bytes

Contents

require 'spec_helper'

describe Nation, type: :model do

  it 'should create a nation' do
    expect {  Nation.make! }.not_to raise_error
  end

  it 'should require an abbr' do
    expect(Nation.make(abbr: nil)).to_not be_valid
  end

  it 'should validates uniqueness of abbr' do
    Nation.make!(abbr: 'BR')
    expect(Nation.make(abbr: 'BR')).to_not be_valid
  end

  it 'should have abbr as _id' do
    Nation.make!(abbr: 'BR')
    expect(Nation.first[:_id]).to eq('BR')
  end

  it 'may have a localized name' do
    I18n.locale = :'pt-BR'
    n = Nation.new(name: 'Brasil')
    expect(n.name).to eq('Brasil')
    I18n.locale = :en
    n.name = 'Brazil'
    expect(n.name_translations).to eq('pt-BR' => 'Brasil', 'en' => 'Brazil')
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geopolitical-0.8.4 spec/models/nation_spec.rb