lackie 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/lackie/rack/logger.rb +14 -0
- data/lib/lackie.rb +1 -1
- data/spec/lackie/rack/logging_spec.rb +53 -0
- metadata +7 -4
data/lib/lackie.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'lackie/rack'
|
3
|
+
|
4
|
+
module Lackie
|
5
|
+
module Rack
|
6
|
+
describe Middleware, "with a logger" do
|
7
|
+
before do
|
8
|
+
Lackie::JavaScript::Surrender.stub!(:new).and_return(mock("surrender", :script => "yowzer"))
|
9
|
+
@app = mock("app")
|
10
|
+
@env = mock("env")
|
11
|
+
@logger = mock("logger", :log => true)
|
12
|
+
@middleware = Middleware.new(@app, @logger)
|
13
|
+
end
|
14
|
+
|
15
|
+
def request(options)
|
16
|
+
@request = mock("Request: #{options.inspect}", options)
|
17
|
+
::Rack::Request.stub!(:new).with(@env).and_return(@request)
|
18
|
+
@middleware.call(@env)
|
19
|
+
end
|
20
|
+
|
21
|
+
def get(path, options)
|
22
|
+
request(options.merge({ :path => path, :get? => true }))
|
23
|
+
end
|
24
|
+
|
25
|
+
def post(path, body)
|
26
|
+
request(:path => path, :get? => false, :body => mock("io", :read => body))
|
27
|
+
end
|
28
|
+
|
29
|
+
it "logs the surrendered user agent" do
|
30
|
+
@logger.should_receive(:log).with("surrendered to some-browser")
|
31
|
+
get("/lackie/surrender", :user_agent => "some-browser")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "logs commands with ids" do
|
35
|
+
@logger.should_receive(:log).with("eval {\"command\":\"foo\",\"id\":1}")
|
36
|
+
post("/lackie/eval", "foo")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "logs results with ids" do
|
40
|
+
post("/lackie/eval", "bar")
|
41
|
+
@logger.should_receive(:log).with("result {\"id\":1,\"value\":\"bar\"}")
|
42
|
+
post("/lackie/result", "{\"id\":1,\"value\":\"bar\"}")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe SimpleLogger do
|
47
|
+
it "logs using Kernel.puts" do
|
48
|
+
Kernel.should_receive(:puts).with("yo").once
|
49
|
+
SimpleLogger.new.log("yo")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lackie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 8
|
10
|
+
version: 0.1.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Josh Chisholm
|
@@ -157,10 +157,12 @@ files:
|
|
157
157
|
- lib/lackie/javascript/surrender.rb
|
158
158
|
- lib/lackie/poller.rb
|
159
159
|
- lib/lackie/rack.rb
|
160
|
+
- lib/lackie/rack/logger.rb
|
160
161
|
- lib/lackie/rack/middleware.rb
|
161
162
|
- lib/lackie/remote_control.rb
|
162
163
|
- spec/lackie/javascript/surrender_spec.rb
|
163
164
|
- spec/lackie/poller_spec.rb
|
165
|
+
- spec/lackie/rack/logging_spec.rb
|
164
166
|
- spec/lackie/rack/middleware_spec.rb
|
165
167
|
- spec/lackie/remote_control_spec.rb
|
166
168
|
- spec/spec_helper.rb
|
@@ -197,7 +199,7 @@ rubyforge_project:
|
|
197
199
|
rubygems_version: 1.4.1
|
198
200
|
signing_key:
|
199
201
|
specification_version: 3
|
200
|
-
summary: lackie-0.1.
|
202
|
+
summary: lackie-0.1.8
|
201
203
|
test_files:
|
202
204
|
- features/remote_control.feature
|
203
205
|
- features/step_definitions/lackie_steps.rb
|
@@ -207,6 +209,7 @@ test_files:
|
|
207
209
|
- features/support/example_app/app.html
|
208
210
|
- spec/lackie/javascript/surrender_spec.rb
|
209
211
|
- spec/lackie/poller_spec.rb
|
212
|
+
- spec/lackie/rack/logging_spec.rb
|
210
213
|
- spec/lackie/rack/middleware_spec.rb
|
211
214
|
- spec/lackie/remote_control_spec.rb
|
212
215
|
- spec/spec_helper.rb
|