Sha256: 2010a7362a4cf2aa55458b33fbca81e036449f25f1962356dca468c8f692723c

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Barometer::Query::Format::ShortZipcode do
  before(:each) do
    @valid = "90210"
    @invalid = "90210-5555"
  end

  describe "and class methods" do
    it "returns a format" do
      Barometer::Query::Format::ShortZipcode.format.should == :short_zipcode
    end

    it "returns a country" do
      Barometer::Query::Format::ShortZipcode.country_code.should == "US"
      Barometer::Query::Format::ShortZipcode.country_code("ignored").should == "US"
    end

    it "returns a regex" do
      Barometer::Query::Format::ShortZipcode.regex.should_not be_nil
      Barometer::Query::Format::ShortZipcode.regex.is_a?(Regexp).should be_true
    end

    describe "is?," do
      it "recognizes a valid format" do
        Barometer::Query::Format::ShortZipcode.is?(@valid).should be_true
      end

      it "recognizes non-valid format" do
        Barometer::Query::Format::ShortZipcode.is?(@invalid).should be_false
      end
    end

    it "stubs to" do
      Barometer::Query::Format::ShortZipcode.to.should be_nil
    end

    it "stubs convertable_formats" do
      Barometer::Query::Format::ShortZipcode.convertable_formats.should == []
    end

    it "doesn't convert" do
      query = Barometer::Query.new(@valid)
      Barometer::Query::Format::ShortZipcode.converts?(query).should be_false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
barometer-0.8.0 spec/formats/short_zipcode_spec.rb