|
4 | 4 | before do |
5 | 5 | @layer = Layer::Api::Client.new |
6 | 6 | @conn = @layer.connection |
| 7 | + @default_headers = @layer.default_layer_headers.reject{|k, v| k == 'If-None-Match'} |
7 | 8 | end |
8 | 9 |
|
9 | 10 | describe ".connection" do |
|
14 | 15 | it "should return a connection containing default layer headers" do |
15 | 16 | # Remove If-None-Match header since it's always going to be random |
16 | 17 | # and we can't compare it |
17 | | - default_headers = @layer.default_layer_headers.reject{|k, v| k == 'If-None-Match'} |
18 | | - expect(@conn.headers).to include(default_headers) |
| 18 | + expect(@conn.headers).to include(@default_headers) |
19 | 19 | expect(@conn.headers).to include("If-None-Match") |
20 | 20 | end |
21 | 21 |
|
|
29 | 29 | expect(@conn.object_id).to eq(new_conn.object_id) |
30 | 30 | end |
31 | 31 | end |
| 32 | + |
| 33 | + describe ".run_request" do |
| 34 | + it "should successfully add default layer headers to request" do |
| 35 | + VCR.use_cassette('conversation') do |
| 36 | + request = @layer.run_request(:get, 'users/test/blocks') |
| 37 | + expect(request.env.request_headers).to include(@default_headers) |
| 38 | + expect(request.env.request_headers).to include("If-None-Match") |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + it "should make request to url that is supplied as param" do |
| 43 | + VCR.use_cassette('conversation') do |
| 44 | + request_url = 'users/test/blocks' |
| 45 | + request = @layer.run_request(:get, request_url) |
| 46 | + request_actual = request.env.url.to_s.sub("#{@layer.base_url}/", "") |
| 47 | + |
| 48 | + expect(request_actual).to eq (request_url) |
| 49 | + end |
| 50 | + end |
| 51 | + |
| 52 | + it "should use the http method that is supplied as a param" do |
| 53 | + VCR.use_cassette('announcement') do |
| 54 | + method = :post |
| 55 | + request = @layer.run_request(method, 'announcements', announcement_params) |
| 56 | + |
| 57 | + expect(request.env.method).to eq(method) |
| 58 | + end |
| 59 | + end |
| 60 | + end |
32 | 61 | end |
0 commit comments