spec/jsonify_spec.rb in scrapify-0.0.4 vs spec/jsonify_spec.rb in scrapify-0.0.5
- old
+ new
@@ -1,9 +1,14 @@
require 'spec_helper'
require 'test_models'
describe Jsonify do
+ before do
+ ::Pizza.stubs(:http_cache_header).returns("cache-control" => "private")
+ ::Pizza.stubs(:all).returns([])
+ end
+
it "should find all objects and convert to json for index url" do
pizzas = [{name: 'cheese'}, {name: 'chicken'}]
::Pizza.expects(:all).returns(pizzas)
jsonify = Jsonify.new('/pizzas', ::Pizza)
@@ -23,6 +28,14 @@
status.should == 200
header['Content-Type'].should == 'application/json'
response.first.should == pizza.to_json
end
-end
\ No newline at end of file
+
+ it "should forward the http cache headers" do
+ ::Pizza.expects(:http_cache_header).returns("cache-control"=>"private")
+
+ jsonify = Jsonify.new('/pizzas', ::Pizza)
+ status, header, response = jsonify.call('REQUEST_PATH' => '/pizzas')
+ header['cache-control'].should == "private"
+ end
+end