Permalink
Browse files

refactored spec

  • Loading branch information...
1 parent 8d8a469 commit 4bb101623ad076535cdba87fb0085a69369351d2 @p0deje p0deje committed May 12, 2012
Showing with 7 additions and 8 deletions.
  1. +7 −8 spec/http_origin_spec.rb
View
@@ -3,6 +3,13 @@
describe Rack::Protection::HttpOrigin do
it_behaves_like "any rack application"
+ before(:each) do
+ mock_app do
+ use Rack::Protection::HttpOrigin
+ run DummyApp
+ end
+ end
+
%w(GET HEAD POST PUT DELETE).each do |method|
it "accepts #{method} requests with no Origin" do
send(method.downcase, '/').should be_ok
@@ -11,20 +18,12 @@
%w(GET HEAD).each do |method|
it "accepts #{method} requests with non-whitelisted Origin" do
- mock_app do
- use Rack::Protection::HttpOrigin
- run DummyApp
- end
send(method.downcase, '/', {}, 'HTTP_ORIGIN' => 'http://malicious.com').should be_ok
end
end
%w(POST PUT DELETE).each do |method|
it "denies #{method} requests with non-whitelisted Origin" do
- mock_app do
- use Rack::Protection::HttpOrigin
- run DummyApp
- end
send(method.downcase, '/', {}, 'HTTP_ORIGIN' => 'http://malicious.com').should_not be_ok
end

0 comments on commit 4bb1016

Please sign in to comment.