Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Sinatra 2.0 #9

Merged
merged 4 commits into from
Sep 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: ruby
rvm:
- 1.9.3
- 2.4
- 2.3
- 2.2
- jruby
- ruby-head
before_install:
Expand Down
7 changes: 4 additions & 3 deletions sinatra-jsonp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ Gem::Specification.new do |s|
s.version = "0.4.4"
s.description = "JSONP output helper for Sinatra"

s.add_dependency "sinatra", "~> 1.0"
s.add_dependency "sinatra", ">= 1.0"
s.add_dependency "multi_json", "~> 1.8"

s.add_development_dependency 'rspec', '~> 2.3'
s.add_development_dependency 'rspec', '~> 3.0'
s.add_development_dependency 'rake', '>= 0'
s.add_development_dependency 'sinatra-contrib', '~> 1.0'
s.add_development_dependency 'sinatra-contrib', '>= 1.0'
s.add_development_dependency 'test-unit', '~> 3.0.9'
s.add_development_dependency 'rack-test', '~> 0.7.0'

s.authors = ["Serg Podtynnyi"]
s.email = "[email protected]"
Expand Down
12 changes: 6 additions & 6 deletions spec/jsonp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@

it "returns JSON if no callback passed" do
get '/method'
body.should == '["hello","hi","hallo"]'
expect(body).to eq '["hello","hi","hallo"]'
end
it "returns JSONP if callback passed via request params" do
get '/method?callback=functionA'
body.should == 'functionA(["hello","hi","hallo"])'
expect(body).to eq 'functionA(["hello","hi","hallo"])'
end

it "returns JSONP with sanitized callback" do
get '/method', { :callback=>'foo<script>alert(1)</script>' }
body.should == 'fooscriptalert1script(["hello","hi","hallo"])'
expect(body).to eq 'fooscriptalert1script(["hello","hi","hallo"])'
end

it "returns JSONP if callback passed via method param" do
get '/method_with_params'
body.should == 'functionA(["hello","hi","hallo"])'
expect(body).to eq 'functionA(["hello","hi","hallo"])'
end
it "returns JSONP with callback passed via method params even if it passed via request param" do
get '/method_with_params?callback=functionB'
body.should == 'functionA(["hello","hi","hallo"])'
expect(body).to eq 'functionA(["hello","hi","hallo"])'
end

it "return pretty JSON if :json_pretty enabled" do
Expand All @@ -50,6 +50,6 @@
end
end
get '/method'
body.should == "[\n \"hello\",\n \"hi\",\n \"hallo\"\n]"
expect(body).to eq "[\n \"hello\",\n \"hi\",\n \"hallo\"\n]"
end
end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'sinatra/jsonp'

RSpec.configure do |config|
config.expect_with :rspec, :stdlib
config.expect_with :rspec
config.include Sinatra::TestHelpers
end

Expand Down