comcetera 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/comcetera.rb +13 -0
  3. data/spec/comcetera_spec.rb +3 -12
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -60,6 +60,19 @@ class Comcetera
60
60
  end
61
61
  new(:error_message=>"Timeout from Comcetera", :debug=>"#{self.retries} times no response within #{self.timeout} seconds")
62
62
  end
63
+
64
+ def setup_fakeweb_response(options={})
65
+ raise "FakeWeb is not defined. Please require 'fakeweb' and make sure the fakeweb rubygem is installed." unless defined?(FakeWeb)
66
+ raise ArgumentError.new("Option missing: :msisdn") unless options[:msisdn]
67
+ raise ArgumentError.new("Option missing: :result") unless options[:result]
68
+ options[:username]||= self.username
69
+ options[:password]||= self.password
70
+ FakeWeb.register_uri :get, "http://api.comcetera.com/npl?user=#{options[:username]}&pass=#{options[:password]}&msisdn=#{options[:msisdn]}", :body=> <<-MSG
71
+ QUERYOK
72
+ #{options[:msisdn]} #{options[:result]}
73
+ ENDBATCH
74
+ MSG
75
+ end
63
76
  end
64
77
 
65
78
  def ==(other)
@@ -1,20 +1,11 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- FakeWeb.register_uri :get, 'http://api.comcetera.com/npl?user=username&pass=password&msisdn=31612345678', :body=> <<-MSG
4
- QUERYOK
5
- 31612345678 12345
6
- ENDBATCH
7
- MSG
8
- FakeWeb.register_uri :get, 'http://api.comcetera.com/npl?user=username&pass=password&msisdn=31612345621', :body=> <<-MSG
9
- QUERYOK
10
- 31612345621 ERR21
11
- ENDBATCH
12
- MSG
13
-
14
3
  describe "Comcetera" do
15
4
  before(:all) do
16
5
  Comcetera.username = "username"
17
6
  Comcetera.password = "password"
7
+ Comcetera.setup_fakeweb_response(:msisdn=>31612345678, :result => 12345)
8
+ Comcetera.setup_fakeweb_response(:msisdn=>31612345621, :result => "ERR21")
18
9
  end
19
10
 
20
11
  describe "detect" do
@@ -42,7 +33,7 @@ describe "Comcetera" do
42
33
  @comcetera.msisdn.should == "31612345678"
43
34
  end
44
35
  end
45
-
36
+
46
37
  it "should return an instance with error code and debug info when no operator code is returned" do
47
38
  @comcetera = Comcetera.detect(31612345621)
48
39
  @comcetera.operator_code.should be_nil
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comcetera
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Wes Oldenbeuving
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-04 00:00:00 +02:00
18
+ date: 2010-11-22 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency