require 'spec_helper' describe Language do fixtures :languages before(:each) do @valid_attributes = { :code => "jp", :description => "Japan" } end it "should create a new instance given valid attributes" do Language.create!(@valid_attributes) end it 'should not valid when code is not assigned' do Language.new(:description => 'Japan').should_not be_valid end it 'should not valid when description is not assigned' do Language.new(:code => 'jp').should_not be_valid end it 'should return valid description for code' do Language.find(:first, :conditions => ["code = ?", 'af']). description.should == 'Afrikaans' end it 'should have only one entry for one code' do Language.find(:all, :conditions => ["code = ?", 'af']).size. should be_equal 1 end it 'should return valid code for description' do Language.first("description = ?", 'Albanian').code.should == 'sq' end after(:all) do Language.destroy_all end end