Skip to content

Instantly share code, notes, and snippets.

@mikesten
Created May 13, 2010 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikesten/399738 to your computer and use it in GitHub Desktop.
Save mikesten/399738 to your computer and use it in GitHub Desktop.
require "rubygems"
gem "sinatra", "=1.0"
require "sinatra/base"
class App < Sinatra::Base
get "/direct" do
params.inspect
end
end
require 'app'
run App
Browsing to http://localhost:3333/direct?box[]=1&box[]=2
{"box"=>["1", "2"]}
> spec test.rb
1) 'requesting a url with [] params should include the contents of the params array' FAILED
expected "{\"box\"=>[\"1\", \"2\"]}"
got "{\"box\"=>[nil, nil]}"
require 'rubygems'
require 'rack/test'
require 'app'
Spec::Runner.configure do |config|
config.include Rack::Test::Methods
end
def app
@app ||= App
end
describe "requesting a url with [] params" do
it "should include the contents of the params array" do
get "/direct?box[]=1&box[]=2"
last_response.body.should eql('{"box"=>["1", "2"]}')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment