ribose 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +539 -970
- data/.sample.pryrc +4 -0
- data/CHANGELOG.md +5 -0
- data/README.md +539 -3
- data/bin/console +2 -5
- data/lib/ribose.rb +31 -1
- data/lib/ribose/actions.rb +10 -0
- data/lib/ribose/actions/all.rb +43 -0
- data/lib/ribose/actions/base.rb +11 -0
- data/lib/ribose/actions/create.rb +44 -0
- data/lib/ribose/actions/delete.rb +32 -0
- data/lib/ribose/actions/fetch.rb +44 -0
- data/lib/ribose/actions/update.rb +35 -0
- data/lib/ribose/app_data.rb +15 -0
- data/lib/ribose/app_relation.rb +12 -0
- data/lib/ribose/base.rb +48 -0
- data/lib/ribose/calendar.rb +22 -0
- data/lib/ribose/client.rb +31 -0
- data/lib/ribose/config.rb +21 -0
- data/lib/ribose/configuration.rb +25 -0
- data/lib/ribose/connection.rb +39 -0
- data/lib/ribose/connection_invitation.rb +51 -0
- data/lib/ribose/conversation.rb +87 -0
- data/lib/ribose/error.rb +30 -0
- data/lib/ribose/feed.rb +11 -0
- data/lib/ribose/file_uploader.rb +93 -0
- data/lib/ribose/join_space_request.rb +41 -0
- data/lib/ribose/leaderboard.rb +19 -0
- data/lib/ribose/member.rb +34 -0
- data/lib/ribose/message.rb +94 -0
- data/lib/ribose/profile.rb +56 -0
- data/lib/ribose/request.rb +122 -0
- data/lib/ribose/resource_helper.rb +81 -0
- data/lib/ribose/response/raise_error.rb +15 -0
- data/lib/ribose/rspec.rb +19 -0
- data/lib/ribose/session.rb +48 -0
- data/lib/ribose/setting.rb +16 -0
- data/lib/ribose/space.rb +30 -0
- data/lib/ribose/space_file.rb +49 -0
- data/lib/ribose/space_invitation.rb +70 -0
- data/lib/ribose/stream.rb +15 -0
- data/lib/ribose/user.rb +42 -0
- data/lib/ribose/version.rb +1 -1
- data/lib/ribose/widget.rb +11 -0
- data/lib/ribose/wiki.rb +80 -0
- data/ribose.gemspec +6 -0
- data/spec/fixtures/app_data.json +188 -0
- data/spec/fixtures/app_relation.json +19 -0
- data/spec/fixtures/app_relations.json +89 -0
- data/spec/fixtures/calendar.json +12 -0
- data/spec/fixtures/calendars.json +34 -0
- data/spec/fixtures/connection_invitation.json +26 -0
- data/spec/fixtures/connection_invitation_accepted.json +26 -0
- data/spec/fixtures/connection_invitations.json +28 -0
- data/spec/fixtures/connection_invitations_created.json +37 -0
- data/spec/fixtures/connection_suggestion.json +22 -0
- data/spec/fixtures/connections.json +28 -0
- data/spec/fixtures/conversation.json +26 -0
- data/spec/fixtures/conversation_created.json +31 -0
- data/spec/fixtures/conversations.json +34 -0
- data/spec/fixtures/empty.json +1 -0
- data/spec/fixtures/feeds.json +84 -0
- data/spec/fixtures/file_upload_prepared.json +17 -0
- data/spec/fixtures/file_uploaded.json +38 -0
- data/spec/fixtures/general_information.json +16 -0
- data/spec/fixtures/join_space_request_created.json +26 -0
- data/spec/fixtures/join_space_request_updated.json +25 -0
- data/spec/fixtures/join_space_requests.json +34 -0
- data/spec/fixtures/leaderboard.json +21 -0
- data/spec/fixtures/login.html +323 -0
- data/spec/fixtures/members.json +20 -0
- data/spec/fixtures/message.json +22 -0
- data/spec/fixtures/messages.json +24 -0
- data/spec/fixtures/ping.json +3 -0
- data/spec/fixtures/profile.json +10 -0
- data/spec/fixtures/sample.png +0 -0
- data/spec/fixtures/setting.json +16 -0
- data/spec/fixtures/settings.json +18 -0
- data/spec/fixtures/space.json +59 -0
- data/spec/fixtures/space_created.json +59 -0
- data/spec/fixtures/space_file.json +58 -0
- data/spec/fixtures/space_invitation.json +32 -0
- data/spec/fixtures/space_invitation_updated.json +35 -0
- data/spec/fixtures/space_invitations.json +34 -0
- data/spec/fixtures/space_mass_invitations.json +46 -0
- data/spec/fixtures/spaces.json +61 -0
- data/spec/fixtures/stream.json +176 -0
- data/spec/fixtures/user_activated.json +6 -0
- data/spec/fixtures/widgets.json +50 -0
- data/spec/fixtures/wiki.json +79 -0
- data/spec/fixtures/wikis.json +197 -0
- data/spec/ribose/actions/create_spec.rb +40 -0
- data/spec/ribose/actions/delete_spec.rb +24 -0
- data/spec/ribose/actions/fetch_spec.rb +32 -0
- data/spec/ribose/actions/update_spec.rb +36 -0
- data/spec/ribose/app_data_spec.rb +15 -0
- data/spec/ribose/app_relation_spec.rb +27 -0
- data/spec/ribose/calendar_spec.rb +50 -0
- data/spec/ribose/client_spec.rb +48 -0
- data/spec/ribose/config_spec.rb +41 -0
- data/spec/ribose/connection_invitation_spec.rb +79 -0
- data/spec/ribose/connection_spec.rb +26 -0
- data/spec/ribose/conversation_spec.rb +84 -0
- data/spec/ribose/error_spec.rb +67 -0
- data/spec/ribose/feed_spec.rb +14 -0
- data/spec/ribose/file_uploader_spec.rb +30 -0
- data/spec/ribose/join_space_request_spec.rb +70 -0
- data/spec/ribose/leaderboard_spec.rb +13 -0
- data/spec/ribose/member_spec.rb +16 -0
- data/spec/ribose/message_spec.rb +69 -0
- data/spec/ribose/profile_spec.rb +40 -0
- data/spec/ribose/request_spec.rb +66 -0
- data/spec/ribose/resource_helper_spec.rb +58 -0
- data/spec/ribose/session_spec.rb +46 -0
- data/spec/ribose/setting_spec.rb +40 -0
- data/spec/ribose/space_file_spec.rb +41 -0
- data/spec/ribose/space_invitation_spec.rb +117 -0
- data/spec/ribose/space_spec.rb +70 -0
- data/spec/ribose/stream_spec.rb +14 -0
- data/spec/ribose/user_spec.rb +48 -0
- data/spec/ribose/widget_spec.rb +14 -0
- data/spec/ribose/wiki_spec.rb +67 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/fake_ribose_api.rb +431 -0
- data/spec/support/file_upload_stub.rb +76 -0
- metadata +190 -3
- data/spec/ribose_spec.rb +0 -4
@@ -0,0 +1,67 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Ribose Errors" do
|
4
|
+
context "when response is 200" do
|
5
|
+
it "does not raise any error" do
|
6
|
+
stub_ping_request_with(200)
|
7
|
+
expect { create_ping_request }.not_to raise_error
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when response is 201" do
|
12
|
+
it "does not raise any error" do
|
13
|
+
stub_ping_request_with(201)
|
14
|
+
expect { create_ping_request }.not_to raise_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when response is 400" do
|
19
|
+
it "retuns the bad request error" do
|
20
|
+
stub_ping_request_with(400)
|
21
|
+
expect { create_ping_request }.to raise_error(Ribose::BadRequest)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when response is 401" do
|
26
|
+
it "returns the unauthorized error" do
|
27
|
+
stub_ping_request_with(401)
|
28
|
+
expect { create_ping_request }.to raise_error(Ribose::Unauthorized)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "when response is 403" do
|
33
|
+
it "returns the forbidden error" do
|
34
|
+
stub_ping_request_with(403)
|
35
|
+
expect { create_ping_request }.to raise_error(Ribose::Forbidden)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when response is 404" do
|
40
|
+
it "returns the not_found error" do
|
41
|
+
stub_ping_request_with(404)
|
42
|
+
expect { create_ping_request }.to raise_error(Ribose::NotFound)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when response is 422" do
|
47
|
+
it "returns unprocessable entity error" do
|
48
|
+
stub_ping_request_with(422)
|
49
|
+
expect { create_ping_request }.to raise_error(Ribose::UnprocessableEntity)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when the response is 5xx" do
|
54
|
+
it "returns server error" do
|
55
|
+
stub_ping_request_with(501)
|
56
|
+
expect { create_ping_request }.to raise_error(Ribose::ServerError)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def create_ping_request
|
61
|
+
Ribose::Request.get("/ping")
|
62
|
+
end
|
63
|
+
|
64
|
+
def stub_ping_request_with(status = 200, method = :get)
|
65
|
+
stub_api_response(method, "ping", filename: "ping", status: status)
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::Feed do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves the list of user feeds" do
|
6
|
+
stub_ribose_feed_api
|
7
|
+
feeds = Ribose::Feed.all
|
8
|
+
|
9
|
+
expect(feeds.first.id).not_to be_nil
|
10
|
+
expect(feeds.first.type).to eq("Feed::Basic")
|
11
|
+
expect(feeds.first.instance_name).to eq("John Doe")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::FileUploader do
|
4
|
+
describe ".upload" do
|
5
|
+
context "with valid data" do
|
6
|
+
it "creates a new upload with details" do
|
7
|
+
space_id = 123_456_789
|
8
|
+
|
9
|
+
stub_ribose_space_file_upload_api(space_id, file_attributes)
|
10
|
+
file_upload = Ribose::FileUploader.upload(space_id, file_attributes)
|
11
|
+
|
12
|
+
expect(file_upload.attachment.id).not_to be_nil
|
13
|
+
expect(file_upload.attachment.author).to eq("John Doe")
|
14
|
+
expect(file_upload.attachment.content_type).to eq("image/png")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def file_attributes
|
20
|
+
{
|
21
|
+
file: sample_fixture_file,
|
22
|
+
tag_list: "sample, file, samplefile",
|
23
|
+
description: "This is a sample file",
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def sample_fixture_file
|
28
|
+
@sample_file ||= File.join(Ribose.root, "spec/fixtures/sample.png")
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::JoinSpaceRequest do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves the list of all join space requests" do
|
6
|
+
stub_ribose_join_space_request_list_api
|
7
|
+
invitations = Ribose::JoinSpaceRequest.all
|
8
|
+
|
9
|
+
expect(invitations.first.id).not_to be_nil
|
10
|
+
expect(invitations.first.type).to eq("Invitation::ToSpace")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".create" do
|
15
|
+
it "creates a new join space request" do
|
16
|
+
attributes = {
|
17
|
+
state: 0,
|
18
|
+
type: "Invitation::JoinSpaceRequest",
|
19
|
+
body: "Hi, I would like to join to your space",
|
20
|
+
space_id: 123_456_789,
|
21
|
+
}
|
22
|
+
|
23
|
+
stub_ribose_join_space_request_create_api(attributes)
|
24
|
+
invitation = Ribose::JoinSpaceRequest.create(attributes)
|
25
|
+
|
26
|
+
expect(invitation.id).not_to be_nil
|
27
|
+
expect(invitation.inviter.name).to eq("John Doe")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe ".update" do
|
32
|
+
it "updates the details for a join request" do
|
33
|
+
invitation_id = 123_456_789
|
34
|
+
attributes = { state: 1, role_id: 101 }
|
35
|
+
|
36
|
+
stub_ribose_join_space_request_update(invitation_id, attributes)
|
37
|
+
invitation = Ribose::JoinSpaceRequest.update(invitation_id, attributes)
|
38
|
+
|
39
|
+
expect(invitation.id).not_to be_nil
|
40
|
+
expect(invitation.state).not_to be_nil
|
41
|
+
expect(invitation.type).to eq("Invitation::JoinSpaceRequest")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".accept" do
|
46
|
+
it "accepts a join request to a space" do
|
47
|
+
invitation_id = 123_456_789
|
48
|
+
|
49
|
+
stub_ribose_join_space_request_update(invitation_id, state: 1)
|
50
|
+
invitation = Ribose::JoinSpaceRequest.accept(invitation_id)
|
51
|
+
|
52
|
+
expect(invitation.state).to eq(1)
|
53
|
+
expect(invitation.id).not_to be_nil
|
54
|
+
expect(invitation.type).to eq("Invitation::JoinSpaceRequest")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe ".reject" do
|
59
|
+
it "rejects a join request to a space" do
|
60
|
+
invitation_id = 123_456_789
|
61
|
+
|
62
|
+
stub_ribose_join_space_request_update(invitation_id, state: 2)
|
63
|
+
invitation = Ribose::JoinSpaceRequest.reject(invitation_id)
|
64
|
+
|
65
|
+
expect(invitation.id).not_to be_nil
|
66
|
+
expect(invitation.state).not_to be_nil
|
67
|
+
expect(invitation.type).to eq("Invitation::JoinSpaceRequest")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::Leaderboard do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves the current leader board" do
|
6
|
+
stub_ribose_leaderboard_api
|
7
|
+
leaderboard = Ribose::Leaderboard.all
|
8
|
+
|
9
|
+
expect(leaderboard.first.name).to eq("John Doe")
|
10
|
+
expect(leaderboard.first.login).to eq("john.doe")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::Member do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves all members for a space" do
|
6
|
+
space_id = 123_456_789
|
7
|
+
stub_ribose_space_member_list(space_id)
|
8
|
+
|
9
|
+
members = Ribose::Member.all(space_id)
|
10
|
+
|
11
|
+
expect(members.count).to eq(1)
|
12
|
+
expect(members.first.user.name).to eq("John Doe")
|
13
|
+
expect(members.first.role_name_in_space).to eq("Administrator")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::Message do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves all conversation messages" do
|
6
|
+
space_id = 123_456
|
7
|
+
conversation_id = 456_789
|
8
|
+
stub_ribose_message_list(space_id, conversation_id)
|
9
|
+
|
10
|
+
messages = Ribose::Message.all(
|
11
|
+
space_id: space_id, conversation_id: conversation_id,
|
12
|
+
)
|
13
|
+
|
14
|
+
expect(messages.first.id).not_to be_nil
|
15
|
+
expect(messages.first.user.name).to eq("John Doe")
|
16
|
+
expect(messages.first.contents).to eq("Welcome to Ribose Space")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".create" do
|
21
|
+
it "creates a new message into a conversation" do
|
22
|
+
space_id = 123_456
|
23
|
+
|
24
|
+
stub_ribose_message_create(space_id, message: message_attrs)
|
25
|
+
message = Ribose::Message.create(message_attrs.merge(space_id: space_id))
|
26
|
+
|
27
|
+
expect(message.id).not_to be_nil
|
28
|
+
expect(message.user.name).to eq("John Doe")
|
29
|
+
expect(message.contents).to eq("Welcome to Ribose")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".update" do
|
34
|
+
it "updates an existing conversation message" do
|
35
|
+
space_id = 123_456
|
36
|
+
message_id = 789_012_345
|
37
|
+
|
38
|
+
stub_ribose_message_update(space_id, message_id, message: message_attrs)
|
39
|
+
message = Ribose::Message.update(
|
40
|
+
message_attrs.merge(space_id: space_id, message_id: message_id),
|
41
|
+
)
|
42
|
+
|
43
|
+
expect(message.user.name).to eq("John Doe")
|
44
|
+
expect(message.contents).to eq("Welcome to Ribose")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe ".remove" do
|
49
|
+
it "remvoes a message from the conversation" do
|
50
|
+
space_id = 123_456
|
51
|
+
message_id = 789_012_345
|
52
|
+
conversation_id = 9282737373
|
53
|
+
|
54
|
+
stub_ribose_message_remove(space_id, message_id, conversation_id)
|
55
|
+
|
56
|
+
expect do
|
57
|
+
Ribose::Message.remove(
|
58
|
+
space_id: space_id,
|
59
|
+
message_id: message_id,
|
60
|
+
conversation_id: conversation_id,
|
61
|
+
)
|
62
|
+
end.not_to raise_error
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def message_attrs
|
67
|
+
{ contents: "Welcome to Ribose", conversation_id: "456789" }
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::Profile do
|
4
|
+
describe ".fetch" do
|
5
|
+
it "retrieves the current user profile" do
|
6
|
+
stub_ribose_fetch_profile_api
|
7
|
+
profile = Ribose::Profile.fetch
|
8
|
+
|
9
|
+
expect(profile.id).not_to be_nil
|
10
|
+
expect(profile.first_name).to eq("John")
|
11
|
+
expect(profile.name).to eq("John Doe")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".updates" do
|
16
|
+
it "updates teh current user profile" do
|
17
|
+
attributes = { frest_name: "John", last_name: "Doe" }
|
18
|
+
|
19
|
+
stub_ribose_update_profile_api(attributes)
|
20
|
+
profile = Ribose::Profile.update(attributes)
|
21
|
+
|
22
|
+
expect(profile.id).not_to be_nil
|
23
|
+
expect(profile.name).to eq("John Doe")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".set_login" do
|
28
|
+
it "sets the login for the current user" do
|
29
|
+
user_id = "63116bd1"
|
30
|
+
login = "new_login_name"
|
31
|
+
|
32
|
+
stub_ribose_fetch_profile_api
|
33
|
+
stub_ribose_set_login_name_api(user_id, login)
|
34
|
+
profile = Ribose::Profile.set_login(login)
|
35
|
+
|
36
|
+
expect(profile.id).not_to be_nil
|
37
|
+
expect(profile.name).to eq("John Doe")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::Request do
|
4
|
+
describe ".get" do
|
5
|
+
it "retrieve the resource via a http :get" do
|
6
|
+
endpoint = "ping"
|
7
|
+
|
8
|
+
stub_ribose_ping_api_request
|
9
|
+
response = Ribose::Request.get(endpoint)
|
10
|
+
|
11
|
+
expect(response.data).to eq("Pong!")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".post" do
|
16
|
+
it "submits provided data via :post" do
|
17
|
+
stub_ribose_ping_api_request(:post)
|
18
|
+
response = Ribose::Request.post("ping", data: "hello")
|
19
|
+
|
20
|
+
expect(response.data).to eq("Pong!")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".put" do
|
25
|
+
it "creates a new http request via :put" do
|
26
|
+
stub_ribose_ping_api_request(:put)
|
27
|
+
response = Ribose::Request.put("ping", data: "hello")
|
28
|
+
|
29
|
+
expect(response.data).to eq("Pong!")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".delete" do
|
34
|
+
it "creates a http request via :delete" do
|
35
|
+
stub_ribose_ping_api_request(:delete)
|
36
|
+
response = Ribose::Request.delete("ping")
|
37
|
+
|
38
|
+
expect(response.data).to eq("Pong!")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "client" do
|
43
|
+
context "when custom client specifeid" do
|
44
|
+
it "sends the http request with the custom client" do
|
45
|
+
client = Ribose::Client.new(token: 123, email: "john@example.com")
|
46
|
+
|
47
|
+
stub_ribose_ping_api_request(:get, client)
|
48
|
+
response = Ribose::Request.get("ping", client: client)
|
49
|
+
|
50
|
+
expect(response.data).to eq("Pong!")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "with invalid ribose client" do
|
55
|
+
it "raise the ribose unauthorized error" do
|
56
|
+
expect do
|
57
|
+
Ribose::Request.get("ping", client: Hash.new)
|
58
|
+
end.to raise_error(Ribose::Unauthorized)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def stub_ribose_ping_api_request(method = :get, client = nil)
|
64
|
+
stub_api_response(method, "ping", filename: "ping", client: client)
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "ribose/resource_helper"
|
3
|
+
|
4
|
+
RSpec.describe "TestResourceHelper" do
|
5
|
+
describe "helpers" do
|
6
|
+
context "without any customization" do
|
7
|
+
it "builds and returns the default values" do
|
8
|
+
resource = Ribose::TestResourceHelper.new
|
9
|
+
|
10
|
+
expect(resource.resource).to eq("resource")
|
11
|
+
expect(resource.resources).to eq("resources")
|
12
|
+
|
13
|
+
expect(resource.resources_path).to eq("resources")
|
14
|
+
expect(resource.resource_path).to eq("resources/123456789")
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with customization" do
|
18
|
+
it "returns the custom values when available" do
|
19
|
+
custom_resource = Ribose::CustomResourceHelper.new
|
20
|
+
|
21
|
+
expect(custom_resource.resources).to eq("resources")
|
22
|
+
expect(custom_resource.resources_path).to eq("resource/nested")
|
23
|
+
expect(custom_resource.resource_path).to eq("custom/nested/123456789")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module Ribose
|
30
|
+
class TestResourceHelper
|
31
|
+
include Ribose::ResourceHelper
|
32
|
+
|
33
|
+
def resource
|
34
|
+
"resource"
|
35
|
+
end
|
36
|
+
|
37
|
+
def resource_id
|
38
|
+
123_456_789
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class CustomResourceHelper
|
43
|
+
include Ribose::ResourceHelper
|
44
|
+
|
45
|
+
def resource
|
46
|
+
"resource"
|
47
|
+
end
|
48
|
+
|
49
|
+
def resources_path
|
50
|
+
"resource/nested"
|
51
|
+
end
|
52
|
+
|
53
|
+
def resource_path
|
54
|
+
"custom/nested/123456789"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|