spec/unit/sucker/response_spec.rb in sucker-1.1.2 vs spec/unit/sucker/response_spec.rb in sucker-1.1.3

- old
+ new

@@ -37,10 +37,11 @@ end it "initializes the request URI" do response.uri.should be_an_instance_of String end + end describe "#xml" do it "returns a Nokogiri document" do @@ -71,13 +72,13 @@ end describe "#each" do - context "when a block is given" do + context "when a block is given" do - it "yields each match to a block" do + it "yields each match to a block" do has_yielded = false response.each("ItemAttributes") do |item| has_yielded = true item.should be_an_instance_of Hash @@ -86,41 +87,45 @@ has_yielded.should be_true end end - context "when no block is given" do + context "when no block is given" do - it "raises error" do - lambda { response.each("ItemAttributes") }.should raise_error(LocalJumpError) - end + it "raises error" do + expect do + response.each("ItemAttributes") + end.to raise_error(LocalJumpError) + end - end + end end describe "#map" do - context "when a block is given" do + context "when a block is given" do - it "yields each match to a block and maps returned values" do + it "yields each match to a block and maps returned values" do # Collect EANs eans = response.map("ItemAttributes") { |item| item["EAN"] } eans.should be_an_instance_of Array eans.each { |ean| ean.match(/^[0-9]{13}$/).should be_true } end end - context "when no block is given" do + context "when no block is given" do - it "raises error" do - lambda { response.map("ItemAttributes") }.should raise_error(LocalJumpError) - end + it "raises error" do + expect do + response.map("ItemAttributes") + end.to raise_error(LocalJumpError) + end - end + end end describe "#to_hash" do