Sha256: 5b561a151cf58b24ad9960383f508a63753ffc5ddd2bb9c1c728b984c44e3f84
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') FakeWeb.register_uri :get, 'http://api.comcetera.com/npl?user=username&pass=password&msisdn=31612345678', :body=> <<-MSG QUERYOK 31612345678 12345 ENDBATCH MSG FakeWeb.register_uri :get, 'http://api.comcetera.com/npl?user=username&pass=password&msisdn=31612345621', :body=> <<-MSG QUERYOK 31612345621 ERR21 ENDBATCH MSG describe "Comcetera" do before(:all) do Comcetera.username = "username" Comcetera.password = "password" end describe "detect" do it "should return a new Comcetera instance" do @comcetera = Comcetera.detect(31612345678) @comcetera.should be_instance_of(Comcetera) 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)} @comcetera = Comcetera.detect(31612345678) @comcetera.should == Comcetera.new(:error_message=>"Timeout from Comcetera", :debug=>"2 times no response within 2 seconds") end describe "the returned Comcetera instance" do before(:each) do @comcetera = Comcetera.detect(31612345678) end it "should contain the returned operator code" do @comcetera.operator_code.should == "12345" end it "should contain the returned msisdn" do @comcetera.msisdn.should == "31612345678" end end it "should return an instance with error code and debug info when no operator code is returned" do @comcetera = Comcetera.detect(31612345621) @comcetera.operator_code.should be_nil @comcetera.error_code.should == "ERR21" @comcetera.error_message.should == "Facility not supported" @comcetera.debug.should == <<-MSG QUERYOK 31612345621 ERR21 ENDBATCH MSG end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comcetera-1.0.0 | spec/comcetera_spec.rb |