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 2013/10/27 20:25:30 UTC

svn commit: r1536185 - in /buildr/trunk/spec/core: common_spec.rb test_spec.rb transport_spec.rb

Author: donaldp
Date: Sun Oct 27 19:25:30 2013
New Revision: 1536185

URL: http://svn.apache.org/r1536185
Log:
Remove use of deprecated mock method

Modified:
    buildr/trunk/spec/core/common_spec.rb
    buildr/trunk/spec/core/test_spec.rb
    buildr/trunk/spec/core/transport_spec.rb

Modified: buildr/trunk/spec/core/common_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/core/common_spec.rb?rev=1536185&r1=1536184&r2=1536185&view=diff
==============================================================================
--- buildr/trunk/spec/core/common_spec.rb (original)
+++ buildr/trunk/spec/core/common_spec.rb Sun Oct 27 19:25:30 2013
@@ -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
     @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
 

Modified: buildr/trunk/spec/core/test_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/core/test_spec.rb?rev=1536185&r1=1536184&r2=1536185&view=diff
==============================================================================
--- buildr/trunk/spec/core/test_spec.rb (original)
+++ buildr/trunk/spec/core/test_spec.rb Sun Oct 27 19:25:30 2013
@@ -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

Modified: buildr/trunk/spec/core/transport_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/core/transport_spec.rb?rev=1536185&r1=1536184&r2=1536185&view=diff
==============================================================================
--- buildr/trunk/spec/core/transport_spec.rb (original)
+++ buildr/trunk/spec/core/transport_spec.rb Sun Oct 27 19:25:30 2013
@@ -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