Skip to content

Commit

Permalink
email specs working
Browse files Browse the repository at this point in the history
  • Loading branch information
nofxx committed Aug 17, 2008
1 parent 2cc7ca1 commit c87d22b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 37 deletions.
64 changes: 28 additions & 36 deletions spec/activesms/email_spec.rb
@@ -1,6 +1,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')


class Noter < ActiveSms::Base
def emaio
@delivery = :email
Expand All @@ -22,47 +21,40 @@ def emaio
Sms2Email.should_receive(:deliver_sms_message).with("5555555555@tim.com.br", "hi", "noreply@domain.com").and_return(true)
Noter.deliver(sms)
end


it "should determine a correct email address" do
Noter.get_sms_address('5543214321', 'tim').should eql('5543214321@tim.com.br')
#@email.get_sms_address('5543214321', 'oi').should eql('5543214321@sms.oi.com.br')
end




describe "Instantiated" do
before(:each) do
@email = Noter.create_emaio
@email = Class.new { include ActiveSms::Email }.new
# @email = Aa.new
end

it "should be valid" do
violated unless @email
end
end



#
# it "should clean the number" do
# @email.get_sms_address('5-543-2=14321', 'tim').should eql('5543214321@tim.com.br')
# @email.get_sms_address('55g432g14fd321', 'oi').should eql('5543214321@sms.oi.com.br')
# end

it "should determine a correct email address" do
@email.get_sms_address('5543214321', 'tim').should eql('5543214321@tim.com.br')
@email.get_sms_address('5543214321', 'oi').should eql('5543214321@sms.oi.com.br')
end

it "should clean the number" do
@email.get_sms_address('5-543-2=14321', 'tim').should eql('5543214321@tim.com.br')
@email.get_sms_address('55g432g14fd321', 'oi').should eql('5543214321@sms.oi.com.br')
end

# it "should throw an error if the carrier is not known" do
# lambda {@email.get_sms_address('5543214321', 'nofxx-telecom')}.should raise_error(ActiveSms::CarrierException)
# end
#
# it "should throw an error if the carrier is blank" do
# lambda {@email.get_sms_address('5543214321', '')}.should raise_error(ActiveSms::CarrierException)
# end
#
# describe "Email2Sms" do
# it "should throw an error if the carrier is blank" do
# @sms = ActiveSms::Sms.new
# lambda {@email.deliver(@sms)}.should raise_error(ActiveSms::CarrierException)
# end
# end
#

it "should throw an error if the carrier is not known" do
lambda {@email.get_sms_address('5543214321', 'nofxx-telecom')}.should raise_error(ActiveSms::CarrierException)
end

it "should throw an error if the carrier is blank" do
lambda {@email.get_sms_address('5543214321', '')}.should raise_error(ActiveSms::CarrierException)
end

describe "Email2Sms" do
it "should throw an error if the carrier is blank" do
@sms = ActiveSms::Sms.new
lambda {@email.email_deliver(@sms)}.should raise_error(ActiveSms::CarrierException)
end
end
end
end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Expand Up @@ -9,7 +9,7 @@
$:.unshift(File.dirname(__FILE__) + '/../lib')
$:.unshift(File.dirname(__FILE__) + '/../lib/activesms')
$:.unshift(File.dirname(__FILE__) + '/../lib/activesms/connection_adapters')
# require 'activesms/sms'
require 'activesms/sms'
require 'activesms'
#
# require 'activesms/connection_adapters/abstract_adapter'
Expand Down

0 comments on commit c87d22b

Please sign in to comment.