Permalink
Browse files

Replace FakeWeb to WebMock.

  • Loading branch information...
1 parent b9457dc commit 56a84a8d3cb2258d927c77ee1f97195293a953ef @prodis committed Aug 9, 2012
View
@@ -26,5 +26,5 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "rake"
gem.add_development_dependency "rspec", "~> 2.11"
- gem.add_development_dependency "fakeweb", "~> 1.3"
+ gem.add_development_dependency "webmock", "~> 1.8"
end
@@ -106,7 +106,7 @@
before(:each) { @frete = Correios::Frete::Calculador.new }
context "to many services" do
- before(:each) { fake_request_for(:success_response_many_services) }
+ before(:each) { mock_request_for(:success_response_many_services) }
it "creates a WebService with correct params" do
web_service = Correios::Frete::WebService.new @frete, [:pac, :sedex]
@@ -123,7 +123,7 @@
end
context "to one service" do
- before(:each) { fake_request_for(:success_response_one_service) }
+ before(:each) { mock_request_for(:success_response_one_service) }
it "creates a WebService with correct params" do
web_service = Correios::Frete::WebService.new @frete, [:sedex]
@@ -13,7 +13,7 @@
let(:web_service) { Correios::Frete::WebService.new(frete, [:pac, :sedex]) }
it "returns XML response" do
- fake_request_for("<xml><fake></fake>")
+ mock_request_for("<xml><fake></fake>")
web_service.request!.should == "<xml><fake></fake>"
end
end
View
@@ -1,8 +1,8 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
-require 'rspec'
require 'correios-frete'
-require 'fakeweb'
+require 'rspec'
+require 'webmock/rspec'
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
@@ -11,4 +11,4 @@
RSpec.configure do |config|
end
-FakeWeb.allow_net_connect = false
+WebMock.disable_net_connect!
@@ -1,10 +1,8 @@
# encoding: UTF-8
-def fake_request_for(response)
- FakeWeb.register_uri(:get,
- Regexp.new("http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx"),
- :status => 200,
- :body => body_for(response))
+def mock_request_for(response)
+ url = Regexp.new("http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx")
+ WebMock::API.stub_request(:get, url).to_return(:status => 200, :body => body_for(response))
end
def body_for(response)

0 comments on commit 56a84a8

Please sign in to comment.