fozzie 0.0.27 → 1.0.0
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.
- data/.gitignore +2 -1
- data/Guardfile +2 -2
- data/README.md +22 -11
- data/Rakefile +1 -1
- data/fozzie.gemspec +8 -14
- data/lib/core_ext/module/monitor.rb +4 -3
- data/lib/fozzie.rb +6 -7
- data/lib/fozzie/adapter.rb +1 -0
- data/lib/fozzie/adapter/statsd.rb +86 -0
- data/lib/fozzie/bulk_dsl.rb +28 -0
- data/lib/fozzie/configuration.rb +32 -13
- data/lib/fozzie/dsl.rb +19 -0
- data/lib/fozzie/exception.rb +5 -0
- data/lib/fozzie/interface.rb +30 -15
- data/lib/fozzie/rack/middleware.rb +3 -1
- data/lib/fozzie/sniff.rb +28 -33
- data/lib/fozzie/version.rb +1 -1
- data/spec/config/fozzie.yml +2 -1
- data/spec/lib/core_ext/module/monitor_spec.rb +9 -0
- data/spec/lib/fozzie/adapter/statsd_spec.rb +82 -0
- data/spec/lib/fozzie/bulk_dsl_spec.rb +47 -0
- data/spec/lib/fozzie/configuration_spec.rb +34 -20
- data/spec/lib/fozzie/dsl_spec.rb +16 -0
- data/spec/lib/fozzie/rack/middleware_spec.rb +6 -36
- data/spec/lib/fozzie/rack/sinatra_spec.rb +31 -0
- data/spec/lib/fozzie/sniff_spec.rb +37 -37
- data/spec/lib/fozzie/version_spec.rb +1 -1
- data/spec/lib/fozzie_spec.rb +19 -3
- data/spec/shared_examples/fozzie_adapter.rb +7 -0
- data/spec/shared_examples/interface.rb +160 -0
- data/spec/spec_helper.rb +20 -10
- metadata +31 -74
- data/lib/core_ext/hash.rb +0 -16
- data/lib/fozzie/mill.rb +0 -50
- data/lib/fozzie/rails/engine.rb +0 -15
- data/lib/fozzie/rails/middleware.rb +0 -39
- data/lib/fozzie/railtie.rb +0 -15
- data/lib/fozzie/socket.rb +0 -53
- data/spec/lib/core_ext/hash_spec.rb +0 -33
- data/spec/lib/fozzie/interface_spec.rb +0 -180
- data/spec/lib/fozzie/mill_spec.rb +0 -43
- data/spec/lib/fozzie/rails/middleware_spec.rb +0 -125
@@ -1,125 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'action_controller'
|
3
|
-
|
4
|
-
describe Fozzie::Rails::Middleware do
|
5
|
-
let(:routes) { mock "routes" }
|
6
|
-
|
7
|
-
subject do
|
8
|
-
RailsApp = Class.new do
|
9
|
-
def call(env); env end
|
10
|
-
end unless defined?(RailsApp)
|
11
|
-
Fozzie::Rails::Middleware.new RailsApp.new
|
12
|
-
end
|
13
|
-
|
14
|
-
before do
|
15
|
-
Rails = rails unless defined?(Rails)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#rails_version" do
|
19
|
-
let(:version) { "10.9.8" }
|
20
|
-
let(:rails) { mock "rails" }
|
21
|
-
|
22
|
-
before do
|
23
|
-
::Rails.stubs(:version).returns(version)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "returns the major version from Rails.version" do
|
27
|
-
subject.rails_version.should == 10
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#routing_lookup" do
|
32
|
-
context "when #rails_version == 3" do
|
33
|
-
let(:app) { mock "app" }
|
34
|
-
|
35
|
-
before do
|
36
|
-
subject.stubs(:rails_version).returns(3)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "returns Rails.application.routes" do
|
40
|
-
Rails.expects(:application).returns(app)
|
41
|
-
app.expects(:routes).returns(routes)
|
42
|
-
subject.routing_lookup.should eq routes
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "when #rails_version does not == 3" do
|
47
|
-
before do
|
48
|
-
if defined?(ActionController::Routing::Routes)
|
49
|
-
|
50
|
-
@old_routes_const = ActionController::Routing::Routes
|
51
|
-
ActionController::Routing.send(:remove_const, :Routes)
|
52
|
-
end
|
53
|
-
ActionController::Routing::Routes = routes
|
54
|
-
end
|
55
|
-
|
56
|
-
after do
|
57
|
-
if @old_routes_const
|
58
|
-
ActionController::Routing.send(:remove_const, :Routes)
|
59
|
-
ActionController::Routing::Routes = @old_routes_const
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
it "returns ActionController::Routing::Routes" do
|
64
|
-
subject.routing_lookup.should eq routes
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "#generate_key" do
|
70
|
-
let(:env) { mock "env" }
|
71
|
-
let(:path) { mock "path" }
|
72
|
-
let(:request_method) { mock "request_method" }
|
73
|
-
|
74
|
-
it "gets the path_info and request method from env parameter" do
|
75
|
-
env.expects(:[]).with("PATH_INFO")
|
76
|
-
env.expects(:[]).with("REQUEST_METHOD")
|
77
|
-
subject.generate_key(env)
|
78
|
-
end
|
79
|
-
|
80
|
-
context "when path_info is nil" do
|
81
|
-
let(:env) { { "PATH_INFO" => nil } }
|
82
|
-
|
83
|
-
it "does not lookup routing" do
|
84
|
-
subject.expects(:routing_lookup).never
|
85
|
-
subject.generate_key(env)
|
86
|
-
end
|
87
|
-
|
88
|
-
it "does not register any stats" do
|
89
|
-
S.expects(:increment).never
|
90
|
-
end
|
91
|
-
|
92
|
-
it "returns nil" do
|
93
|
-
subject.generate_key(env).should be_nil
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context "when path info is not nil" do
|
98
|
-
let(:env) { { "PATH_INFO" => path, "REQUEST_METHOD" => request_method } }
|
99
|
-
|
100
|
-
before do
|
101
|
-
subject.stubs(:routing_lookup).returns(routes)
|
102
|
-
routes.stubs(:recognize_path).returns({ :controller => "controller",
|
103
|
-
:action => "action" })
|
104
|
-
end
|
105
|
-
|
106
|
-
it "looks up controller and action for the path and request method" do
|
107
|
-
subject.expects(:routing_lookup).returns(routes)
|
108
|
-
routes.expects(:recognize_path).with(path, :method => request_method)
|
109
|
-
subject.generate_key(env)
|
110
|
-
end
|
111
|
-
|
112
|
-
it "returns a bucket generated from the controller, action, and 'render'" do
|
113
|
-
subject.generate_key(env).should eq "controller.action.render"
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
|
-
describe "subject" do
|
120
|
-
it "returns env on call for testing" do
|
121
|
-
subject.call({}).should == {}
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|