etapper 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{etapper}
8
- s.version = "0.0.0"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Stephen Eley"]
12
- s.date = %q{2009-10-16}
12
+ s.date = %q{2010-01-21}
13
13
  s.email = %q{seley@aarweb.org}
14
14
  s.extra_rdoc_files = [
15
15
  "README.rdoc"
@@ -709,3 +709,4 @@ Gem::Specification.new do |s|
709
709
  s.add_dependency(%q<rspec>, [">= 0"])
710
710
  end
711
711
  end
712
+
@@ -65,35 +65,56 @@ module Etapper
65
65
  unless connected?
66
66
  raise ConnectionError, "Username is required!" unless username
67
67
  raise ConnectionError, "Password is required!" unless password
68
- result = @driver.login(@username, @password)
69
- if result == ''
70
- @connected = true
71
- else # May need a redirect
72
- newurl = URI.parse(result)
73
- newurl.query = nil # Strip off the '?wsdl' parameter at the end
74
- driver.endpoint_url = newurl.to_s
75
- @connected = connect
68
+ begin
69
+ result = driver.login(@username, @password)
70
+ if result == ''
71
+ @connected = true
72
+ else # May need a redirect
73
+ newurl = URI.parse(result)
74
+ newurl.query = nil # Strip off the '?wsdl' parameter at the end
75
+ driver.endpoint_url = newurl.to_s
76
+ @connected = connect
77
+ end
78
+ rescue # We just can't connect right now, it seems
79
+ @connected = false
80
+ false
76
81
  end
77
82
  end
78
83
  end
79
84
 
80
85
  def disconnect
81
- driver.logout if connected?
82
- @connected = false
83
- true
86
+ begin
87
+ driver.logout if connected?
88
+ true
89
+ rescue # We don't care what went wrong, we just need to know we're not connected
90
+ false
91
+ ensure
92
+ @connected = false
93
+ end
84
94
  end
85
95
 
86
96
  # Our primary proxy. Sends anything we don't know about to the driver for processing.
87
97
  def method_missing(method, *params)
88
98
  raise NoMethodError if method == :driver # This is protected for a reason
89
- unless connected?
90
- if autoconnect
91
- connect
92
- else
93
- raise ConnectionError, "Autoconnect is disabled! Use the 'connect' method before making any API calls."
99
+ tries = 0
100
+ begin
101
+ unless connected?
102
+ if autoconnect
103
+ connect
104
+ else
105
+ raise ConnectionError, "Autoconnect is disabled! Use the 'connect' method before making any API calls."
106
+ end
94
107
  end
95
- end
96
- driver.send(method, *params)
108
+ driver.send(method, *params)
109
+ rescue StandardError, SocketError => e
110
+ # Try three times, waiting a few seconds and forcing login again each time
111
+ while tries < 3
112
+ sleep (tries += 1)
113
+ disconnect
114
+ retry
115
+ end
116
+ raise # We give up
117
+ end
97
118
  end
98
119
 
99
120
  protected
@@ -92,12 +92,12 @@ describe "Authentication" do
92
92
  end
93
93
 
94
94
  it "doesn't try to connect without a username" do
95
- client.expects(:username).returns(nil)
95
+ client.stubs(:username).returns(nil)
96
96
  lambda {client.fakeMethod}.should raise_error(Etapper::ConnectionError, "Username is required!")
97
97
  end
98
98
 
99
99
  it "doesn't try to connect without a password" do
100
- client.expects(:password).returns(nil)
100
+ client.stubs(:password).returns(nil)
101
101
  lambda {client.fakeMethod}.should raise_error(Etapper::ConnectionError, "Password is required!")
102
102
  end
103
103
 
@@ -125,9 +125,9 @@ describe "Authentication" do
125
125
  client.connect
126
126
  end
127
127
 
128
- it "bombs out on any failure" do
128
+ it "returns false on any failure" do
129
129
  @dummy.expects(:login).raises(MockFault, "Account Locked Out")
130
- lambda{client.connect}.should raise_error
130
+ client.connect.should be_false
131
131
  end
132
132
  end
133
133
 
@@ -17,15 +17,15 @@ describe "Bare client" do
17
17
  end
18
18
 
19
19
  it "knows its username" do
20
- client.username.should == 'etapper_johntest'
20
+ client.username.should == 'etapper_sandbox'
21
21
  end
22
22
 
23
23
  it "knows its password" do
24
- client.password.should == 'mypass'
24
+ client.password.should == 'mypass1234'
25
25
  end
26
26
 
27
27
  it "lets you set a password" do
28
- lambda{client.password = 'mypass'}.should_not raise_error
28
+ lambda{client.password = 'mypass1234'}.should_not raise_error
29
29
  end
30
30
 
31
31
  it "knows if it's connected" do
@@ -3,8 +3,8 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe "Method Proxying" do
4
4
  before(:each) do
5
5
  @client = Etapper::Client.instance
6
- @client.username = 'etapper_johntest'
7
- @client.password = 'mypass'
6
+ @client.username = 'etapper_sandbox'
7
+ @client.password = 'mypass1234'
8
8
  end
9
9
 
10
10
  it "attempts to call methods on the driver if they aren't defined by the client" do
@@ -7,8 +7,8 @@ class TestError < StandardError; end
7
7
  $:.unshift(File.dirname(__FILE__) + '/../lib')
8
8
  $:.unshift(File.dirname(__FILE__))
9
9
 
10
- ENV["ETAPPER_USERNAME"] = 'etapper_johntest'
11
- ENV["ETAPPER_PASSWORD"] = 'mypass'
10
+ ENV["ETAPPER_USERNAME"] = 'etapper_sandbox'
11
+ ENV["ETAPPER_PASSWORD"] = 'mypass1234'
12
12
 
13
13
  require 'etapper'
14
14
  require 'stub_driver'
@@ -28,7 +28,7 @@ share_as :MockDriver do
28
28
  @dummy = stub('driver') do
29
29
  # stubs(:endpoint_url).returns('### ORIGINAL URL ###')
30
30
  # # Our good and bad logins
31
- stubs(:login).with('etapper_johntest','mypass').returns('')
31
+ stubs(:login).with('etapper_sandbox','mypass1234').returns('')
32
32
  stubs(:login).with('etapper_jilltest','anotherpass').returns('http://redirect.etapestry.com/v2messaging/service?wsdl')
33
33
  # stubs(:login).with('etapper_carltest','anotherpass').raises(MockFault, 'Account Password Expired')
34
34
  # stubs(:login).with('etapper_fredtest','athirdpass').raises(MockFault, 'Account Locked Out')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Eley
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-13 00:00:00 -05:00
12
+ date: 2010-01-21 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency