|
7 | 7 |
|
8 | 8 | describe "request" do |
9 | 9 | it "raises an ArgumentError if an unsupported HTTP verb is used" do |
10 | | - expect { fake_api.new.request(:i_am_a_teapot, '/', {}, {}) }.to raise_error(ArgumentError) |
| 10 | + expect { fake_api.new.request(:i_am_a_teapot, '/') }.to raise_error(ArgumentError) |
11 | 11 | end |
12 | 12 |
|
13 | 13 | context "with a connection" do |
|
17 | 17 | end |
18 | 18 |
|
19 | 19 | it "supports get" do |
20 | | - stub_request(:get, "https://api.bitbucket.org/1.0/repositories"). |
| 20 | + stub_request(:get, "https://api.bitbucket.org/1.0/endpoint"). |
21 | 21 | with(:headers => { |
22 | 22 | 'Accept' => '*/*', |
23 | 23 | 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', |
24 | 24 | 'Authorization' => 'Bearer 12345', |
25 | 25 | 'User-Agent' => 'Faraday v0.9.2' |
26 | 26 | }) |
27 | 27 |
|
28 | | - fake_api.new.request(:get, '/1.0/repositories', {}, {}) |
| 28 | + fake_api.new.request(:get, '/1.0/endpoint', {}, {}) |
29 | 29 | end |
30 | 30 |
|
31 | 31 | it "supports put" do |
32 | | - stub_request(:put, "https://api.bitbucket.org/1.0/repositories"). |
33 | | - with(:body => { "data" => "payload" }, |
| 32 | + stub_request(:put, "https://api.bitbucket.org/1.0/endpoint"). |
| 33 | + with(:body => "{\"data\":{\"key\":\"value\"}}", |
34 | 34 | :headers => { |
35 | 35 | 'Accept' => '*/*', |
36 | 36 | 'Content-Type'=>'application/x-www-form-urlencoded', |
37 | 37 | 'Authorization' => 'Bearer 12345', |
38 | 38 | 'User-Agent' => 'Faraday v0.9.2' |
39 | 39 | }) |
40 | 40 |
|
41 | | - fake_api.new.request(:put, '/1.0/repositories', { :data => "payload" }, {}) |
| 41 | + fake_api.new.request(:put, '/1.0/endpoint', { 'data' => { 'key' => 'value'} }, {}) |
42 | 42 | end |
43 | 43 |
|
44 | 44 | it "supports patch" do |
45 | | - stub_request(:patch, "https://api.bitbucket.org/1.0/repositories"). |
46 | | - with(:body => { "data" => "payload" }, |
| 45 | + stub_request(:patch, "https://api.bitbucket.org/1.0/endpoint"). |
| 46 | + with(:body => "{\"data\":{\"key\":\"value\"}}", |
47 | 47 | :headers => { |
48 | 48 | 'Accept' => '*/*', |
49 | 49 | 'Content-Type'=>'application/x-www-form-urlencoded', |
50 | 50 | 'Authorization' => 'Bearer 12345', |
51 | 51 | 'User-Agent' => 'Faraday v0.9.2' |
52 | 52 | }) |
53 | 53 |
|
54 | | - fake_api.new.request(:patch, '/1.0/repositories', { :data => "payload" }, {}) |
| 54 | + fake_api.new.request(:patch, '/1.0/endpoint', { 'data' => { 'key' => 'value'} }, {}) |
55 | 55 | end |
56 | 56 |
|
57 | 57 | it "supports delete" do |
58 | | - stub_request(:delete, "https://api.bitbucket.org/1.0/repositories"). |
| 58 | + stub_request(:delete, "https://api.bitbucket.org/1.0/endpoint"). |
59 | 59 | with(:headers => { |
60 | 60 | 'Accept' => '*/*', |
61 | 61 | 'Authorization' => 'Bearer 12345', |
62 | 62 | 'User-Agent' => 'Faraday v0.9.2' |
63 | 63 | }) |
64 | | - fake_api.new.request(:delete, '/1.0/repositories', {}, {}) |
| 64 | + fake_api.new.request(:delete, '/1.0/endpoint', {}, {}) |
65 | 65 | end |
66 | 66 |
|
67 | 67 | it "supports post" do |
68 | | - stub_request(:post, "https://api.bitbucket.org/1.0/repositories"). |
69 | | - with(:body => { "data" => "payload" }, |
| 68 | + stub_request(:post, "https://api.bitbucket.org/1.0/endpoint"). |
| 69 | + with(:body => "{\"data\":{\"key\":\"value\"}}", |
70 | 70 | :headers => { |
71 | 71 | 'Accept' => '*/*', |
72 | 72 | 'Content-Type'=>'application/x-www-form-urlencoded', |
73 | 73 | 'Authorization' => 'Bearer 12345', |
74 | 74 | 'User-Agent' => 'Faraday v0.9.2' |
75 | 75 | }) |
76 | 76 |
|
77 | | - fake_api.new.request(:post, '/1.0/repositories', { :data => "payload" }, {}) |
| 77 | + fake_api.new.request(:post, '/1.0/endpoint', { 'data' => { 'key' => 'value'} }, {}) |
78 | 78 | end |
79 | 79 | end |
80 | 80 | end |
|
0 commit comments