Permalink
Browse files

fixing test suite to work with the latest version of rspec

  • Loading branch information...
1 parent abf0347 commit cdeb5d00b302d8ead987ca9a9988989ecd709344 Aaron Bedra committed May 22, 2009
View
@@ -50,7 +50,7 @@ Spec::Rake::SpecTask.new('spec') do |t|
end
RCov::VerifyTask.new(:verify_coverage => :specs_with_rcov) do |t|
- t.threshold = 97.0
+ t.threshold = 97.03
t.index_html = 'coverage/index.html'
end
View
@@ -1,6 +1,6 @@
require 'rubygems'
-gem :activerecord, '>= 2.1.0'
-gem :activesupport, '>= 2.1.0'
+gem 'activerecord', '>= 2.1.0'
+gem 'activesupport', '>= 2.1.0'
require 'active_support'
require 'activerecord'
@@ -42,7 +42,7 @@
describe "when the credentials are invalid" do
it "returns a Castronaut::AuthenticationResult object with the unable to authenticate user message" do
- Castronaut::Adapters::Development::User.stub!(:find_by_login).and_return(stub_everything(:crypted_password => "a", :salt => "b"))
+ Castronaut::Adapters::Development::User.stub!(:find_by_login).and_return(stub(:crypted_password => "a", :salt => "b").as_null_object)
Castronaut::Adapters::Development::User.authenticate('bob', '1234').error_message.should == "Unable to authenticate the username bob"
end
@@ -5,14 +5,14 @@
describe "authenticate" do
it "attempts to authenticate the user" do
- connection = stub_everything
+ connection = stub({}).as_null_object
Net::LDAP.stub!(:new).and_return(connection)
connection.should_receive(:authenticate).with('cn=bob, dc=example, dc=com, ', '1234').and_return(nil)
Castronaut::Adapters::Ldap::User.authenticate('cn=bob, dc=example, dc=com', '1234')
end
it "returns a failed to authenticate message when authentication fails" do
- connection = stub_everything
+ connection = stub({}).as_null_object
Net::LDAP.stub!(:new).and_return(connection)
connection.stub!(:authenticate).and_return(nil)
connection.stub!(:bind).and_return(false)
@@ -85,7 +85,7 @@
describe "when the credentials are invalid" do
it "returns a Castronaut::AuthenticationResult object with the unable to authenticate user message" do
- Castronaut::Adapters::RestfulAuthentication::User.stub!(:find_by_login).and_return(stub_everything(:crypted_password => "a", :salt => "b"))
+ Castronaut::Adapters::RestfulAuthentication::User.stub!(:find_by_login).and_return(stub(:crypted_password => "a", :salt => "b").as_null_object)
Castronaut::Adapters::RestfulAuthentication::User.authenticate('bob', '1234').error_message.should == "Unable to authenticate the username bob"
end
@@ -15,7 +15,7 @@
config = Castronaut::Configuration.new
config.stub!(:parse_config_into_settings)
config.stub!(:connect_activerecord)
- config.stub!(:setup_logger).and_return(stub_everything)
+ config.stub!(:setup_logger).and_return(stub({}).as_null_object)
Castronaut::Configuration.stub!(:new).and_return(config)
Castronaut::Configuration.load.config_file_path.should == './castronaut.yml'
@@ -27,7 +27,7 @@
config = Castronaut::Configuration.new
config.stub!(:parse_config_into_settings)
config.stub!(:connect_activerecord)
- config.stub!(:setup_logger).and_return(stub_everything)
+ config.stub!(:setup_logger).and_return(stub({}).as_null_object)
Castronaut::Configuration.stub!(:new).and_return(config)
Castronaut::Configuration.load("/foo/bar/baz").config_file_path.should == '/foo/bar/baz'
@@ -39,7 +39,7 @@
config = Castronaut::Configuration.new
config.stub!(:parse_config_into_settings)
config.stub!(:connect_activerecord)
- config.stub!(:setup_logger).and_return(stub_everything)
+ config.stub!(:setup_logger).and_return(stub({}).as_null_object)
Castronaut::Configuration.stub!(:new).and_return(config)
Castronaut::Configuration.load(@test_config_file)
@@ -52,7 +52,7 @@
config = Castronaut::Configuration.new
config.stub!(:parse_config_into_settings)
config.stub!(:connect_activerecord)
- config.stub!(:setup_logger).and_return(stub_everything)
+ config.stub!(:setup_logger).and_return(stub({}).as_null_object)
Castronaut::Configuration.stub!(:new).and_return(config)
Castronaut::Configuration.load(@test_config_file).config_hash = config_hash
@@ -72,7 +72,7 @@
config = Castronaut::Configuration.new
config.stub!(:connect_activerecord)
Castronaut::Configuration.stub!(:new).and_return(config)
- Hodel3000CompliantLogger.should_receive(:new).with("log/castronaut.log", anything).and_return(stub_everything)
+ Hodel3000CompliantLogger.should_receive(:new).with("log/castronaut.log", anything).and_return(stub({}).as_null_object)
Castronaut::Configuration.load(@test_config_file)
end
@@ -90,7 +90,7 @@
config.stub!(:connect_activerecord)
Castronaut::Configuration.stub!(:new).and_return(config)
- Hodel3000CompliantLogger.should_receive(:new).with("log/castronaut.log", "daily").and_return(stub_everything)
+ Hodel3000CompliantLogger.should_receive(:new).with("log/castronaut.log", "daily").and_return(stub({}).as_null_object)
Castronaut::Configuration.load(@test_config_file)
end
@@ -70,7 +70,7 @@
describe "and it has already been consumed" do
it "returns a ticket result with the AlreadyConsumedMessage" do
- login_ticket = stub_everything(:consumed? => true)
+ login_ticket = stub(:consumed? => true).as_null_object
Castronaut::TicketResult.should_receive(:new).with(login_ticket, LoginTicket::AlreadyConsumedMessage)
LoginTicket.stub!(:find_by_ticket).and_return(login_ticket)
@@ -69,7 +69,7 @@
describe "when proxy granting ticket url is valid" do
it "creates a new net/http connection to uri host and port" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
uri = stub('uri', :host => 'example.com', :port => 443, :path => '')
@@ -80,10 +80,10 @@
end
it "sets the new net/http connection to use ssl" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
- uri = stub_everything(:host => 'example.com', :port => 443, :path => '')
+ uri = stub(:host => 'example.com', :port => 443, :path => '').as_null_object
URI.stub!(:parse).and_return(uri)
https.should_receive(:use_ssl=).with(true)
@@ -94,10 +94,10 @@
end
it "starts the connection" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
- uri = stub_everything(:host => 'example.com', :port => 443, :path => '')
+ uri = stub(:host => 'example.com', :port => 443, :path => '').as_null_object
URI.stub!(:parse).and_return(uri)
https.should_receive(:start)
@@ -108,58 +108,58 @@
describe "inside the http connection block" do
it "intializes a new proxy granting ticket" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
- uri = stub_everything(:host => 'example.com', :port => 443, :path => '')
+ uri = stub(:host => 'example.com', :port => 443, :path => '').as_null_object
URI.stub!(:parse).and_return(uri)
- https.stub!(:start).and_yield(stub_everything(:request_get => stub_everything))
+ https.stub!(:start).and_yield(stub(:request_get => stub({}).as_null_object).as_null_object)
- ProxyGrantingTicket.should_receive(:new).with(:service_ticket => 'service ticket', :client_hostname => '10.1.1.1').and_return(stub_everything)
+ ProxyGrantingTicket.should_receive(:new).with(:service_ticket => 'service ticket', :client_hostname => '10.1.1.1').and_return(stub({}).as_null_object)
ProxyGrantingTicket.generate_ticket('http://example.com', '10.1.1.1', 'service ticket')
end
it "dispenses a new ticket for the proxy granting ticket" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
- uri = stub_everything(:host => 'example.com', :port => 443, :path => '')
+ uri = stub(:host => 'example.com', :port => 443, :path => '').as_null_object
URI.stub!(:parse).and_return(uri)
- https.stub!(:start).and_yield(stub_everything(:request_get => stub_everything))
+ https.stub!(:start).and_yield(stub(:request_get => stub({}).as_null_object).as_null_object)
- proxy_granting_ticket = stub_everything
+ proxy_granting_ticket = stub({}).as_null_object
proxy_granting_ticket.should_receive(:dispense_ticket)
ProxyGrantingTicket.stub!(:new).and_return(proxy_granting_ticket)
ProxyGrantingTicket.generate_ticket('http://example.com', '10.1.1.1', 'service ticket')
end
it "dispenses a new iou for the proxy granting ticket" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
- uri = stub_everything(:host => 'example.com', :port => 443, :path => '')
+ uri = stub(:host => 'example.com', :port => 443, :path => '').as_null_object
URI.stub!(:parse).and_return(uri)
- https.stub!(:start).and_yield(stub_everything(:request_get => stub_everything))
+ https.stub!(:start).and_yield(stub(:request_get => stub({}).as_null_object).as_null_object)
- proxy_granting_ticket = stub_everything
+ proxy_granting_ticket = stub({}).as_null_object
proxy_granting_ticket.should_receive(:dispense_iou)
ProxyGrantingTicket.stub!(:new).and_return(proxy_granting_ticket)
ProxyGrantingTicket.generate_ticket('http://example.com', '10.1.1.1', 'service ticket')
end
it "requests the proxy granting ticket path via GET" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
- uri = stub_everything(:host => 'example.com', :port => 443, :path => '')
+ uri = stub(:host => 'example.com', :port => 443, :path => '').as_null_object
URI.stub!(:parse).and_return(uri)
http_connection = mock('httpconnection')
- http_connection.should_receive(:request_get).with('/?pgtId=PGT-RANDOM&pgtIou=PGTIOU-RANDOM').and_return(stub_everything)
+ http_connection.should_receive(:request_get).with('/?pgtId=PGT-RANDOM&pgtIou=PGTIOU-RANDOM').and_return(stub({}).as_null_object)
https.stub!(:start).and_yield(http_connection)
@@ -171,7 +171,7 @@
describe "when the request to the proxy granting ticket path is successful" do
it "saves the proxy granting ticket" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
uri = stub('uri', :host => 'example.com', :port => 443, :path => '', :query => '')
@@ -191,7 +191,7 @@
describe "returns a ticket result" do
it "with the proxy granting ticket" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
uri = stub('uri', :host => 'example.com', :port => 443, :path => '', :query => '')
@@ -207,10 +207,10 @@
end
it "with a proxy granting ticket generated message" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
- uri = stub_everything(:host => 'example.com', :port => 443, :path => '')
+ uri = stub(:host => 'example.com', :port => 443, :path => '').as_null_object
URI.stub!(:parse).and_return(uri)
http_connection = mock('httpconnection')
http_connection.stub!(:request_get).and_return(stub('request', :code => '200'))
@@ -223,16 +223,16 @@
end
it "with a message category of success" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
- uri = stub_everything(:host => 'example.com', :port => 443, :path => '')
+ uri = stub(:host => 'example.com', :port => 443, :path => '').as_null_object
URI.stub!(:parse).and_return(uri)
http_connection = mock('httpconnection')
http_connection.stub!(:request_get).and_return(stub('request', :code => '200'))
https.stub!(:start).and_yield(http_connection)
- proxy_granting_ticket = stub_everything(:iou => 'PGTIOU-RANDOM', :ticket => 'PGT-RANDOM', :save! => true)
+ proxy_granting_ticket = stub(:iou => 'PGTIOU-RANDOM', :ticket => 'PGT-RANDOM', :save! => true).as_null_object
ProxyGrantingTicket.stub!(:new).and_return(proxy_granting_ticket)
ProxyGrantingTicket.generate_ticket('http://example.com', '10.1.1.1', 'service ticket').message_category.should == 'success'
@@ -247,32 +247,32 @@
describe "returns a ticket result" do
it "with a proxy granting ticket generated message" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
- uri = stub_everything(:host => 'example.com', :port => 443, :path => '')
+ uri = stub(:host => 'example.com', :port => 443, :path => '').as_null_object
URI.stub!(:parse).and_return(uri)
http_connection = mock('httpconnection')
http_connection.stub!(:request_get).and_return(stub('request', :code => '404'))
https.stub!(:start).and_yield(http_connection)
- proxy_granting_ticket = stub_everything(:iou => 'PGTIOU-RANDOM', :ticket => 'PGT-RANDOM', :save! => true, :inspect => 'PGT-INSPECT')
+ proxy_granting_ticket = stub(:iou => 'PGTIOU-RANDOM', :ticket => 'PGT-RANDOM', :save! => true, :inspect => 'PGT-INSPECT').as_null_object
ProxyGrantingTicket.stub!(:new).and_return(proxy_granting_ticket)
ProxyGrantingTicket.generate_ticket('http://example.com', '10.1.1.1', 'service ticket').message.should == "PGT callback server responded with a bad result code '404'. PGT will not be stored."
end
it "with a message category of success" do
- https = stub_everything
+ https = stub({}).as_null_object
Net::HTTP.stub!(:new).and_return(https)
- uri = stub_everything(:host => 'example.com', :port => 443, :path => '')
+ uri = stub(:host => 'example.com', :port => 443, :path => '').as_null_object
URI.stub!(:parse).and_return(uri)
http_connection = mock('httpconnection')
- http_connection.stub!(:request_get).and_return(stub_everything(:code => '404'))
+ http_connection.stub!(:request_get).and_return(stub(:code => '404').as_null_object)
https.stub!(:start).and_yield(http_connection)
- proxy_granting_ticket = stub_everything(:iou => 'PGTIOU-RANDOM', :ticket => 'PGT-RANDOM', :save! => true)
+ proxy_granting_ticket = stub(:iou => 'PGTIOU-RANDOM', :ticket => 'PGT-RANDOM', :save! => true).as_null_object
ProxyGrantingTicket.stub!(:new).and_return(proxy_granting_ticket)
ProxyGrantingTicket.generate_ticket('http://example.com', '10.1.1.1', 'service ticket').message_category.should == 'warn'
@@ -16,7 +16,7 @@
describe "validating ticket" do
it "validates the service and ticket using the service ticket validator" do
- ServiceTicket.should_receive(:validate_ticket).with('service', 'ticket', true).and_return(stub_everything(:invalid? => true))
+ ServiceTicket.should_receive(:validate_ticket).with('service', 'ticket', true).and_return(stub(:invalid? => true).as_null_object)
ProxyTicket.validate_ticket('service', 'ticket')
end
@@ -114,7 +114,7 @@
describe "when the service and ticket are given" do
it "attempts to find the ServiceTicket by the given ticket" do
- Castronaut::Models::ServiceTicket.should_receive(:find_by_ticket).with('ticket').and_return(stub_everything)
+ Castronaut::Models::ServiceTicket.should_receive(:find_by_ticket).with('ticket').and_return(stub({}).as_null_object)
Castronaut::Models::ServiceTicket.validate_ticket('service', 'ticket')
end
@@ -142,17 +142,17 @@
describe "when it is already consumed it returns a ticket result" do
it "with the ticket used up message" do
- Castronaut::Models::ServiceTicket.stub!(:find_by_ticket).and_return(stub_everything(:consumed? => true))
+ Castronaut::Models::ServiceTicket.stub!(:find_by_ticket).and_return(stub(:consumed? => true).as_null_object)
Castronaut::Models::ServiceTicket.validate_ticket('service', 'ticket').message.should == "Ticket 'ticket' has already been used up."
end
it "with the INVALID_TICKET message category" do
- Castronaut::Models::ServiceTicket.stub!(:find_by_ticket).and_return(stub_everything(:consumed? => true))
+ Castronaut::Models::ServiceTicket.stub!(:find_by_ticket).and_return(stub(:consumed? => true).as_null_object)
Castronaut::Models::ServiceTicket.validate_ticket('service', 'ticket').message_category.should == 'INVALID_TICKET'
end
it "is marked as invalid" do
- Castronaut::Models::ServiceTicket.stub!(:find_by_ticket).and_return(stub_everything(:consumed? => true))
+ Castronaut::Models::ServiceTicket.stub!(:find_by_ticket).and_return(stub(:consumed? => true).as_null_object)
Castronaut::Models::ServiceTicket.validate_ticket('service', 'ticket').should be_invalid
end
@@ -47,7 +47,7 @@
it "validates the ticket generating ticket" do
@controller.request.cookies['tgt'] = 'fake cookie'
- Castronaut::Models::TicketGrantingTicket.should_receive(:validate_cookie).with('fake cookie').and_return(Castronaut::TicketResult.new(stub_everything))
+ Castronaut::Models::TicketGrantingTicket.should_receive(:validate_cookie).with('fake cookie').and_return(Castronaut::TicketResult.new(stub({}).as_null_object))
Castronaut::Presenters::Login.new(@controller).represent!
end
@@ -143,7 +143,7 @@
describe "login ticket generation" do
it "generates a new login ticket when you call :login_ticket" do
- Castronaut::Models::LoginTicket.should_receive(:generate_from).and_return(stub_everything(:ticket => 'ticket'))
+ Castronaut::Models::LoginTicket.should_receive(:generate_from).and_return(stub(:ticket => 'ticket').as_null_object)
Castronaut::Presenters::Login.new(@controller).login_ticket
end
@@ -24,7 +24,7 @@
end
it "generates a new login ticket when you call :login_ticket" do
- Castronaut::Models::LoginTicket.should_receive(:generate_from).and_return(stub_everything(:ticket => 'ticket'))
+ Castronaut::Models::LoginTicket.should_receive(:generate_from).and_return(stub(:ticket => 'ticket').as_null_object)
Castronaut::Presenters::Logout.new(@controller).login_ticket
end
Oops, something went wrong.

0 comments on commit cdeb5d0

Please sign in to comment.