Skip to content

Commit

Permalink
Basic specs to cover cache!, do_not_cache! and content_type!
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Dec 7, 2015
1 parent ed33cd7 commit cea4931
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/spec_response.rb
Expand Up @@ -359,4 +359,37 @@ def object_with_each.each
res.finish.last.wont_respond_to(:to_ary)
lambda { res.finish.last.to_ary }.must_raise NoMethodError
end

it "should specify not to cache content" do
response = Rack::Response.new

response.cache!(1000)
response.do_not_cache!

expect(response['Cache-Control']).must_be_equal "no-cache, must-revalidate"

expires_header = Time.parse(response['Expires'])
expect(expires_header).must_be :<=, Time.now
end

it "should specify to cache content" do
response = Rack::Response.new

duration = 120
expires = Time.now + 100 # At least this far into the future
response.cache!(duration)

expect(response['Cache-Control']).must_be_equal "public, max-age=120"

expires_header = Time.parse(response['Expires'])
expect(expires_header).must_be :>=, expires
end

it "should set content type" do
response = Rack::Response.new

response.content_type! "text/html"

expect(response['Content-Type']).must_be_equal "text/html"
end
end

0 comments on commit cea4931

Please sign in to comment.