You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by do...@apache.org on 2014/07/31 07:12:31 UTC

[17/50] git commit: Remove use of deprecated mock method

Remove use of deprecated mock method

git-svn-id: https://svn.apache.org/repos/asf/buildr/trunk@1536185 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/buildr/repo
Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/87afece5
Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/87afece5
Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/87afece5

Branch: refs/heads/master
Commit: 87afece5bf0279384bb7420ca56fc4d37c333bc1
Parents: 3425521
Author: Peter Donald <do...@apache.org>
Authored: Sun Oct 27 19:25:30 2013 +0000
Committer: Peter Donald <do...@apache.org>
Committed: Sun Oct 27 19:25:30 2013 +0000

----------------------------------------------------------------------
 spec/core/common_spec.rb    |  4 ++--
 spec/core/test_spec.rb      |  4 ++--
 spec/core/transport_spec.rb | 28 ++++++++++++++--------------
 3 files changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/buildr/blob/87afece5/spec/core/common_spec.rb
----------------------------------------------------------------------
diff --git a/spec/core/common_spec.rb b/spec/core/common_spec.rb
index 8240545..c741b34 100644
--- a/spec/core/common_spec.rb
+++ b/spec/core/common_spec.rb
@@ -97,7 +97,7 @@ end
 describe Buildr.method(:download) do
   before do
     @content = 'we has download!'
-    @http = mock('http')
+    @http = double('http')
     @http.stub(:request).and_return(Net::HTTPNotModified.new(nil, nil, nil))
   end
 
@@ -601,7 +601,7 @@ describe Buildr::Options, 'proxy.exclude' do
     @uri = URI("http://#{@host}")
     @no_proxy_args = [@host, 80]
     @proxy_args = @no_proxy_args + ['myproxy', 8080, nil, nil]
-    @http = mock('http')
+    @http = double('http')
     @http.stub(:request).and_return(Net::HTTPNotModified.new(nil, nil, nil))
   end
 

http://git-wip-us.apache.org/repos/asf/buildr/blob/87afece5/spec/core/test_spec.rb
----------------------------------------------------------------------
diff --git a/spec/core/test_spec.rb b/spec/core/test_spec.rb
index 68f8db5..4c48cf2 100644
--- a/spec/core/test_spec.rb
+++ b/spec/core/test_spec.rb
@@ -183,7 +183,7 @@ describe Buildr::TestTask do
   end
 
   it 'should execute setup task before running tests' do
-    mock = mock('actions')
+    mock = double('actions')
     test_task.setup { mock.setup }
     test_task.enhance { mock.tests }
     mock.should_receive(:setup).ordered
@@ -192,7 +192,7 @@ describe Buildr::TestTask do
   end
 
   it 'should execute teardown task after running tests' do
-    mock = mock('actions')
+    mock = double('actions')
     test_task.teardown { mock.teardown }
     test_task.enhance { mock.tests }
     mock.should_receive(:tests).ordered

http://git-wip-us.apache.org/repos/asf/buildr/blob/87afece5/spec/core/transport_spec.rb
----------------------------------------------------------------------
diff --git a/spec/core/transport_spec.rb b/spec/core/transport_spec.rb
index f8c554b..f8bf079 100644
--- a/spec/core/transport_spec.rb
+++ b/spec/core/transport_spec.rb
@@ -237,7 +237,7 @@ describe URI::HTTP, '#read' do
     @uri = URI("http://#{@host_domain}#{@path}#{@query}")
     @no_proxy_args = [@host_domain, 80]
     @proxy_args = @no_proxy_args + ['myproxy', 8080, 'john', 'smith']
-    @http = mock('http')
+    @http = double('http')
     @http.stub(:request).and_yield(Net::HTTPNotModified.new(nil, nil, nil))
   end
 
@@ -318,7 +318,7 @@ describe URI::HTTP, '#read' do
 
   it 'should use HTTP Basic authentication' do
     Net::HTTP.should_receive(:new).and_return(@http)
-    request = mock('request')
+    request = double('request')
     Net::HTTP::Get.should_receive(:new).and_return(request)
     request.should_receive(:basic_auth).with('john', 'secret')
     URI("http://john:secret@#{@host_domain}").read
@@ -331,7 +331,7 @@ describe URI::HTTP, '#read' do
     redirect = Net::HTTPRedirection.new(nil, nil, nil)
     redirect['Location'] = "http://#{@host_domain}/asdf"
 
