First pass at initial specs for Webrat::SinatraSession
This commit is contained in:
parent
b88b2b2949
commit
d0504d9344
15
spec/webrat/sinatra/helper.rb
Normal file
15
spec/webrat/sinatra/helper.rb
Normal 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
|
||||||
|
)
|
35
spec/webrat/sinatra/sinatra_spec.rb
Normal file
35
spec/webrat/sinatra/sinatra_spec.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user