Skip to content

Add scheme test, test-unit to development dependencies #75

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions rack-rewrite.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'shoulda', '~> 2.10.2'
s.add_development_dependency 'mocha', '~> 0.9.7'
s.add_development_dependency 'rack'
s.add_development_dependency 'test-unit'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed? how come?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it:

➜  rack-rewrite git:(add-scheme-test) ✗ rake test
/Users/vidmantas/.rvm/rubies/ruby-2.2.3/bin/ruby -I"lib:lib:test:."  "/Users/vidmantas/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_test_loader.rb" "test/**/*_test.rb"
/Users/vidmantas/.rvm/gems/ruby-2.2.3/gems/shoulda-2.10.3/lib/shoulda/test_unit.rb:1:in `require': cannot load such file -- test/unit (LoadError)
<...>


if s.respond_to? :specification_version then
s.specification_version = 3
Expand Down
13 changes: 13 additions & 0 deletions test/rule_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,19 @@ def negative_lookahead_regexp
end
end

context 'SSL redirect with scheme option' do
setup do
@rule = Rack::Rewrite::Rule.new(:r302, %r{.*}, 'https://www.mydomain.com$&', :scheme => 'http')
end

should 'work' do
env = {'PATH_INFO' => '/foo/bar', 'QUERY_STRING' => 'abc=1', 'SERVER_NAME' => 'mydomain.com', "rack.url_scheme" => "http"}
assert @rule.matches?(env)
rack_response = @rule.apply!(env)
assert_equal 'https://www.mydomain.com/foo/bar?abc=1', rack_response[1]['Location']
end
end

context 'Given a lambda matcher' do
setup do
@rule = Rack::Rewrite::Rule.new(:r302, ->{ Thread.current[:test_matcher] }, '/today' )
Expand Down