-    request1 = mock('request1')
+    request1 = double('request1')
     Net::HTTP::Get.should_receive(:new).once.with('/', default_http_headers).and_return(request1)
     request1.should_receive(:basic_auth).with('john', 'secret')
     @http.should_receive(:request).with(request1).and_yield(redirect)
@@ -340,7 +340,7 @@ describe URI::HTTP, '#read' do
     ok = Net::HTTPOK.new(nil, nil, nil)
     ok.stub(:read_body)
 
-    request2 = mock('request2')
+    request2 = double('request2')
     Net::HTTP::Get.should_receive(:new).once.with("/asdf", default_http_headers).and_return(request2)
     request2.should_receive(:basic_auth).with('john', 'secret')
     @http.should_receive(:request).with(request2).and_yield(ok)
@@ -362,7 +362,7 @@ describe URI::HTTP, '#write' do
   before do
     @content = 'Readme. Please!'
     @uri = URI('http://john:secret@host.domain/foo/bar/baz.jar')
-    @http = mock('Net::HTTP')
+    @http = double('Net::HTTP')
     @http.stub(:request).and_return(Net::HTTPOK.new(nil, nil, nil))
     Net::HTTP.stub(:new).and_return(@http)
   end
@@ -438,9 +438,9 @@ describe URI::SFTP, '#read' do
     @uri = URI('sftp://john:secret@localhost/root/path/readme')
     @content = 'Readme. Please!'
 
-    @ssh_session = mock('Net::SSH::Session')
-    @sftp_session = mock('Net::SFTP::Session')
-    @file_factory = mock('Net::SFTP::Operations::FileFactory')
+    @ssh_session = double('Net::SSH::Session')
+    @sftp_session = double('Net::SFTP::Session')
+    @file_factory = double('Net::SFTP::Operations::FileFactory')
     Net::SSH.stub(:start).with('localhost', 'john', :password=>'secret', :port=>22).and_return(@ssh_session) do
       Net::SFTP::Session.should_receive(:new).with(@ssh_session).and_yield(@sftp_session).and_return(@sftp_session)
       @sftp_session.should_receive(:connect!).and_return(@sftp_session)
@@ -462,14 +462,14 @@ describe URI::SFTP, '#read' do
   end
 
   it 'should read contents of file and return it' do
-    file = mock('Net::SFTP::Operations::File')
+    file = double('Net::SFTP::Operations::File')
     file.should_receive(:read).with(URI::RW_CHUNK_SIZE).once.and_return(@content)
     @file_factory.should_receive(:open).with('/root/path/readme', 'r').and_yield(file)
     @uri.read.should eql(@content)
   end
 
   it 'should read contents of file and pass it to block' do
-    file = mock('Net::SFTP::Operations::File')
+    file = double('Net::SFTP::Operations::File')
     file.should_receive(:read).with(URI::RW_CHUNK_SIZE).once.and_return(@content)
     @file_factory.should_receive(:open).with('/root/path/readme', 'r').and_yield(file)
     content = ''
@@ -486,9 +486,9 @@ describe URI::SFTP, '#write' do
     @uri = URI('sftp://john:secret@localhost/root/path/readme')
     @content = 'Readme. Please!'
 
-    @ssh_session = mock('Net::SSH::Session')
-    @sftp_session = mock('Net::SFTP::Session')
-    @file_factory = mock('Net::SFTP::Operations::FileFactory')
+    @ssh_session = double('Net::SSH::Session')
+    @sftp_session = double('Net::SFTP::Session')
+    @file_factory = double('Net::SFTP::Operations::FileFactory')
     Net::SSH.stub(:start).with('localhost', 'john', :password=>'secret', :port=>22).and_return(@ssh_session) do
       Net::SFTP::Session.should_receive(:new).with(@ssh_session).and_yield(@sftp_session).and_return(@sftp_session)
       @sftp_session.should_receive(:connect!).and_return(@sftp_session)
@@ -539,7 +539,7 @@ describe URI::SFTP, '#write' do
   end
 
   it 'should write contents to file' do
-    file = mock('Net::SFTP::Operations::File')
+    file = double('Net::SFTP::Operations::File')
     file.should_receive(:write).with(@content)
     @file_factory.should_receive(:open).with('/root/path/readme', 'w').and_yield(file)
     @uri.write @content