Sha256: d34a82cfaeb25689346ffca054293ef769c561a10e57e5c8055a8211a230d133

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 KB

Contents

require "spec_helper"

module PostmonRuby
  module Finders
    describe StateFinder do
      describe "#search" do
        context "with too many arguments" do
          it "raise an ArgumentError" do
            expect{ PostmonRuby::Client.search(:estado, "SP", "xxxxx") }.to raise_error(ArgumentError)
          end
        end

        context "with less arguments" do
          it "raise an ArgumentError" do
            expect{ PostmonRuby::Client.search(:estado) }.to raise_error(ArgumentError)
          end
        end        

        context "with valid state" do
          let(:state) { PostmonRuby::Client.search(:estado, "SP" ) }
          it "returns a PostmonRuby::State object" do
            expect(state).to be_a(PostmonRuby::State)
          end
          it "returns a complete state info" do
            expect(state.area_km2).to eq "248.222,801"
            expect(state.codigo_ibge).to eq "35"
            expect(state.nome).to eq "São Paulo"
          end          
        end
 
        context "with invalid state" do
          let(:state) { PostmonRuby::Client.search(:estado, "SK") }
          it "returns a PostmonRuby::State object" do
            expect(state).to be_a(PostmonRuby::State)
          end
          it "returns true in 'not_found'" do
            expect(state.not_found).to be_true
          end          
        end        

      end
    end  
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
postmon_ruby-3.0.0 spec/postmon_ruby/state_finder_spec.rb
postmon_ruby-2.1.3 spec/postmon_ruby/state_finder_spec.rb
postmon_ruby-2.1.2 spec/postmon_ruby/state_finder_spec.rb
postmon_ruby-2.1.1 spec/postmon_ruby/state_finder_spec.rb
postmon_ruby-2.1.0 spec/postmon_ruby/state_finder_spec.rb