rspec-padrino 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 716aaff460bc44ec48bb47d15c5e97ccaa6fc434
4
- data.tar.gz: 02efe422e54090291777f64a2071862ccd4e8b50
3
+ metadata.gz: 39274cd9e7510e23434cdb21f3342779a7f0f77c
4
+ data.tar.gz: 34eee1053ea25ce9b5c7581dcdc9a96f3baef386
5
5
  SHA512:
6
- metadata.gz: 9602945e07b00d722d61da60ad54e2bd44426226e346e991ca0fec8bf9f87b495b14de9a795f9c0cd74b95f5a3dee8835348f5cdfd0d3b120d646d3eac3146b6
7
- data.tar.gz: a51db515b0956a75bcfd734b9030c1d2f9259dd2eefafa008070c5f04001ca74e82050adf9d63d9730b31a145d671f4b9ee968ade16f7445e3e6440adb1b5a52
6
+ metadata.gz: cbd22223c7362d386714cab843cc38c3e953f3e67a9cb5b58aa6ab4d12437201a6470fc37f094335b611b6b53a82c98a5d5fdebfaf3b666dca75cc5af00c37ee
7
+ data.tar.gz: 7b9c41da3e753395c460ee678c753a3eb634a33d2ec4db9789c7b8c308ad00abff7e498a82fc0b9477c25fdf97c848d5c7b2dc7495e1a9648d7c4251e69098bd
@@ -2,7 +2,9 @@
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - 2.1.1
5
+ - 2.1
6
+ - 2.2
6
7
  notifications:
7
8
  email:
8
9
  - udzura@udzura.jp
10
+ - namusyaka@gmail.com
@@ -1,18 +1,18 @@
1
- = rspec-padrino
1
+ # rspec-padrino
2
2
 
3
3
  rspec-padrino is a gem including helpers for testing a Padrino app using RSpec. Taking much from rspec-rails.
4
4
 
5
- == Install
5
+ ## Install
6
6
 
7
7
  gem install rspec-padrino
8
8
 
9
- Depends on padrino-core >= 0.10.2, sinatra, rack-test, and RSpec 2.
9
+ Depends on padrino-core <~ 0.12.0, sinatra, rack-test, and RSpec 2.
10
10
 
11
- == Usage
11
+ ## Usage
12
12
 
13
13
  Create a Padrino project with option <tt>-t rspec</tt>. Required files will be generated.
14
14
 
15
- Then edit <tt>spec_helper.rb</tt> like:
15
+ Then edit `spec_helper.rb` like:
16
16
 
17
17
  RSpec.configure do |conf|
18
18
  conf.include Rack::Test::Methods
@@ -25,16 +25,15 @@ Then edit <tt>spec_helper.rb</tt> like:
25
25
  Padrino.application
26
26
  end
27
27
 
