Sha256: 3d5ce4331710475707b437ad3377ef86e36577a6a5e9b8de451a399b66a0b00d

Contents?: true

Size: 1.86 KB

Versions: 10

Compression:

Stored size: 1.86 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

module SmsNotify
	class Api
		class Command
			def execute(parameters)
				'<?xml version="1.0" encoding="utf-8"?>
<ArrayOfSmsResponse xmlns="http://ws.cdyne.com/SmsWS/">
  <SmsResponse>
    <ResponseID>293948</ResponseID>
    <TextID>32934</TextID>
    <StatusCode>2</StatusCode>
    <ReceivedDate></ReceivedDate>
    <Message>Feel the burn</Message>
  </SmsResponse>
  <SmsResponse>
    <ResponseID>293950</ResponseID>
    <TextID>32934</TextID>
    <StatusCode>5</StatusCode>
    <ReceivedDate></ReceivedDate>
    <Message>You got it</Message>
  </SmsResponse>
</ArrayOfSmsResponse>'
			end
		end
	end
end

module SmsNotify
  describe "Api" do
    before(:each) do
      @api = Api.new('key')
    end

    it "should return a default endpoint url" do
      Api.endpoint_host.should be_a String
    end

    it "should have a license key method after initialized" do
      @api.license_key.should == 'key'
    end

    it "should respond to send_message" do
      @api.respond_to?('send_message').should be true
    end
		
		describe "message_responses" do
			it "should return an array of MessageResponse objects" do
				@api.message_responses('1234')
			end
		end	

    describe "Api Command" do
      before(:each) do
        @command = Api::Command.new('cmdname', 'key')
      end
    
      it "should return an encoded url for the requested command and parameters" do
        url = @command.build_url(:fu => 'bar', :sna => 'fu')
        url.should == URI.parse('https://ws.cdyne.com/SmsWs/SMS.asmx/cmdname?LicenseKey=key&fu=bar&sna=fu')
      end

      it "should return an encoded url with invalid url characters escaped" do
        url = @command.build_url(:fu => 'b a r', :sna => 'f&u')
        url.should == URI.parse('https://ws.cdyne.com/SmsWs/SMS.asmx/cmdname?LicenseKey=key&fu=b+a+r&sna=f%26u')
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cdyne-sms-notify-1.0.6 spec/api_spec.rb
cdyne-sms-notify-1.0.4 spec/api_spec.rb
cdyne-sms-notify-1.0.3 spec/api_spec.rb
cdyne-sms-notify-1.0.2 spec/api_spec.rb
cdyne-sms-notify-1.0.1 spec/api_spec.rb
cdyne-sms-notify-1.0.0 spec/api_spec.rb
cdyne-sms-notify-0.10.1 spec/api_spec.rb
cdyne-sms-notify-0.10.0 spec/api_spec.rb
cdyne-sms-notify-0.9.6 spec/api_spec.rb
cdyne-sms-notify-0.8.5 spec/api_spec.rb