deelay 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,3 +3,8 @@ source "http://rubygems.org"
3
3
  # Specify your gem's dependencies in deelay.gemspec
4
4
  gemspec
5
5
  gem 'sinatra', "~>1.3.3"
6
+
7
+ group :test do
8
+ gem "rack-test"
9
+ gem "rspec"
10
+ end
@@ -6,7 +6,7 @@ class DeelayApp < Sinatra::Base
6
6
 
7
7
  get '/:delay' do
8
8
  delay = params[:delay].to_i
9
- url = request.query_string
9
+ url = URI.unescape(request.query_string)
10
10
 
11
11
  raise "Invalid URL" if (URI::regexp =~ url).nil?
12
12
 
@@ -14,7 +14,7 @@ class DeelayApp < Sinatra::Base
14
14
  redirect url
15
15
  end
16
16
 
17
- error 400..510 do
17
+ error do
18
18
  redirect "#{Deelay::HOMEPAGE}/error"
19
19
  end
20
20
 
@@ -1,3 +1,3 @@
1
1
  module Deelay
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -0,0 +1,44 @@
1
+ require_relative '../lib/deelay'
2
+ require 'rspec'
3
+ require 'rack/test'
4
+
5
+ Sinatra::Base.set :environment, :test
6
+
7
+ describe "DeelayApp" do
8
+ include Rack::Test::Methods
9
+
10
+ def app
11
+ Deelay::DeelayApp
12
+ end
13
+
14
+ context "when url invalid" do
15
+ it "raise error if protocol missing" do
16
+ expect {
17
+ get "/10?testurl.com"
18
+ }.to raise_error
19
+ end
20
+
21
+ it "raise error if protocol missing" do
22
+ expect {
23
+ get "/10?/testurl.com"
24
+ }.to raise_error
25
+ end
26
+ end
27
+
28
+ context "when url valid" do
29
+ it "redirects request with port" do
30
+ get "/10?http://testurl.com:1234"
31
+ last_response.status.should == 302
32
+ end
33
+
34
+ it "redirects request without port" do
35
+ get "/10?http://testurl.com"
36
+ last_response.status.should == 302
37
+ end
38
+
39
+ it "redirects to specified url" do
40
+ get "/10?http://testurl.com"
41
+ last_response.location.should == "http://testurl.com"
42
+ end
43
+ end
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deelay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-12 00:00:00.000000000 Z
12
+ date: 2012-10-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70276693922480 !ruby/object:Gem::Requirement
16
+ requirement: &70224697153080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70276693922480
24
+ version_requirements: *70224697153080
25
25
  description: Delay proxy for http resources
26
26
  email:
27
27
  - gbiesiadecki@gmail.com
@@ -39,6 +39,7 @@ files:
39
39
  - lib/deelay/deelay_app.rb
40
40
  - lib/deelay/homepage.rb
41
41
  - lib/deelay/version.rb
42
+ - spec/deelay_app_spec.rb
42
43
  homepage: http://deelay.me
43
44
  licenses: []
44
45
  post_install_message:
@@ -53,7 +54,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
54
  version: '0'
54
55
  segments:
55
56
  - 0
56
- hash: 3090091788259642483
57
+ hash: 4605244274232536069
57
58
  required_rubygems_version: !ruby/object:Gem::Requirement
58
59
  none: false
59
60
  requirements:
@@ -62,11 +63,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
63
  version: '0'
63
64
  segments:
64
65
  - 0
65
- hash: 3090091788259642483
66
+ hash: 4605244274232536069
66
67
  requirements: []
67
68
  rubyforge_project: deelay
68
69
  rubygems_version: 1.8.15
69
70
  signing_key:
70
71
  specification_version: 3
71
72
  summary: Delay proxy
72
- test_files: []
73
+ test_files:
74
+ - spec/deelay_app_spec.rb