-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusers_spec.rb
More file actions
111 lines (97 loc) · 2.92 KB
/
users_spec.rb
File metadata and controls
111 lines (97 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# frozen_string_literal: true
require_relative "../lib/embed_workflow"
require "net/http"
describe "users" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:execute_request)
.with(instance_of(Net::HTTPRequest))
.and_return("response")
end
describe "#list" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:get_request)
.with({ path: "/api/v1/users", params: {} })
.and_return("response")
end
it "sends the correct parameters to the users API" do
EmbedWorkflow::Users.list
end
context "with pagination parameters" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:get_request)
.with({ path: "/api/v1/users", params: { starting_after: "550e8400-e29b-41d4-a716-446655440000", limit: 10 } })
.and_return("response")
end
it "sends the correct pagination parameters" do
EmbedWorkflow::Users.list(starting_after: "550e8400-e29b-41d4-a716-446655440000", limit: 10)
end
end
end
describe "#fetch" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:get_request)
.with({ path: "/api/v1/users/api-user-1" })
.and_return("response")
end
it "sends the correct parameters to the users API" do
EmbedWorkflow::Users.fetch(key: "api-user-1")
end
end
describe "#delete" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:delete_request)
.with({ path: "/api/v1/users/api-user-1" })
.and_return("response")
end
it "sends the correct parameters to the users API" do
EmbedWorkflow::Users.delete(key: "api-user-1")
end
end
describe "#upsert" do
context "with minimum parameters" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:put_request)
.with({
path: "/api/v1/users/api-user-1",
body: { key: "api-user-1" }
})
.and_return("response")
end
it "sends the correct parameters to the users API" do
EmbedWorkflow::Users.upsert(key: "api-user-1")
end
end
context "with all parameters" do
before do
data = { foo: "bar" }
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:put_request)
.with({
path: "/api/v1/users/api-user-1",
body: {
key: "api-user-1",
name: "Jane Doe",
email: "jane@example.com",
data: data
}
})
.and_return("response")
end
it "sends the correct parameters to the users API" do
data = { foo: "bar" }
EmbedWorkflow::Users.upsert(
key: "api-user-1",
name: "Jane Doe",
email: "jane@example.com",
data: data
)
end
end
end
end