etapper 0.0.1 → 0.0.2
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.
- data/VERSION +1 -1
- data/etapper.gemspec +5 -4
- data/lib/etapper/client.rb +39 -18
- data/spec/authentication_spec.rb +4 -4
- data/spec/client_spec.rb +3 -3
- data/spec/proxying_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- data/spec/stub_driver.rb +1 -1
- metadata +2 -2
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.0. | 
| 1 | 
            +
            0.0.2
         | 
    
        data/etapper.gemspec
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            # Generated by jeweler
         | 
| 2 | 
            -
            # DO NOT EDIT THIS FILE
         | 
| 3 | 
            -
            # Instead, edit Jeweler::Tasks in Rakefile, and run  | 
| 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. | 
| 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{ | 
| 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 | 
            +
             | 
    
        data/lib/etapper/client.rb
    CHANGED
    
    | @@ -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 | 
            -
                     | 
| 69 | 
            -
             | 
| 70 | 
            -
                       | 
| 71 | 
            -
             | 
| 72 | 
            -
                       | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 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 | 
            -
                   | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 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 | 
            -
                   | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 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 | 
            -
             | 
| 96 | 
            -
                   | 
| 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
         | 
    
        data/spec/authentication_spec.rb
    CHANGED
    
    | @@ -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. | 
| 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. | 
| 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 " | 
| 128 | 
            +
                it "returns false on any failure" do
         | 
| 129 129 | 
             
                  @dummy.expects(:login).raises(MockFault, "Account Locked Out")
         | 
| 130 | 
            -
                   | 
| 130 | 
            +
                  client.connect.should be_false
         | 
| 131 131 | 
             
                end
         | 
| 132 132 | 
             
              end
         | 
| 133 133 |  | 
    
        data/spec/client_spec.rb
    CHANGED
    
    | @@ -17,15 +17,15 @@ describe "Bare client" do | |
| 17 17 | 
             
              end
         | 
| 18 18 |  | 
| 19 19 | 
             
              it "knows its username" do
         | 
| 20 | 
            -
                client.username.should == ' | 
| 20 | 
            +
                client.username.should == 'etapper_sandbox'
         | 
| 21 21 | 
             
              end
         | 
| 22 22 |  | 
| 23 23 | 
             
              it "knows its password" do
         | 
| 24 | 
            -
                client.password.should == ' | 
| 24 | 
            +
                client.password.should == 'mypass1234'
         | 
| 25 25 | 
             
              end
         | 
| 26 26 |  | 
| 27 27 | 
             
              it "lets you set a password" do
         | 
| 28 | 
            -
                lambda{client.password = ' | 
| 28 | 
            +
                lambda{client.password = 'mypass1234'}.should_not raise_error
         | 
| 29 29 | 
             
              end
         | 
| 30 30 |  | 
| 31 31 | 
             
              it "knows if it's connected" do
         | 
    
        data/spec/proxying_spec.rb
    CHANGED
    
    | @@ -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 = ' | 
| 7 | 
            -
                @client.password = ' | 
| 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
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -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"] = ' | 
| 11 | 
            -
            ENV["ETAPPER_PASSWORD"] = ' | 
| 10 | 
            +
            ENV["ETAPPER_USERNAME"] = 'etapper_sandbox'
         | 
| 11 | 
            +
            ENV["ETAPPER_PASSWORD"] = 'mypass1234'
         | 
| 12 12 |  | 
| 13 13 | 
             
            require 'etapper'
         | 
| 14 14 | 
             
            require 'stub_driver'
         | 
    
        data/spec/stub_driver.rb
    CHANGED
    
    | @@ -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(' | 
| 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. | 
| 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:  | 
| 12 | 
            +
            date: 2010-01-21 00:00:00 -05:00
         | 
| 13 13 | 
             
            default_executable: 
         | 
| 14 14 | 
             
            dependencies: 
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency 
         |