Sha256: f3bf28ff454e75b0b5888de6cb7baa64cd4d64f664806f13e861978c8b4cfe44
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
# coding: utf-8 require 'spec_helper' describe JpPrefecture::Model do describe '#prefecture' do describe 'カラム名の指定について' do context 'prefecture_code' do before do class Place < ActiveRecord::Base include JpPrefecture jp_prefecture :prefecture_code end @model_class = Place.new(:prefecture_code => 1) end it { @model_class.prefecture.name.should eq '北海道' } end context 'prefecture_id' do before do class Place < ActiveRecord::Base include JpPrefecture jp_prefecture :prefecture_id end @model_class = Place.new(:prefecture_id => 1) end it { @model_class.prefecture.name.should eq '北海道' } end end describe '検索について' do before do class Place < ActiveRecord::Base include JpPrefecture jp_prefecture :prefecture_code end end context '都道府県が見つかった' do before do @model_class = Place.new(:prefecture_code => 1) end it { @model_class.should respond_to(:prefecture) } it { @model_class.prefecture.should be_an_instance_of(JpPrefecture::Prefecture) } it { @model_class.prefecture.name.should eq '北海道' } end context '都道府県が見つからなかった' do before do @model_class = Place.new(:prefecture_code => 999) end it { @model_class.should respond_to(:prefecture) } it { @model_class.prefecture.should be_nil } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jp_prefecture-0.1.0 | spec/lib/model_spec.rb |