spec/mooamba/sedex_spec.rb in mooamba-0.0.1 vs spec/mooamba/sedex_spec.rb in mooamba-0.0.2
- old
+ new
@@ -24,26 +24,42 @@
it "should raise Mooamba::InvalidDestinationZipCode when there's no destiny zip code" do
lambda { Mooamba::Sedex.calculate(@default_parameters.except(:to)) }.should raise_error(Mooamba::InvalidDestinationZipCode)
end
+ it "should raise Mooamba::InvalidWeight when there's no weight" do
+ lambda { Mooamba::Sedex.calculate(@default_parameters.except(:weight)) }.should raise_error(Mooamba::InvalidWeight)
+ end
+
it "should raise Mooamba::InvalidOriginZipCode when the origin zip code is blank" do
lambda { Mooamba::Sedex.calculate(@default_parameters.merge(:from => "")) }.should raise_error(Mooamba::InvalidOriginZipCode)
end
it "should raise Mooamba::InvalidDestinationZipCode when the destiny zip code is blank" do
lambda { Mooamba::Sedex.calculate(@default_parameters.merge(:to => "")) }.should raise_error(Mooamba::InvalidDestinationZipCode)
end
+ it "should raise Mooamba::InvalidWeight when the weight is blank" do
+ lambda { Mooamba::Sedex.calculate(@default_parameters.merge(:weight => "")) }.should raise_error(Mooamba::InvalidWeight)
+ end
+
it "should raise Mooamba::InvalidOriginZipCode when the origin zip code is invalid" do
lambda { Mooamba::Sedex.calculate(@default_parameters.merge(:from => INVALID_ZIP_CODES.last)) }.should raise_error(Mooamba::InvalidOriginZipCode)
end
it "should raise Mooamba::InvalidDestinationZipCode when the destiny zip code is invalid" do
lambda { Mooamba::Sedex.calculate(@default_parameters.merge(:to => INVALID_ZIP_CODES.first)) }.should raise_error(Mooamba::InvalidDestinationZipCode)
end
+ it "should raise Mooamba::InvalidWeight when the weight is 0" do
+ lambda { Mooamba::Sedex.calculate(@default_parameters.merge(:weight => 0)) }.should raise_error(Mooamba::InvalidWeight)
+ end
+
+ it "should raise Mooamba::InvalidWeight when the weight is negative" do
+ lambda { Mooamba::Sedex.calculate(@default_parameters.merge(:weight => -4)) }.should raise_error(Mooamba::InvalidWeight)
+ end
+
it "should raise Mooamba::UnavailableAPI when api returns unexpected content" do
map_parameters_to_file(@default_parameters, "malformed")
lambda { Mooamba::Sedex.calculate(@default_parameters) }.should raise_error(Mooamba::UnavailableAPI)
end
@@ -60,12 +76,22 @@
it "should raise Mooamba::Correios::InvalidDestinyZipCode when the invalid destiny zip code doesn't exist" do
map_parameters_to_file(@default_parameters, "invalid_destiny")
lambda { Mooamba::Sedex.calculate(@default_parameters) }.should raise_error(Mooamba::Correios::InvalidDestinyZipCode)
end
- it "should raise Mooamba::Correios::InvalidWeight when the weight if excessive" do
- map_parameters_to_file(@default_parameters, "invalid_weight")
- lambda { Mooamba::Sedex.calculate(@default_parameters) }.should raise_error(Mooamba::Correios::InvalidWeight)
+ it "should raise Mooamba::Correios::ExcessiveWeight when the weight if excessive" do
+ map_parameters_to_file(@default_parameters, "excessive_weight")
+ lambda { Mooamba::Sedex.calculate(@default_parameters) }.should raise_error(Mooamba::Correios::ExcessiveWeight)
+ end
+
+ it "should raise Mooamba::Correios::UnavailableServiceForArea when the service is unavailable for the current area" do
+ map_parameters_to_file(@default_parameters, "unavailable_service_for_area")
+ lambda { Mooamba::Sedex.calculate(@default_parameters) }.should raise_error(Mooamba::Correios::UnavailableServiceForArea)
+ end
+
+ it "should raise Mooamba::Correios::UnavailableServiceForArea when the pricing service is unavailable for the current area" do
+ map_parameters_to_file(@default_parameters, "unavailable_pricing_service_for_area")
+ lambda { Mooamba::Sedex.calculate(@default_parameters) }.should raise_error(Mooamba::Correios::UnavailableServiceForArea)
end
it "should raise Mooamba::Correios::UnavailableServiceForArea when the service is unavailable for the current area" do
map_parameters_to_file(@default_parameters, "unavailable_service_for_area")
lambda { Mooamba::Sedex.calculate(@default_parameters) }.should raise_error(Mooamba::Correios::UnavailableServiceForArea)