pry-rails 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +14 -6
- data/lib/pry-rails/commands/recognize_path.rb +34 -0
- data/lib/pry-rails/version.rb +1 -1
- data/spec/recognize_path_spec.rb +51 -0
- data/spec/show_models_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- metadata +27 -25
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDU0YWU5MTYxNTVmOWQwNGI5YmI3MzdjYmVhYzgyMDM1NzA4Mzc3NA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YjJhMmIzNDFjZTkzNWMzNTMwNzNjMzAwZDQ0ZjkzOTA2YWEzYzdhZQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTQzODNkMzFhMjUwZTJiMTk1Nzk3MDJiMjRlNzM3MWI3ODM3YTVlZDUzODNi
|
10
|
+
ZTc1NTExOTU4OGIxYzk2OWM2NGEyMzhhNGVkZTY2NjU2ZTExNzIwZTA1OWEw
|
11
|
+
M2E2M2U2NzI4MzhiMjA2ZGU2M2Q0NjU2YTA3MmNmNmM3MmJiOTg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YjUyMmExZDYxYzQzOGZiY2FkYTFhZTFhN2FmYmJhYjliZjk3Mjc2MDAwOTY0
|
14
|
+
MmE2Y2YyYzBhNjBlN2YxZGEzZjAxNDQ3N2NkNzk5ZjBhYmUyZTU3YTJhZTI0
|
15
|
+
NGNmY2NhZWUzM2ZkMWM0YmQ1NTg0ZTVhMWRiYWFiYTRlMjZlZDU=
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
PryRails::Commands.create_command "recognize-path" do
|
4
|
+
group "Rails"
|
5
|
+
description "Verify that a URL is mapped to the right controller and action"
|
6
|
+
|
7
|
+
def options(opt)
|
8
|
+
opt.banner unindent <<-USAGE
|
9
|
+
Usage: recognize-path PATH [-m|--method METHOD]
|
10
|
+
|
11
|
+
Verifies that a given PATH is mapped to the right controller and action.
|
12
|
+
|
13
|
+
recognize-path example.com
|
14
|
+
recognize-path example.com -m post
|
15
|
+
USAGE
|
16
|
+
|
17
|
+
opt.on :m, :method, "Methods", :argument => true
|
18
|
+
end
|
19
|
+
|
20
|
+
def process
|
21
|
+
method = (opts.m? ? opts[:m] : :get)
|
22
|
+
routes = Rails.application.routes
|
23
|
+
|
24
|
+
begin
|
25
|
+
info = routes.recognize_path("http://#{args.first}", :method => method)
|
26
|
+
rescue ActionController::UnknownHttpMethod
|
27
|
+
output.puts "Unknown HTTP method: #{method}"
|
28
|
+
rescue ActionController::RoutingError => e
|
29
|
+
output.puts e
|
30
|
+
end
|
31
|
+
|
32
|
+
output.puts Pry::Helpers::BaseHelpers.colorize_code(info)
|
33
|
+
end
|
34
|
+
end
|
data/lib/pry-rails/version.rb
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "recognize-path" do
|
6
|
+
before do
|
7
|
+
FooController = Class.new(ActionController::Base)
|
8
|
+
BoomsController = Class.new(ActionController::Base)
|
9
|
+
routes = Rails.application.routes
|
10
|
+
routes.draw {
|
11
|
+
root(:to => 'foo#index', :constraints => {:host => 'example.com'})
|
12
|
+
resources :booms
|
13
|
+
}
|
14
|
+
routes.finalize!
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
[:FooController, :BoomsController].each { |const|
|
19
|
+
Object.__send__(:remove_const, const)
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
it "prints info about controller/action that is bound to the given path" do
|
24
|
+
output = mock_pry('recognize-path example.com', 'exit-all')
|
25
|
+
output.must_match /controller.+foo/
|
26
|
+
output.must_match /action.+index/
|
27
|
+
end
|
28
|
+
|
29
|
+
it "accepts short path" do
|
30
|
+
output = mock_pry('recognize-path /booms/1/edit', 'exit-all')
|
31
|
+
output.must_match /action.+edit/
|
32
|
+
output.must_match /controller.+booms/
|
33
|
+
output.must_match /id.+1/
|
34
|
+
end
|
35
|
+
|
36
|
+
it "accepts -m switch" do
|
37
|
+
output = mock_pry('recognize-path example.com/booms -m post', 'exit-all')
|
38
|
+
output.must_match /controller.+booms/
|
39
|
+
output.must_match /action.+create/
|
40
|
+
end
|
41
|
+
|
42
|
+
it "doesn't accept unknown methods" do
|
43
|
+
output = mock_pry('recognize-path example.com/booms -m posty', 'exit-all')
|
44
|
+
output.must_match 'Unknown HTTP method: posty'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "doesn't accept unknown routes" do
|
48
|
+
output = mock_pry('recognize-path bing/bang/bong', 'exit-all')
|
49
|
+
output.must_match 'No route matches "http://bing/bang/bong"'
|
50
|
+
end
|
51
|
+
end
|
data/spec/show_models_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,71 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Wenglewski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
prerelease: false
|
14
15
|
name: pry
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ! '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.9.10
|
15
21
|
requirement: !ruby/object:Gem::Requirement
|
16
22
|
requirements:
|
17
|
-
- - '>='
|
23
|
+
- - ! '>='
|
18
24
|
- !ruby/object:Gem::Version
|
19
25
|
version: 0.9.10
|
20
26
|
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
21
28
|
prerelease: false
|
29
|
+
name: appraisal
|
22
30
|
version_requirements: !ruby/object:Gem::Requirement
|
23
31
|
requirements:
|
24
|
-
- - '>='
|
32
|
+
- - ! '>='
|
25
33
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: appraisal
|
34
|
+
version: '0'
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - '>='
|
37
|
+
- - ! '>='
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '0'
|
34
40
|
type: :development
|
41
|
+
- !ruby/object:Gem::Dependency
|
35
42
|
prerelease: false
|
43
|
+
name: minitest
|
36
44
|
version_requirements: !ruby/object:Gem::Requirement
|
37
45
|
requirements:
|
38
|
-
- - '>='
|
46
|
+
- - ! '>='
|
39
47
|
- !ruby/object:Gem::Version
|
40
48
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - '>='
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
48
54
|
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
49
56
|
prerelease: false
|
57
|
+
name: rr
|
50
58
|
version_requirements: !ruby/object:Gem::Requirement
|
51
59
|
requirements:
|
52
|
-
- - '>='
|
60
|
+
- - ! '>='
|
53
61
|
- !ruby/object:Gem::Version
|
54
62
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rr
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- - '>='
|
65
|
+
- - ! '>='
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: '0'
|
62
68
|
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
- robin@wenglewski.de
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- Readme.md
|
83
83
|
- lib/pry-rails.rb
|
84
84
|
- lib/pry-rails/commands.rb
|
85
|
+
- lib/pry-rails/commands/recognize_path.rb
|
85
86
|
- lib/pry-rails/commands/show_middleware.rb
|
86
87
|
- lib/pry-rails/commands/show_models.rb
|
87
88
|
- lib/pry-rails/commands/show_routes.rb
|
@@ -94,6 +95,7 @@ files:
|
|
94
95
|
- spec/config/environment.rb
|
95
96
|
- spec/config/routes.rb
|
96
97
|
- spec/railtie_spec.rb
|
98
|
+
- spec/recognize_path_spec.rb
|
97
99
|
- spec/show_middleware_spec.rb
|
98
100
|
- spec/show_models_spec.rb
|
99
101
|
- spec/show_routes_spec.rb
|
@@ -108,12 +110,12 @@ require_paths:
|
|
108
110
|
- lib
|
109
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
112
|
requirements:
|
111
|
-
- - '>='
|
113
|
+
- - ! '>='
|
112
114
|
- !ruby/object:Gem::Version
|
113
115
|
version: '0'
|
114
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
117
|
requirements:
|
116
|
-
- - '>='
|
118
|
+
- - ! '>='
|
117
119
|
- !ruby/object:Gem::Version
|
118
120
|
version: '0'
|
119
121
|
requirements: []
|
@@ -128,8 +130,8 @@ test_files:
|
|
128
130
|
- spec/config/environment.rb
|
129
131
|
- spec/config/routes.rb
|
130
132
|
- spec/railtie_spec.rb
|
133
|
+
- spec/recognize_path_spec.rb
|
131
134
|
- spec/show_middleware_spec.rb
|
132
135
|
- spec/show_models_spec.rb
|
133
136
|
- spec/show_routes_spec.rb
|
134
137
|
- spec/spec_helper.rb
|
135
|
-
has_rdoc:
|