## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 # / / require 'spec_helper.rb' describe 'Binding' do it "can fetch" do @holodeck.mock(Twilio::TwilioResponse.new(500, '')) expect { @client.notifications.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings("BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() }.to raise_exception(Twilio::REST::TwilioException) values = {} expect( @holodeck.has_request?(Holodeck::Request.new( method: 'get', url: 'https://notifications.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', ))).to eq(true) end it "receives fetch responses" do @holodeck.mock(Twilio::TwilioResponse.new( 200, %q[ { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T23:24:45Z", "date_updated": "2016-03-24T23:24:45Z", "notification_protocol_version": "3", "endpoint": "abcd", "identity": "jing", "binding_type": "apn", "address": "1234", "tags": [], "url": "https://notifications.stage.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] )) actual = @client.notifications.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings("BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() expect(actual).to_not eq(nil) end it "can delete" do @holodeck.mock(Twilio::TwilioResponse.new(500, '')) expect { @client.notifications.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings("BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() }.to raise_exception(Twilio::REST::TwilioException) values = {} expect( @holodeck.has_request?(Holodeck::Request.new( method: 'delete', url: 'https://notifications.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', ))).to eq(true) end it "receives delete responses" do @holodeck.mock(Twilio::TwilioResponse.new( 204, nil, )) actual = @client.notifications.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings("BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() expect(actual).to eq(true) end it "can create" do @holodeck.mock(Twilio::TwilioResponse.new(500, '')) expect { @client.notifications.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.create(endpoint: "endpoint", identity: "identity", binding_type: "apn", address: "address") }.to raise_exception(Twilio::REST::TwilioException) values = { 'Endpoint' => "endpoint", 'Identity' => "identity", 'BindingType' => "apn", 'Address' => "address", } expect( @holodeck.has_request?(Holodeck::Request.new( method: 'post', url: 'https://notifications.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', data: values, ))).to eq(true) end it "receives create responses" do @holodeck.mock(Twilio::TwilioResponse.new( 201, %q[ { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T23:24:45Z", "date_updated": "2016-03-24T23:24:45Z", "notification_protocol_version": "3", "endpoint": "abcd", "identity": "jing", "binding_type": "apn", "address": "1234", "tags": [], "url": "https://notifications.stage.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] )) actual = @client.notifications.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.create(endpoint: "endpoint", identity: "identity", binding_type: "apn", address: "address") expect(actual).to_not eq(nil) end it "can read" do @holodeck.mock(Twilio::TwilioResponse.new(500, '')) expect { @client.notifications.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() }.to raise_exception(Twilio::REST::TwilioException) values = {} expect( @holodeck.has_request?(Holodeck::Request.new( method: 'get', url: 'https://notifications.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', ))).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://notifications.stage.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=1&Page=0", "previous_page_url": null, "url": "https://notifications.stage.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=1&Page=0", "next_page_url": null, "key": "bindings" }, "bindings": [ { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T23:24:45Z", "date_updated": "2016-03-24T23:24:45Z", "notification_protocol_version": "3", "endpoint": "abcd", "identity": "jing", "binding_type": "apn", "address": "1234", "tags": [], "url": "https://notifications.stage.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ] )) actual = @client.notifications.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.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://notifications.stage.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=1&Page=0", "previous_page_url": null, "url": "https://notifications.stage.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=1&Page=0", "next_page_url": null, "key": "bindings" }, "bindings": [] } ] )) actual = @client.notifications.v1.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() expect(actual).to_not eq(nil) end end