Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resurrecting old tests where applicable
- Loading branch information
1 parent
bdd2ab5
commit 662b85d
Showing
3 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require "#{File.dirname(__FILE__)}/../helpers.rb" | ||
|
||
describe "Configuration attributes" do | ||
|
||
class Basic < Waves::Configurations::Base; end | ||
|
||
it "can be declared by developers" do | ||
Basic.attribute :smurf | ||
Basic.smurf("smurfy") | ||
Basic.smurf.should == "smurfy" | ||
end | ||
|
||
|
||
it "must be declared before use" do | ||
Basic.should.not.respond_to :gnome | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require "#{File.dirname(__FILE__)}/../helpers.rb" | ||
|
||
describe "A Waves request instance" do | ||
|
||
before do | ||
@request = Waves::Request.new(env( '/', :method => 'GET' )) | ||
end | ||
|
||
it "has session, response, and blackboard objects" do | ||
@request.session.class.should == Waves::Session | ||
@request.response.class.should == Waves::Response | ||
end | ||
|
||
it "provides an accessor to the Rack request" do | ||
@request.rack_request.class.should == Rack::Request | ||
end | ||
|
||
it "wraps some useful Rack data in more elegant methods" do | ||
@request.path.should == "/" | ||
|
||
@request.domain.should == "example.org" | ||
|
||
# @request.content_type.should == "text/html" | ||
end | ||
|
||
# it "delegates unknown methods to the Rack request" do | ||
# @request.chitty_bang_bang | ||
# end | ||
|
||
end | ||
|
||
describe "The HTTP request method" do | ||
|
||
|
||
it "is determined in a straightforward manner for straightforward requests" do | ||
@get = Waves::Request.new(env("/", :method => 'GET')) | ||
@post = Waves::Request.new(env("/", :method => 'POST')) | ||
@put = Waves::Request.new(env("/", :method => 'PUT')) | ||
@delete = Waves::Request.new(env("/", :method => 'DELETE')) | ||
|
||
@get.method.should == :get | ||
@post.method.should == :post | ||
@put.method.should == :put | ||
@delete.method.should == :delete | ||
end | ||
|
||
it "can be set with the '_method' query param on a POST" do | ||
@url_put = Waves::Request.new(env("/?_method=put", :method => 'POST')) | ||
@url_delete = Waves::Request.new(env("/?_method=delete", :method => 'POST')) | ||
|
||
@url_put.method.should == :put; @url_put.put.should.be.true | ||
@url_delete.method.should == :delete; @url_delete.delete.should.be.true | ||
end | ||
|
||
it "can be set with the '_method' body param on a POST" do | ||
@body_put = Waves::Request.new(env("/", :method => 'POST', :input => '_method=put')) | ||
@body_delete = Waves::Request.new(env("/", :method => 'POST', :input => '_method=delete')) | ||
|
||
@body_put.method.should == :put; @body_put.put.should.be.true | ||
@body_delete.method.should == :delete | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require "#{File.dirname(__FILE__)}/../helpers.rb" | ||
|
||
describe "An instance of Waves::Response" do | ||
|
||
before do | ||
@request = Waves::Request.new(env( '/', :method => 'GET' )) | ||
@response = Waves::Response.new(@request) | ||
end | ||
|
||
it "has a Rack::Response" do | ||
@response.rack_response.class.should == Rack::Response | ||
end | ||
|
||
it "has a Waves::Request" do | ||
@response.request.class.should == Waves::Request | ||
end | ||
|
||
it "can access the session for the current request" do | ||
@response.session.class.should == Waves::Session | ||
end | ||
|
||
it "provides setter methods for commonly used headers" do | ||
@response.rack_response.should.receive(:[]=).with('Content-Type', 'text/javascript') | ||
@response.content_type = 'text/javascript' | ||
|
||
@response.rack_response.should.receive(:[]=).with('Content-Length', '42') | ||
@response.content_length = '42' | ||
|
||
@response.rack_response.should.receive(:[]=).with('Location', '/here/') | ||
@response.location = '/here/' | ||
|
||
@response.rack_response.should.receive(:[]=).with('Expires', 'Thu, 09 Aug 2007 05:22:55 GMT') | ||
@response.expires = 'Thu, 09 Aug 2007 05:22:55 GMT' | ||
end | ||
|
||
it "delegates unknown methods to the Rack response" do | ||
@response.rack_response.should.receive(:mclintock!) | ||
@response.mclintock! | ||
end | ||
|
||
end | ||
|
||
describe "Waves::Response#finish" do | ||
|
||
before do | ||
@request = Waves::Request.new(env( '/', :method => 'GET' )) | ||
@response = Waves::Response.new(@request) | ||
end | ||
|
||
it "saves the request session and calls Rack::Response#finish" do | ||
@response.rack_response.should.receive(:finish) | ||
@response.finish | ||
end | ||
|
||
end |