Sha256: b456b2b86b0110914e39ca72135f0bd19e330951a4a517ac471748a86d6d3839

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

describe Array do
  describe "#us_state_options" do
    it "has the right number of entries" do
       Array.us_state_options.size.should == 52
       Array.us_state_options(:blank => false).size.should == 51
    end
    it "returns the correct list" do
      Array.us_state_options[1][0].should == "Alabama"
      Array.us_state_options(:abbrev => true)[1][0].should == "AL"
    end
    it "formats correctly" do
      Array.us_state_options(:format => "Up")[1][0].should == "ALABAMA"
      Array.us_state_options(:format => "Down")[1][0].should == "alabama"
      Array.us_state_options(:format => "Cap")[1][0].should == "Alabama"
      Array.us_state_options(:format => "Up", :abbrev => true)[1][0].should == "AL"
      Array.us_state_options(:format => "Down", :abbrev => true)[1][0].should == "al"
      Array.us_state_options(:format => "Cap", :abbrev => true)[1][0].should == "Al"
    end
  end

  describe "#options_label_for" do
    it "returns the correct label" do
      Array.us_state_options.options_label_for("AK").should == "Alaska"
    end
    it "returns nil when nothing is found" do
      Array.us_state_options.options_label_for("invalid").should == nil
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
corelib-0.0.3 spec/array/helpers_spec.rb
corelib-0.0.2 spec/array/helpers_spec.rb