Sha256: aa237fd4726bebfd00b9c701325c7b68cd01a975ca601408ccf6de08b5fe52d4

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 KB

Contents

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

describe "Data247" do
  before(:all) do
    Data247.username = "username"
    Data247.password = "password"
    Data247.setup_fakeweb_response(:msisdn=>"31612345678", :status=>"OK", :result => 12345)
    Data247.setup_fakeweb_response(:msisdn=>"31612345621", :status => "ERROR")
  end

  describe "detect" do
    it "should return a new Data247 instance" do
      @data247 = Data247.detect(31612345678)
      @data247.should be_instance_of(Data247)
    end

    it "should retry after a timeout and return nil when it still fails" do
      3.times {Timeout.should_receive(:timeout).with(2).and_raise(Timeout::Error)}
      @data247 = Data247.detect(31612345678)
      @data247.should == Data247.new(:status=>"Timeout from Data24-7")
    end

    describe "the returned Data247 instance" do
      before(:each) do
        @data247 = Data247.detect("31612345678")
      end

      it "should contain the returned operator code" do
        @data247.operator_code.should == "12345"
      end

      it "should contain the returned msisdn" do
        @data247.msisdn.should == "31612345678"
      end
    end

    it "should return an instance with error code when no operator code is returned" do
      @data247 = Data247.detect(31612345621)
      @data247.operator_code.should be_nil
      @data247.status.should == "ERROR"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
data247-0.2.0 spec/data247_spec.rb
data247-0.1.0 spec/data247_spec.rb
data247-0.0.3 spec/data247_spec.rb
data247-0.0.2 spec/data247_spec.rb
data247-0.0.1 spec/data24_7_spec.rb