spec/smsified_spec.rb in smsified-0.1.5 vs spec/smsified_spec.rb in smsified-0.1.6
- old
+ new
@@ -10,31 +10,40 @@
@address = '14155551212'
@sender_address = '13035551212'
end
describe "Helpers" do
- it 'Should camelcase the appropriate keys' do
+ before(:all) do
class Foo
include Smsified::Helpers
- attr_reader :keys
+ attr_reader :keys, :query_string
def initialize(hash)
@keys = camelcase_keys(hash)
+ @query_string = build_query_string(hash)
end
end
- camelcased_keys = Foo.new({ :destination_address => 'foo',
- :notify_url => 'bar',
- :client_correlator => 'baz',
- :callback_data => 'donkey' }).keys
+ @foo = Foo.new({ :destination_address => 'foo',
+ :notify_url => 'bar',
+ :client_correlator => 'baz',
+ :callback_data => 'donkey' })
+ end
+
+ it 'Should camelcase the appropriate keys' do
+ camelcased_keys = @foo.keys
camelcased_keys[:destinationAddress].should eql 'foo'
camelcased_keys[:notifyURL].should eql 'bar'
camelcased_keys[:clientCorrelator].should eql 'baz'
camelcased_keys[:callbackData].should eql 'donkey'
end
+
+ it 'Should build a proper query string' do
+ @foo.query_string.should eql "destinationAddress=foo¬ifyURL=bar&clientCorrelator=baz&callbackData=donkey"
+ end
end
describe "OneAPI" do
before(:all) do
@one_api = Smsified::OneAPI.new :username => @username, :password => @password, :debug => true
@@ -107,17 +116,19 @@
end
it "Should send an SMS" do
response = @one_api.send_sms(:address => @address, :message => 'Hola from RSpec!', :sender_address => @sender_address)
response.data.should eql @message_sent
+ FakeWeb.last_request.body.should eql "message=Hola+from+RSpec%21&address=14155551212"
end
it "Should send an SMS to multiple destinations" do
response = @one_api.send_sms(:address => ['14155551212', '13035551212'],
:message => 'Hola from RSpec!',
:sender_address => @sender_address)
response.data.should eql @message_sent
+ FakeWeb.last_request.body.should eql "message=Hola+from+RSpec%21&address=14155551212&address=13035551212"
end
it "Should raise an error if you pass an unknown method name" do
begin
@one_api.foobar
@@ -265,16 +276,18 @@
it 'Should create an inbound subscription' do
result = @subscriptions.create_inbound_subscription('17177455076', :notify_url => 'http://foobar.com')
result.http.code.should eql '200'
result.data.should eql @inbound_subscription
+ FakeWeb.last_request.body.should eql "destinationAddress=17177455076¬ifyURL=http%3A%2F%2Ffoobar.com"
end
it 'Should create an outbound subscription' do
result = @subscriptions.create_outbound_subscription('17177455076', :notify_url => 'http://foobar.com')
result.http.code.should eql '200'
result.data.should eql @outbound_subscription
+ FakeWeb.last_request.body.should eql "notifyURL=http%3A%2F%2Ffoobar.com"
end
end
describe 'Updated subscriptions' do
before(:all) do
@@ -290,15 +303,17 @@
it 'Should update an inbound subscription' do
result = @subscriptions.update_inbound_subscription('c880c96f161f6220d4977b29b4bfc111', :notify_url => 'http://foobar1.com')
result.http.code.should eql '200'
result.data.should eql @inbound_subscription
+ FakeWeb.last_request.body.should eql "notifyURL=http%3A%2F%2Ffoobar1.com"
end
it 'Should update an outbound subscription' do
result = @subscriptions.update_outbound_subscription(@sender_address, :notify_url => 'http://foobar.com')
result.http.code.should eql '200'
result.data.should eql @outbound_subscription
+ FakeWeb.last_request.body.should eql "notifyURL=http%3A%2F%2Ffoobar.com"
end
end
describe 'Deleting subscriptions' do
before(:all) do