Sha256: 76149e05d0d6da27dded8fe093f2d7cd7349864d5dce29da0f3551c31ea49745
Contents?: true
Size: 1.29 KB
Versions: 5
Compression:
Stored size: 1.29 KB
Contents
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) status, header, response = jsonify.call('REQUEST_PATH' => '/pizzas') status.should == 200 header['Content-Type'].should == 'application/json' response.first.should == pizzas.to_json end it "should find object by id and convert to json for show url" do pizza = {name: 'cheese'} ::Pizza.expects(:find).with('cheese').returns(pizza) jsonify = Jsonify.new('/pizzas', ::Pizza) status, header, response = jsonify.call('REQUEST_PATH' => '/pizzas/cheese') status.should == 200 header['Content-Type'].should == 'application/json' response.first.should == pizza.to_json end 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
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
scrapify-0.0.9 | spec/jsonify_spec.rb |
scrapify-0.0.8 | spec/jsonify_spec.rb |
scrapify-0.0.7 | spec/jsonify_spec.rb |
scrapify-0.0.6 | spec/jsonify_spec.rb |
scrapify-0.0.5 | spec/jsonify_spec.rb |