28
- more usage on RDoc: [http://rubydoc.info/github/udzura/rspec-padrino/v0.0.1/frames]
28
+ more usage on RDoc: <http://rubydoc.info/github/udzura/rspec-padrino/frames>
29
29
 
30
- == Related Sites
30
+ ## Related Sites
31
31
 
32
- * {rubygems.org}[https://rubygems.org/gems/rspec-padrino]
33
- * {github}[https://github.com/udzura/rspec-padrino]
34
- * {travis-ci}[http://travis-ci.org/udzura/rspec-padrino] {<img src="https://secure.travis-ci.org/udzura/rspec-padrino.png" alt="build status" />}[http://travis-ci.org/udzura/rspec-padrino]
35
- * {author's blog}[http://blog.udzura.jp] # Japanese
32
+ * [rubygems.org](https://rubygems.org/gems/rspec-padrino)
33
+ * [github](https://github.com/udzura/rspec-padrino)
34
+ * [![Build Status](https://travis-ci.org/udzura/rspec-padrino.svg?branch=master)](https://travis-ci.org/udzura/rspec-padrino)
36
35
 
37
- == Contributing to rspec-padrino
36
+ ## Contributing to rspec-padrino
38
37
 
39
38
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
40
39
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
@@ -44,8 +43,7 @@ more usage on RDoc: [http://rubydoc.info/github/udzura/rspec-padrino/v0.0.1/fram
44
43
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
45
44
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
46
45
 
47
- == Copyright
46
+ ## LICENSE
48
47
 
49
- Copyright (c) 2011 Uchio Kondo <udzura@udzura.jp>. See LICENSE.txt for
50
- further details.
48
+ See LICENSE.txt for further details.
51
49
 
@@ -1,8 +1,11 @@
1
1
  module RSpec::Padrino
2
2
  module Matchers
3
3
  require 'rspec/padrino/matchers/routing_matchers'
4
+ require 'rspec/padrino/matchers/redirect_to'
5
+
4
6
  def self.included(base)
5
7
  base.send :include, RSpec::Padrino::Matchers::RoutingMatchers
8
+ base.send :include, RSpec::Padrino::Matchers::RedirectTo
6
9
  end
7
10
  end
8
11
  end
@@ -0,0 +1,31 @@
1
+ module RSpec::Padrino::Matchers
2
+ module RedirectTo
3
+ extend RSpec::Matchers::DSL
4
+ SCHEMA_REGEXP = /\A[A-z][A-z0-9\+\.\-]*:/.freeze
5
+
6
+ matcher :redirect_to do |*expected|
7
+ match do |response|
8
+ @expected_url = make_expected_url(*expected)
9
+ @actual_url = response.location
10
+ response.redirect? && @expected_url == @actual_url
11
+ end
12
+
13
+ def make_expected_url(*args)
14
+ head = args.first
15
+ if args.length == 1 && head.kind_of?(String) && head =~ SCHEMA_REGEXP
16
+ args.shift
17
+ else
18
+ last_application.absolute_url(*expected)
19
+ end
20
+ end
21
+
22
+ failure_message_for_should do |actual|
23
+ "expected #{actual} to be a redirect to #{@expected_url}, got #{@actual_url.inspect}"
24
+ end
25
+
26
+ failure_message_for_should_not do |actual|
27
+ "expected #{actual} not to be a redirect to #{@expected_url}, got #{@actual_url.inspect}"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Padrino
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -63,4 +63,59 @@ describe "Integrations" do
63
63
  {:get => "/foo/errored"}.should be_routable
64
64
  end
65
65
  end
66
+
67
+ describe "redirect_to" do
68
+ subject { last_response }
69
+
70
+ context "with optional style" do
71
+ it "redirects to /baz/show" do
72
+ get "/baz"
73
+ should redirect_to(:baz, :show)
74
+ end
75
+
76
+ it "redirects to /baz/captures/123" do
77
+ get "/baz/redirect_with_captures/123"
78
+ should redirect_to(:baz, :captures, :id => 123)
79
+ end
80
+
81
+ it "should fail if does not redirect" do
82
+ get "/baz/captures/123"
83
+ should_not redirect_to(:baz, :captures, :id => 123)
84
+ end
85
+
86
+ it "should not fail even if only one argument is an instance of non-string" do
87
+ get "/cushion", q: "/one"
88
+ should redirect_to(:one)
89
+ end
90
+ end
91
+
92
+ context "with URI" do
93
+ it "redirects to /baz/show" do
94
+ get "/baz"
95
+ should redirect_to("/baz/show")
96
+ end
97
+
98
+ it "redirects to /baz/captures/123" do
99
+ get "/baz/redirect_with_captures/123"
100
+ should redirect_to("/baz/captures/123")
101
+ end
102
+
103
+ it "should fail if does not redirect" do
104
+ get "/baz/captures/123"
105
+ should_not redirect_to("/baz/captures/123")
106
+ end
107
+ end
108
+
109
+ context "with absolute URI" do
110
+ it "redirects to http://example.com" do
111
+ get "/cushion", :q => "http://example.com"
112
+ should redirect_to("http://example.com")
113
+ end
114
+
115
+ it "redirects to ftp://example.com" do
116
+ get "/cushion", :q => "ftp://example.com"
117
+ should redirect_to("ftp://example.com")
118
+ end
119
+ end
120
+ end
66
121
  end
@@ -36,6 +36,30 @@ class TestApp < Padrino::Application
36
36
  end
37
37
  end
38
38
 
39
+ controllers :baz do
40
+ get :index do
41
+ redirect url(:baz, :show)
42
+ end
43
+
44
+ get :show do
45
+ "show"
46
+ end
47
+
48
+ get :redirect_with_captures, :with => :id do |id|
49
+ redirect url(:baz, :captures, :id => id)
50
+ end
51
+
52
+ get :captures, :with => :id do |id|
53
+ "with #{id}"
54
+ end
55
+ end
56
+
57
+ get(:one){}
58
+
59
+ get :cushion do
60
+ redirect params[:q]
61
+ end
62
+
39
63
  helpers do
40
64
  def foo_index_path
41
65
  url_for(:foo, :index)
metadata CHANGED
@@ -1,153 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-padrino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uchio KONDO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-03 00:00:00.000000000 Z
11
+ date: 2015-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: padrino-core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.12.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.12.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rack-test
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: padrino-helpers
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.12.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.12.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rdoc
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.3'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.3'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: pry
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rake
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  description: rspec-padrino is a gem including helpers for testing a Padrino app using
@@ -158,21 +158,22 @@ executables: []
158
158
  extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
- - .document
162
- - .gitignore
163
- - .rspec
164
- - .travis.yml
161
+ - ".document"
162
+ - ".gitignore"
163
+ - ".rspec"
164
+ - ".travis.yml"
165
165
  - CHANGELOG.md
166
166
  - Gemfile
167
167
  - Gemfile.lock
168
168
  - LICENSE.txt
169
- - README.rdoc
169
+ - README.md
170
170
  - Rakefile
171
171
  - VERSION
172
172
  - lib/rspec-padrino.rb
173
173
  - lib/rspec/padrino.rb
174
174
  - lib/rspec/padrino/initializers/last_application.rb
175
175
  - lib/rspec/padrino/matchers.rb
176
+ - lib/rspec/padrino/matchers/redirect_to.rb
176
177
  - lib/rspec/padrino/matchers/routing_matchers.rb
177
178
  - lib/rspec/padrino/methods.rb
178
179
  - lib/rspec/padrino/version.rb
@@ -194,17 +195,17 @@ require_paths:
194
195
  - lib
195
196
  required_ruby_version: !ruby/object:Gem::Requirement
196
197
  requirements:
197
- - - '>='
198
+ - - ">="
198
199
  - !ruby/object:Gem::Version
199
200
  version: '0'
200
201
  required_rubygems_version: !ruby/object:Gem::Requirement
201
202
  requirements:
202
- - - '>='
203
+ - - ">="
203
204
  - !ruby/object:Gem::Version
204
205
  version: '0'
205
206
  requirements: []
206
207
  rubyforge_project:
207
- rubygems_version: 2.0.14
208
+ rubygems_version: 2.4.5
208
209
  signing_key:
209
210
  specification_version: 4
210
211
  summary: rspec-padrino is a gem including helpers for testing a Padrino app using
@@ -217,3 +218,4 @@ test_files:
217
218
  - spec/rspec/padrino/methods_spec.rb
218
219
  - spec/spec.opts
219
220
  - spec/spec_helper.rb
221
+ has_rdoc: