|
22 | 22 | expect(device.device_id).to eq(seed["august_device_1"]) |
23 | 23 | end |
24 | 24 |
|
| 25 | + it "accepts the api key as the first argument" do |
| 26 | + seam = Seam.new(seed["seam_apikey1_token"], endpoint: endpoint, wait_for_action_attempt: false) |
| 27 | + |
| 28 | + device = seam.devices.get(device_id: seed["august_device_1"]) |
| 29 | + |
| 30 | + expect(device.device_id).to eq(seed["august_device_1"]) |
| 31 | + expect(seam.defaults.wait_for_action_attempt).to be false |
| 32 | + end |
| 33 | + |
| 34 | + it "accepts the api key as the first argument on every constructor" do |
| 35 | + [Seam::Http, Seam::Http::SingleWorkspace].each do |klass| |
| 36 | + seam = klass.new(seed["seam_apikey1_token"], endpoint: endpoint) |
| 37 | + |
| 38 | + expect(seam.devices.get(device_id: seed["august_device_1"]).device_id).to eq(seed["august_device_1"]) |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + it "rejects an api key given both as the first argument and as an option" do |
| 43 | + expect { Seam.new("seam_some_api_key", api_key: "seam_other_api_key") }.to raise_error( |
| 44 | + Seam::Http::Options::SeamInvalidOptionsError, |
| 45 | + "Seam received invalid options: The api_key was given both as a positional argument and as the api_key option" |
| 46 | + ) |
| 47 | + end |
| 48 | + |
| 49 | + it "rejects an api key given as the first argument alongside a client" do |
| 50 | + expect { Seam.new("seam_some_api_key", client: Faraday.new) }.to raise_error( |
| 51 | + Seam::Http::Options::SeamInvalidOptionsError, |
| 52 | + /The client option cannot be used with any other option, but received: api_key/ |
| 53 | + ) |
| 54 | + end |
| 55 | + |
| 56 | + it "treats a nil first argument as no api key" do |
| 57 | + seam = Seam.new(nil, api_key: seed["seam_apikey1_token"], endpoint: endpoint) |
| 58 | + |
| 59 | + expect(seam.devices.get(device_id: seed["august_device_1"]).device_id).to eq(seed["august_device_1"]) |
| 60 | + end |
| 61 | + |
25 | 62 | it "returns resources with parsed attributes" do |
26 | 63 | devices = seam.devices.list |
27 | 64 |
|
|
44 | 81 | Seam.from_api_key("ey") |
45 | 82 | end.to raise_error(Seam::Http::Auth::SeamInvalidTokenError, /JWT/) |
46 | 83 |
|
| 84 | + expect do |
| 85 | + Seam.new("ey") |
| 86 | + end.to raise_error(Seam::Http::Auth::SeamInvalidTokenError, /JWT/) |
| 87 | + |
47 | 88 | expect do |
48 | 89 | Seam.from_api_key("seam_cst_token") |
49 | 90 | end.to raise_error(Seam::Http::Auth::SeamInvalidTokenError, /Client Session Token/) |
|
0 commit comments