fluoride-analyzer 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fluoride-analyzer/group-collapser.rb +2 -1
- data/lib/fluoride-analyzer/group-context.rb +8 -2
- data/lib/fluoride-analyzer/parser.rb +15 -2
- data/lib/fluoride-analyzer/patterner.rb +10 -2
- data/lib/fluoride-analyzer/request-templater.rb +9 -4
- data/lib/fluoride-analyzer/tasklib.rb +1 -1
- data/spec/result-parser.rb +52 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27aad46700d207c15bb61903807aa942698295d5
|
4
|
+
data.tar.gz: 01de20a80c6011090dcc43bcc9ec29b0a42d628f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a1e63ea059d32e68d735b242d44e2d21e80ee4e56791ce69c34231eb5996430a0c915bed12f89f4c85000a7cf93baf27cbcf333b0348d7855f0f56f4c54bfbe
|
7
|
+
data.tar.gz: ed9f524f94a23abfe1e87488bda04425332d04de0c0f914fb7ab18d1ba2dbe1f4ce1017e4b8c7895c890b2084cae48d2bce20258dabbb4eca9274e751cd6f5de
|
@@ -44,7 +44,8 @@ module Fluoride::Analyzer
|
|
44
44
|
end
|
45
45
|
|
46
46
|
reduced_hash.each do |(path, query_params), requests|
|
47
|
-
|
47
|
+
next if status == 304
|
48
|
+
yield GroupContext.new(method, status, requests, path, query_params)
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
@@ -48,12 +48,18 @@ module Fluoride::Analyzer
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def redirect_path
|
51
|
-
request['redirect_location'].
|
51
|
+
if request['redirect_location'].nil?
|
52
|
+
pp request
|
53
|
+
pp response
|
54
|
+
exit
|
55
|
+
else
|
56
|
+
request['redirect_location'].sub(%r[^https?://#{request['host']}], '')
|
57
|
+
end
|
52
58
|
end
|
53
59
|
|
54
60
|
def test_result
|
55
61
|
case @status_code.to_i
|
56
|
-
when 300..399
|
62
|
+
when 300..303,305..399
|
57
63
|
["response.should redirect_to(\"#{redirect_path}\")"]
|
58
64
|
else
|
59
65
|
["response.should be_success", "response.status.should == 200"]
|
@@ -98,6 +98,18 @@ module Fluoride::Analyzer
|
|
98
98
|
def patterner
|
99
99
|
@patterner ||= Patterner.for(Rails.application.routes)
|
100
100
|
end
|
101
|
+
attr_writer :patterner
|
102
|
+
|
103
|
+
def warnings
|
104
|
+
@warnings ||= Hash.new do |h,k|
|
105
|
+
warn k
|
106
|
+
h[k] = true
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def warning(message)
|
111
|
+
warnings[message]
|
112
|
+
end
|
101
113
|
|
102
114
|
def collect_record(file, record, index)
|
103
115
|
if exclude?(record)
|
@@ -124,11 +136,12 @@ module Fluoride::Analyzer
|
|
124
136
|
|
125
137
|
if pattern.path_spec == :unrecognized
|
126
138
|
@counts[:no_matching_route] += 1
|
127
|
-
|
139
|
+
warning "Unrecognized route: #{record['request']['method']} #{record['request']['path'].inspect}"
|
140
|
+
return
|
128
141
|
else
|
129
142
|
route_path = pattern.path_spec
|
130
143
|
path_params = Hash[pattern.segment_keys.map do |key|
|
131
|
-
[key, params[key]]
|
144
|
+
[key, pattern.params[key]]
|
132
145
|
end]
|
133
146
|
end
|
134
147
|
|
@@ -31,7 +31,7 @@ module Fluoride::Analyzer
|
|
31
31
|
end
|
32
32
|
attr_reader :rails_routes
|
33
33
|
|
34
|
-
def build_request(
|
34
|
+
def build_request(request_env)
|
35
35
|
ActionDispatch::Request.new(base_env.merge(request_env))
|
36
36
|
end
|
37
37
|
|
@@ -85,6 +85,7 @@ module Fluoride::Analyzer
|
|
85
85
|
|
86
86
|
def build(env)
|
87
87
|
req = build_request(env)
|
88
|
+
|
88
89
|
pattern = nil
|
89
90
|
route_set.recognize(req) do |route, matches, params|
|
90
91
|
rails_route = route_map[route]
|
@@ -97,7 +98,14 @@ module Fluoride::Analyzer
|
|
97
98
|
path_spec = rails_route.path.spec.to_s
|
98
99
|
segment_keys = rails_route.segment_keys
|
99
100
|
end
|
100
|
-
|
101
|
+
# require 'pp'
|
102
|
+
# puts "\n#{__FILE__}:#{__LINE__} => #{{
|
103
|
+
# :req => req, :route => route, :matches => matches, :params => params,
|
104
|
+
# :rails_route => rails_route,
|
105
|
+
# :path_spec => path_spec,
|
106
|
+
# :segment_keys => segment_keys
|
107
|
+
# }.pretty_inspect}"
|
108
|
+
#
|
101
109
|
pattern = RoutePattern.new(route, matches, params, path_spec, segment_keys)
|
102
110
|
end
|
103
111
|
if pattern.nil?
|
@@ -13,13 +13,18 @@ module Fluoride::Analyzer
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def go
|
16
|
+
require 'pp'
|
16
17
|
results.each_pair do |pattern, statuses|
|
17
|
-
|
18
|
+
if pattern.nil?
|
19
|
+
pp statuses
|
20
|
+
else
|
21
|
+
context = PatternContext.new(pattern, statuses)
|
18
22
|
|
19
|
-
|
20
|
-
|
23
|
+
path = File.join(context.filename)
|
24
|
+
contents = template.result(context.context_binding)
|
21
25
|
|
22
|
-
|
26
|
+
yield(path, contents)
|
27
|
+
end
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
data/spec/result-parser.rb
CHANGED
@@ -107,4 +107,56 @@ describe Fluoride::Analyzer::Parser do
|
|
107
107
|
it "should be a well formatted version of the results" do
|
108
108
|
expect(results).to match("/" => {"GET" => {200 => match([ a_hash_including("path" => "/") ])}})
|
109
109
|
end
|
110
|
+
|
111
|
+
xdescribe "for Rails3" do
|
112
|
+
let :route_set do
|
113
|
+
double("Rails Route set")
|
114
|
+
end
|
115
|
+
|
116
|
+
let :route do
|
117
|
+
double("Rails route")
|
118
|
+
end
|
119
|
+
|
120
|
+
let :matches do
|
121
|
+
double("match list")
|
122
|
+
end
|
123
|
+
|
124
|
+
let :params do
|
125
|
+
double("route params")
|
126
|
+
end
|
127
|
+
|
128
|
+
let :routes do
|
129
|
+
double("Rails routes").tap do |routes|
|
130
|
+
allow(routes).to receive(:set).and_return(route_set)
|
131
|
+
allow(routes).to receive(:recognize).and_return([[route, matches, params]]).any_number_of_times
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
let :patterner do
|
136
|
+
Fluoride::Analyzer::Patterner::Rails3.new(routes)
|
137
|
+
end
|
138
|
+
|
139
|
+
let :parser do
|
140
|
+
Fluoride::Analyzer::Parser.new.tap do |parser|
|
141
|
+
parser.patterner = patterner
|
142
|
+
parser.parse_stream("test-file.yaml", requests_stream)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should have a Rails3 patterner" do
|
147
|
+
expect(parser.patterner.class.name).to match(/Rails3/)
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should have excluded 1 request" do
|
151
|
+
expect(parser.counts[:excluded]).to eq(1)
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should have 0 unrecognized requests" do
|
155
|
+
expect(parser.counts[:unrecognized]).to eq(0)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should be a well formatted version of the results" do
|
159
|
+
expect(results).to match("/" => {"GET" => {200 => match([ a_hash_including("path" => "/") ])}})
|
160
|
+
end
|
161
|
+
end
|
110
162
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluoride-analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Judson Lester
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-01-
|
13
|
+
date: 2015-01-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mattock
|
@@ -82,7 +82,7 @@ rdoc_options:
|
|
82
82
|
- --main
|
83
83
|
- doc/README
|
84
84
|
- --title
|
85
|
-
- fluoride-analyzer-0.0.
|
85
|
+
- fluoride-analyzer-0.0.8 Documentation
|
86
86
|
require_paths:
|
87
87
|
- lib/
|
88
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|