rack-test 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,69 +0,0 @@
1
- require "rubygems"
2
- require "bundler/setup"
3
-
4
- require "codeclimate-test-reporter"
5
- CodeClimate::TestReporter.start
6
-
7
- require "rack"
8
- require "rspec"
9
-
10
- Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
11
-
12
- require "rack/test"
13
- require File.dirname(__FILE__) + "/fixtures/fake_app"
14
-
15
- RSpec.configure do |config|
16
- config.mock_with :rspec
17
- config.include Rack::Test::Methods
18
-
19
- def app
20
- Rack::Lint.new(Rack::Test::FakeApp.new)
21
- end
22
-
23
- def check(*args)
24
- end
25
-
26
- end
27
-
28
- shared_examples_for "any #verb methods" do
29
- it "requests the URL using VERB" do
30
- send(verb, "/")
31
-
32
- check last_request.env["REQUEST_METHOD"].should == verb.upcase
33
- last_response.should be_ok
34
- end
35
-
36
- it "uses the provided env" do
37
- send(verb, "/", {}, { "HTTP_USER_AGENT" => "Rack::Test" })
38
- last_request.env["HTTP_USER_AGENT"].should == "Rack::Test"
39
- end
40
-
41
- it "yields the response to a given block" do
42
- yielded = false
43
-
44
- send(verb, "/") do |response|
45
- response.should be_ok
46
- yielded = true
47
- end
48
-
49
- yielded.should be_true
50
- end
51
-
52
- it "sets the HTTP_HOST header with port" do
53
- send(verb, "http://example.org:8080/uri")
54
- last_request.env["HTTP_HOST"].should == "example.org:8080"
55
- end
56
-
57
- it "sets the HTTP_HOST header without port" do
58
- send(verb, "/uri")
59
- last_request.env["HTTP_HOST"].should == "example.org"
60
- end
61
-
62
- context "for a XHR" do
63
- it "sends XMLHttpRequest for the X-Requested-With header" do
64
- send(verb, "/", {}, { :xhr => true })
65
- last_request.env["HTTP_X_REQUESTED_WITH"].should == "XMLHttpRequest"
66
- last_request.should be_xhr
67
- end
68
- end
69
- end
@@ -1,9 +0,0 @@
1
- RSpec::Matchers.define :have_body do |expected|
2
- match do |response|
3
- response.body.should == expected
4
- end
5
-
6
- description do
7
- "have body #{expected.inspect}"
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- RSpec::Matchers.define :be_challenge do
2
- match do |actual_response|
3
- actual_response.status == 401 &&
4
- actual_response['WWW-Authenticate'] =~ /^Digest / &&
5
- actual_response.body.empty?
6
- end
7
-
8
- description do
9
- "a HTTP Digest challenge response"
10
- end
11
- end