spec/integration/ip_messaging/v1/service/role_spec.rb in twilio-ruby-5.0.0.rc3 vs spec/integration/ip_messaging/v1/service/role_spec.rb in twilio-ruby-5.0.0.rc4

- old
+ new

@@ -21,10 +21,39 @@ method: 'get', url: 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', ))).to eq(true) end + it "receives fetch responses" do + @holodeck.mock(Twilio::TwilioResponse.new( + 200, + %q[ + { + "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "channel user", + "type": "channel", + "permissions": [ + "sendMessage", + "leaveChannel", + "editOwnMessage", + "deleteOwnMessage" + ], + "date_created": "2016-03-03T19:47:15Z", + "date_updated": "2016-03-03T19:47:15Z", + "url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.ip_messaging.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ + .roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() + + expect(actual).to_not eq(nil) + end + it "can delete" do @holodeck.mock(Twilio::TwilioResponse.new(500, '')) expect { @client.ip_messaging.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ @@ -32,15 +61,27 @@ }.to raise_exception(Twilio::REST::TwilioException) values = {} expect( @holodeck.has_request?(Holodeck::Request.new( - method: 'get', + method: 'delete', url: 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', ))).to eq(true) end + it "receives delete responses" do + @holodeck.mock(Twilio::TwilioResponse.new( + 204, + nil, + )) + + actual = @client.ip_messaging.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ + .roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() + + expect(actual).to eq(true) + end + it "can create" do @holodeck.mock(Twilio::TwilioResponse.new(500, '')) expect { @client.ip_messaging.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ @@ -58,10 +99,39 @@ url: 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', data: values, ))).to eq(true) end + it "receives create responses" do + @holodeck.mock(Twilio::TwilioResponse.new( + 201, + %q[ + { + "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "channel user", + "type": "channel", + "permissions": [ + "sendMessage", + "leaveChannel", + "editOwnMessage", + "deleteOwnMessage" + ], + "date_created": "2016-03-03T19:47:15Z", + "date_updated": "2016-03-03T19:47:15Z", + "url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.ip_messaging.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ + .roles.create(friendly_name: "friendly_name", type: "channel", permission: ['permission']) + + expect(actual).to_not eq(nil) + end + it "can read" do @holodeck.mock(Twilio::TwilioResponse.new(500, '')) expect { @client.ip_messaging.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ @@ -74,10 +144,77 @@ method: 'get', url: 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', ))).to eq(true) end + it "receives read_full responses" do + @holodeck.mock(Twilio::TwilioResponse.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 1, + "first_page_url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=1&Page=0", + "previous_page_url": null, + "url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=1&Page=0", + "next_page_url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=1&Page=1&PageToken=PTRL3ea1a94dd9cd408c8b29d18bf0f99033", + "key": "roles" + }, + "roles": [ + { + "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "channel user", + "type": "channel", + "permissions": [ + "sendMessage", + "leaveChannel", + "editOwnMessage", + "deleteOwnMessage" + ], + "date_created": "2016-03-03T19:47:15Z", + "date_updated": "2016-03-03T19:47:15Z", + "url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + } + ] + )) + + actual = @client.ip_messaging.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ + .roles.list() + + expect(actual).to_not eq(nil) + end + + it "receives read_empty responses" do + @holodeck.mock(Twilio::TwilioResponse.new( + 200, + %q[ + { + "meta": { + "page": 0, + "page_size": 1, + "first_page_url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=1&Page=0", + "previous_page_url": null, + "url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=1&Page=0", + "next_page_url": null, + "key": "roles" + }, + "roles": [] + } + ] + )) + + actual = @client.ip_messaging.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ + .roles.list() + + expect(actual).to_not eq(nil) + end + it "can update" do @holodeck.mock(Twilio::TwilioResponse.new(500, '')) expect { @client.ip_messaging.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ @@ -92,7 +229,36 @@ @holodeck.has_request?(Holodeck::Request.new( method: 'post', url: 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', data: values, ))).to eq(true) + end + + it "receives update responses" do + @holodeck.mock(Twilio::TwilioResponse.new( + 200, + %q[ + { + "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "friendly_name": "channel user", + "type": "channel", + "permissions": [ + "sendMessage", + "leaveChannel", + "editOwnMessage", + "deleteOwnMessage" + ], + "date_created": "2016-03-03T19:47:15Z", + "date_updated": "2016-03-03T19:47:15Z", + "url": "https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] + )) + + actual = @client.ip_messaging.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ + .roles("RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(friendly_name: "friendly_name", permission: ['permission']) + + expect(actual).to_not eq(nil) end end \ No newline at end of file