$LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'rubygems' require 'spec' require 'spec/autorun' require 'fakeweb' require 'mooamba' Spec::Runner.configure do |config| FakeWeb.allow_net_connect = false end VALID_ZIP_CODES = %w(04548-040 01310-100) INVALID_ZIP_CODES = %w(0 00) def map_parameters_to_file(options, file) parameters = { :sCepOrigem => options[:from].gsub("-", ""), :sCepDestino => options[:to].gsub("-", ""), :nVlPeso => options[:weight], :StrRetorno => "XML" }.merge Mooamba::Sedex::DEFAULT_PARAMS FakeWeb.register_uri(:get, URI.escape(Mooamba::Correios::API_URL + parameters.to_query_string), :body => data(file).read) end def valid_xml_file data "valid" end def data(name) File.open("#{File.dirname(__FILE__)}/data/#{name}.xml") end class Hash def except(*blacklist) {}.tap do |h| (keys - blacklist).each { |k| h[k] = self[k] } end end end