Sha256: f79f2a4833eae186991dd62572c5431aab6e50a64d786b7d50597148d6758884
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'spec_helper' describe Enumitation::ClassMethods do before(:all) do class MyModel < ActiveRecord::Base enumitation :number, %w[1 2] end end after(:all) do Object.send :remove_const, :MyModel end describe "select_options_for" do context "when no label translation is present" do it "returns select options with label and value of equal values" do MyModel.select_options_for(:number).should == [%w[1 1], %w[2 2]] end end context "when label translation is present" do before do %w[1 2].each do |num| mock(I18n).t(num, :scope => "enumitation.models.my_model.number", :default => num) do if num == '1' 'one' elsif num == '2' 'two' end end end end it "returns select options with the label translated" do MyModel.select_options_for(:number).should == [%w[one 1], %w[two 2]] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
enumitation-0.0.3 | spec/lib/class_methods_spec.rb |