spec/lib/fozzie/rack/middleware_spec.rb in fozzie-0.0.27 vs spec/lib/fozzie/rack/middleware_spec.rb in fozzie-1.0.0
- old
+ new
@@ -1,14 +1,13 @@
require 'spec_helper'
-require 'sinatra/base'
-require 'rack/test'
+require 'fozzie/rack/middleware'
describe Fozzie::Rack::Middleware do
subject do
unless defined?(RackApp)
- RackApp = Class.new { def call(env); env end }
+ RackApp = Class.new { def call(env); env end }
end
Fozzie::Rack::Middleware.new RackApp.new
end
it { should respond_to(:call) }
@@ -22,34 +21,33 @@
describe "#call" do
it "ignored stats request when path not valid" do
fake_env = { 'PATH_INFO' => '' }
- subject.expects(:call_without_timer).with(fake_env)
+ subject.should_receive(:call_without_timer).with(fake_env)
subject.call(fake_env)
end
it "passes request with timer on index" do
fake_env = { 'PATH_INFO' => '/' }
- subject.expects(:call_with_timer).with('index.render', fake_env)
+ subject.should_receive(:call_with_timer).with('index.render', fake_env)
subject.call(fake_env)
end
it "passes request with timer on full path" do
fake_env = { 'PATH_INFO' => '/somewhere/nice' }
- subject.expects(:call_with_timer).with('somewhere.nice.render', fake_env)
+ subject.should_receive(:call_with_timer).with('somewhere.nice.render', fake_env)
subject.call(fake_env)
end
it "passes request onto app" do
envs = ['', '/', '/somewhere/nice'].each do |p|
fake_env = { 'PATH_INFO' => p }
- subject.app.expects(:call).with(fake_env)
+ subject.app.should_receive(:call).with(fake_env)
subject.call(fake_env)
end
end
-
end
describe "#generate_key" do
it "returns nil when applicable" do
@@ -65,36 +63,8 @@
it "returns dotted value" do
fake_env = { 'PATH_INFO' => '/somewhere/nice' }
subject.generate_key(fake_env).should == 'somewhere.nice.render'
end
- end
-
-end
-
-describe "Sinatra Server with Middleware" do
- include Rack::Test::Methods
-
- def app
- Sinatra.new do
- set :environment, :test
- use Fozzie::Rack::Middleware
- get('/') { "echo" }
- get('/somewhere/nice') { "echo" }
- end
- end
-
- it "sends stats request on root" do
- S.expects(:timing).with('index.render', any_parameters)
- get '/'
- last_response.should be_ok
- last_response.body.should == 'echo'
- end
-
- it "sends stats request on nested path" do
- S.expects(:timing).with('somewhere.nice.render', any_parameters)
- get '/somewhere/nice'
- last_response.should be_ok
- last_response.body.should == 'echo'
end
end
\ No newline at end of file