Skip to content

Commit

Permalink
Support rack 2.
Browse files Browse the repository at this point in the history
* Prepare test environment for both rack 1 and rack 2 on Travis.
  * Update .travis.yml.
    * Add "bundle list" in script section to check rack's version
      from Travis log page.
  * Update Gemfile for rack 2 test, and
    add gemfiles/Gemfile.rack-1 for rack 1 test.
    * Keep codeclimate-test-reporter version < 1.
      To supress deprecated warning temporary.
      Later update it to latest version.
    * Add gems to Gemfile for Thorfile.
    * Specify sinatra 2.0.0.rc2 version for rack 2 test.
  * Delete Gemfile.lock
* Fix test suite for Rack 2.x compatiblity.
  • Loading branch information
junaruga committed Apr 26, 2017
1 parent ac30234 commit 7a9148a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 62 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
pkg
doc
coverage
Gemfile.lock
/gemfiles/*.lock
/gemfiles/.bundle
/Gemfile.lock
VERSION
*.rbc
.bundle
*.swp
/.bundle
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ language: ruby
sudo: false
before_install:
- which bundle || gem install bundler
script:
- bundle list
- bundle exec rake
rvm:
- 2.2.7
- 2.3.4
- 2.4.1
- ruby-head
- jruby-9.1.8.0
- jruby-head
gemfile:
- Gemfile
- gemfiles/Gemfile.rack-1
matrix:
allow_failures:
- rvm: ruby-head
Expand Down
15 changes: 11 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
source 'https://rubygems.org'

gem 'rspec'
gem "rack"
gem "sinatra"
gemspec

# Development dependency
gem 'rake'
gem 'rspec'
# To use rack 2
gem 'sinatra', '~> 2.0.0.rc2'
# Keep version < 1 to supress deprecated warning temporary.
gem 'codeclimate-test-reporter', '< 1', :require => false

gem "codeclimate-test-reporter", group: :test, require: nil
# For Thorfile. Run "bundle exec thor help" to see the help.
gem 'thor'
gem 'git'
49 changes: 0 additions & 49 deletions Gemfile.lock

This file was deleted.

13 changes: 13 additions & 0 deletions gemfiles/Gemfile.rack-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source 'https://rubygems.org'

gemspec :path => '..'

# Runtime dependency
gem 'rack', '< 2'

# Development dependency
gem 'rake'
gem 'rspec'
gem 'sinatra'
# Keep version < 1 to supress deprecated warning temporary.
gem 'codeclimate-test-reporter', '< 1', :require => false
14 changes: 7 additions & 7 deletions spec/rack/test/utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
:input => StringIO.new(data)
}
env = Rack::MockRequest.env_for("/", options)
params = Rack::Utils::Multipart.parse_multipart(env)
params = Rack::Multipart.parse_multipart(env)
check expect(params["submit-name"]).to eq("Larry")
check expect(params["files"][:filename]).to eq("foo.txt")
expect(params["files"][:tempfile].read).to eq("bar\n")
Expand All @@ -82,7 +82,7 @@
:input => StringIO.new(data)
}
env = Rack::MockRequest.env_for("/", options)
params = Rack::Utils::Multipart.parse_multipart(env)
params = Rack::Multipart.parse_multipart(env)
check expect(params["submit-name"]).to eq("Larry")

check expect(params["files"][0][:filename]).to eq("foo.txt")
Expand All @@ -102,7 +102,7 @@
:input => StringIO.new(data)
}
env = Rack::MockRequest.env_for("/", options)
params = Rack::Utils::Multipart.parse_multipart(env)
params = Rack::Multipart.parse_multipart(env)
check expect(params["people"][0]["submit-name"]).to eq("Larry")
check expect(params["people"][0]["files"][:filename]).to eq("foo.txt")
expect(params["people"][0]["files"][:tempfile].read).to eq("bar\n")
Expand All @@ -119,7 +119,7 @@
:input => StringIO.new(data)
}
env = Rack::MockRequest.env_for("/", options)
params = Rack::Utils::Multipart.parse_multipart(env)
params = Rack::Multipart.parse_multipart(env)
check expect(params["files"][:filename]).to eq("foo.txt")
expect(params["files"][:tempfile].read).to eq("bar\n")
check expect(params["foo"]).to eq([{"id" => "1", "name" => "Dave"}, {"id" => "2", "name" => "Steve"}])
Expand All @@ -137,7 +137,7 @@
:input => StringIO.new(data)
}
env = Rack::MockRequest.env_for("/", options)
params = Rack::Utils::Multipart.parse_multipart(env)
params = Rack::Multipart.parse_multipart(env)
check expect(params["files"][:filename]).to eq("foo.txt")
expect(params["files"][:tempfile].read).to eq("bar\n")
check expect(params["foo"]).to eq({"bar" => [{"id" => "1", "name" => "Dave"},
Expand All @@ -155,7 +155,7 @@
:input => StringIO.new(data)
}
env = Rack::MockRequest.env_for("/", options)
params = Rack::Utils::Multipart.parse_multipart(env)
params = Rack::Multipart.parse_multipart(env)
check expect(params["files"][0][:filename]).to eq("foo.txt")
expect(params["files"][0][:tempfile].read).to eq("bar\n")
check expect(params["foo"][0]).to eq("1")
Expand All @@ -173,7 +173,7 @@
:input => StringIO.new(data)
}
env = Rack::MockRequest.env_for("/", options)
params = Rack::Utils::Multipart.parse_multipart(env)
params = Rack::Multipart.parse_multipart(env)
check expect(params["foo"][0]["id"]).to eq("1")
check expect(params["foo"][0]["data"][:filename]).to eq("foo.txt")
expect(params["foo"][0]["data"][:tempfile].read).to eq("bar\n")
Expand Down

0 comments on commit 7a9148a

Please sign in to comment.