Sha256: b9ecf416e7f0dfde9296050a732155c7094a283536bc6907efc446a553edc2f8

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require './spec/spec_helper'

describe "ez_enum" do

  before do
    I18n.locale = :en
  end

  AllStatuses = [Status::New, Status::Processing, Status::Failed, Status::Complete]

  describe "::All" do
    it { defined?(Status::All).should_not be nil }
    it { Status::All.should eq(AllStatuses) }
  end

  describe ".choices_for_select" do
    it { Status.respond_to?(:choices_for_select).should be true }
    it { Status.choices_for_select.should_not be nil }
    it { Status.choices_for_select.length.should eq(AllStatuses.length) }
    it { Status.choices_for_select.first.should eq(['New', 1])}
    it "has correct display for switch in locale" do
      I18n.locale = :af
      Status.choices_for_select.first.should eq(['Nuwe', 1])
    end
  end

  describe ".display_for" do
    it { Status.respond_to?(:display_for).should be true }
    it "provides display_for each member" do
      Status::All.each do |status|
        Status.display_for(status).should_not be nil
      end
    end
    it { Status.display_for(Status::Failed).should eq('Epic Fail') }
    it "has correct display for switch in locale" do
      I18n.locale = :af
      Status.display_for(Status::Failed).should eq('Gebreek')
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ez_enum-0.0.1 spec/ez_enum/ez_enum_spec.rb