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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1637ac26ca7cc98d39f42c0fc3efd8c4ca4929ed
4
- data.tar.gz: fae4b689619bb34b1216d27c9fa6b5c4c811acdd
3
+ metadata.gz: 27aad46700d207c15bb61903807aa942698295d5
4
+ data.tar.gz: 01de20a80c6011090dcc43bcc9ec29b0a42d628f
5
5
  SHA512:
6
- metadata.gz: 226647f9f585b51ce79feefe029c0b00da5b26b1014d6b80d3c31e114c9b7f11fd2804b22c6c497371592b47c9012a73b1b733cc4567e9cbfd0258a4520d382b
7
- data.tar.gz: b40af17fbba3a67c0218ac27487ed80982e39c2965e7c8d345713f3ef4c194a1e272b3c680951d29f64b9de82b52f3612003d3cc07bcfcda0833d3a479aac0b3
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
- yield GroupContext.new(method, status, requests, path, query_params)
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'].sub(%r[^https?://#{request['host']}], '')
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
- warn "Unrecognized route: #{record['request']['path'].inspect}"
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(result_env)
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
- context = PatternContext.new(pattern, statuses)
18
+ if pattern.nil?
19
+ pp statuses
20
+ else
21
+ context = PatternContext.new(pattern, statuses)
18
22
 
19
- path = File.join(context.filename)
20
- contents = template.result(context.context_binding)
23
+ path = File.join(context.filename)
24
+ contents = template.result(context.context_binding)
21
25
 
22
- yield(path, contents)
26
+ yield(path, contents)
27
+ end
23
28
  end
24
29
  end
25
30
  end
@@ -38,7 +38,7 @@ module Fluoride::Analyzer
38
38
 
39
39
  recordings_list.find_all do |prereq|
40
40
  next unless File.file?(prereq) && __FILE__ != prereq
41
- parser.parse_stream(File.read(prereq))
41
+ parser.parse_stream(prereq, File.read(prereq))
42
42
  end
43
43
 
44
44
  parser.limit = limit
@@ -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.7
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-14 00:00:00.000000000 Z
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.7 Documentation
85
+ - fluoride-analyzer-0.0.8 Documentation
86
86
  require_paths:
87
87
  - lib/
88
88
  required_ruby_version: !ruby/object:Gem::Requirement