Sha256: 56b18de118d6f1342673e14693961da2f5e133c7172e0c54938f185380a693ea

Contents?: true

Size: 737 Bytes

Versions: 6

Compression:

Stored size: 737 Bytes

Contents

require 'spec_helper'

class JSON_API < Goliath::API
  use Goliath::Rack::Params
  use Goliath::Rack::JSONP
  use Goliath::Rack::Render, 'json'

  def response(env)
    [200, {'CONTENT_TYPE' => 'application/json'}, "OK"]
  end
end

describe 'JSONP' do
  let(:err) { Proc.new { fail "API request failed" } }

  it 'sets the content type' do
    with_api(JSON_API) do
      get_request({:query => {:callback => 'test'}}, err) do |c|
        c.response_header['CONTENT_TYPE'].should =~ %r{^application/javascript}
      end
    end
  end

  it 'wraps response with callback' do
    with_api(JSON_API) do
      get_request({:query => {:callback => 'test'}}, err) do |c|
        c.response.should =~ /^test\(.*\)$/
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
goliath-1.0.4 spec/integration/jsonp_spec.rb
goliath-1.0.3 spec/integration/jsonp_spec.rb
goliath-1.0.2 spec/integration/jsonp_spec.rb
goliath-1.0.1 spec/integration/jsonp_spec.rb
goliath-1.0.0 spec/integration/jsonp_spec.rb
goliath-1.0.0.beta.1 spec/integration/jsonp_spec.rb