First pass at initial specs for Webrat::SinatraSession

This commit is contained in:
Josh Knowles 2008-12-25 17:58:56 -05:00
parent b88b2b2949
commit d0504d9344
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,15 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require "webrat/sinatra"
class Sinatra::Application
# Override this to prevent Sinatra from barfing on the options passed from RSpec
def self.load_default_options_from_command_line!
end
end
Sinatra::Application.default_options.merge!(
:env => :test,
:run => false,
:raise_errors => true,
:logging => false
)

View File

@ -0,0 +1,35 @@
require File.expand_path(File.dirname(__FILE__) + '/helper')
describe Webrat::SinatraSession do
before :each do
@sinatra_session = Webrat::SinatraSession.new
@response = mock(:response)
@response.stub!(:redirect?)
@sinatra_session.instance_variable_set("@response", @response)
end
it "should delegate get to get_it" do
@sinatra_session.should_receive(:get_it).with("url", { :env => "headers" })
@sinatra_session.get("url", {}, "headers")
end
it "should delegate post to post_it" do
@sinatra_session.should_receive(:post_it).with("url", { :env => "headers" })
@sinatra_session.post("url", {}, "headers")
end
it "should delegate put to put_it" do
@sinatra_session.should_receive(:put_it).with("url", { :env => "headers" })
@sinatra_session.put("url", {}, "headers")
end
it "should delegate delete to delete_it" do
@sinatra_session.should_receive(:delete_it).with("url", { :env => "headers" })
@sinatra_session.delete("url", {}, "headers")
end
end
# Hack required to reset configuration mode to play nice with other specs that depend on this being rails
Webrat.configuration.mode = :rails