Last change
on this file since 415 was 415, checked in by KOBAYASHI, Shinji, 14 years ago |
developing around terminology
|
File size:
1.0 KB
|
Rev | Line | |
---|
[415] | 1 | require 'spec_helper'
|
---|
| 2 |
|
---|
| 3 | describe Language do
|
---|
| 4 | fixtures :languages
|
---|
| 5 |
|
---|
| 6 | before(:each) do
|
---|
| 7 | @valid_attributes = {
|
---|
| 8 | :code => "jp",
|
---|
| 9 | :description => "Japan"
|
---|
| 10 | }
|
---|
| 11 | end
|
---|
| 12 |
|
---|
| 13 | it "should create a new instance given valid attributes" do
|
---|
| 14 | Language.create!(@valid_attributes)
|
---|
| 15 | end
|
---|
| 16 |
|
---|
| 17 | it 'should not valid when code is not assigned' do
|
---|
| 18 | Language.new(:description => 'Japan').should_not be_valid
|
---|
| 19 | end
|
---|
| 20 |
|
---|
| 21 | it 'should not valid when description is not assigned' do
|
---|
| 22 | Language.new(:code => 'jp').should_not be_valid
|
---|
| 23 | end
|
---|
| 24 |
|
---|
| 25 | it 'should return valid description for code' do
|
---|
| 26 | Language.find(:first,
|
---|
| 27 | :conditions => ["code = ?", 'af']).
|
---|
| 28 | description.should == 'Afrikaans'
|
---|
| 29 | end
|
---|
| 30 |
|
---|
| 31 | it 'should have only one entry for one code' do
|
---|
| 32 | Language.find(:all, :conditions => ["code = ?", 'af']).size.
|
---|
| 33 | should be_equal 1
|
---|
| 34 |
|
---|
| 35 | end
|
---|
| 36 |
|
---|
| 37 | it 'should return valid code for description' do
|
---|
| 38 | Language.first("description = ?", 'Albanian').code.should == 'sq'
|
---|
| 39 | end
|
---|
| 40 |
|
---|
| 41 | after(:all) do
|
---|
| 42 | Language.destroy_all
|
---|
| 43 | end
|
---|
| 44 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.