conduit 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d46f2ac30b74dabd934e5f184565479ff5e20d4d
4
- data.tar.gz: f75ba0ec8e8e1c258d57e92a7682a5f5426ee70d
3
+ metadata.gz: db869d12c0bfe0b84b990b04a554c601a4e2730a
4
+ data.tar.gz: 0fc937f569573df1b4ea36080d4d37458546e9d4
5
5
  SHA512:
6
- metadata.gz: 450fbc11d0537d048d7fd60885dc2873c1abab99557e3b938f90d927b9a3eb54ae048d639195724268b7ab7622108f6ce6bdb7995b2114b4e67f9e67436dc014
7
- data.tar.gz: 1c72077fc8dcb18d3069e5aa2028c60005f6f41c74456c279b8895422da7add56bcd5e661c3380880e677e945af4aca49918d936e8b76a95b9728c68e1b75aa5
6
+ metadata.gz: ba53aa6aaee8504bfb0152e277dc6d11679182eaab78885725a30249123c0d0d8e063273811a6900524032f33aea1d4c4b21023531badfc04113517f3b1f36b1
7
+ data.tar.gz: 5ea5bfe00dd30d2a7106b2356c1d945ae16452288e4dec810cbed34f1ee17c73ce0bfe8c81ba7420d1a0d59a41eaa874d921aa948c526ea85fdf6e1e5994df2f
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
1
  require "bundler/gem_tasks"
2
-
@@ -1,37 +1,34 @@
1
1
  $LOAD_PATH.unshift File.dirname(__FILE__)
2
2
 
3
- require 'conduit/configuration'
3
+ require "conduit/configuration"
4
4
 
5
5
  module Conduit
6
-
7
6
  # Autoload the Conduit base classes
8
7
  # NOTE: Autoloading should be
9
8
  # concurrency-safe
10
9
  #
11
- autoload :Storage, 'conduit/storage'
12
- autoload :Util, 'conduit/util'
13
- autoload :ApiResponse, 'conduit/api_response'
14
- autoload :ConnectionError, 'conduit/connection_error'
15
- autoload :TimeOut, 'conduit/time_out'
16
- autoload :Error, 'conduit/error'
10
+ autoload :Storage, "conduit/storage"
11
+ autoload :Util, "conduit/util"
12
+ autoload :ApiResponse, "conduit/api_response"
13
+ autoload :ConnectionError, "conduit/connection_error"
14
+ autoload :TimeOut, "conduit/time_out"
15
+ autoload :Error, "conduit/error"
17
16
 
18
17
  module Core
19
-
20
18
  # Autoload the Conduit::Core base classes
21
19
  # NOTE: Autoloading should be
22
20
  # concurrency-safe
23
21
  #
24
- autoload :Connection, 'conduit/core/connection'
25
- autoload :Render, 'conduit/core/render'
26
- autoload :Decorator, 'conduit/core/decorator'
27
- autoload :RequestMocker, 'conduit/core/request_mocker'
28
- autoload :Action, 'conduit/core/action'
29
- autoload :Parser, 'conduit/core/parser'
30
- autoload :Driver, 'conduit/core/driver'
22
+ autoload :Connection, "conduit/core/connection"
23
+ autoload :Render, "conduit/core/render"
24
+ autoload :Decorator, "conduit/core/decorator"
25
+ autoload :RequestMocker, "conduit/core/request_mocker"
26
+ autoload :Action, "conduit/core/action"
27
+ autoload :Parser, "conduit/core/parser"
28
+ autoload :Driver, "conduit/core/driver"
31
29
  end
32
30
 
33
31
  module Driver
34
-
35
32
  class << self
36
33
  # Store a list of available drivers
37
34
  #
@@ -56,8 +53,6 @@ module Conduit
56
53
  end
57
54
  end
58
55
  end
59
-
60
56
  end
61
57
  end
62
-
63
58
  end
@@ -16,7 +16,7 @@ module Conduit
16
16
  It will add the base `action`, `decorator`, `parser` and `request_mocker`
17
17
  files along with generators and other basic files.
18
18
  LONGDESC
19
- def generate_driver driver_name
19
+ def generate_driver(driver_name)
20
20
  @driver_name = driver_name
21
21
  @dasherized_name = ActiveSupport::Inflector.dasherize driver_name
22
22
  @classified_name = ActiveSupport::Inflector.classify driver_name
@@ -62,7 +62,7 @@ module Conduit
62
62
 
63
63
  Bundler.with_clean_env do
64
64
  inside(@base_path) do
65
- full_command = %Q["#{Gem.ruby}" "#{_bundle_command}" install]
65
+ full_command = %("#{Gem.ruby}" "#{_bundle_command}" install)
66
66
  run(full_command)
67
67
  end
68
68
  end
@@ -12,7 +12,7 @@ module Conduit
12
12
  @configuration ||= Configuration.new
13
13
  end
14
14
 
15
- def self.configure(&block)
15
+ def self.configure
16
16
  yield configuration
17
17
  end
18
18
 
@@ -20,7 +20,7 @@ module Conduit
20
20
  attr_accessor :storage_config, :driver_paths
21
21
 
22
22
  def storage
23
- path = File.join(__dir__, '../', 'tmp', 'conduit')
23
+ path = File.join(__dir__, "../", "tmp", "conduit")
24
24
  @storage_config ||= { provider: :file, file_path: path }
25
25
  end
26
26
 
@@ -12,17 +12,16 @@
12
12
  # => action.perform
13
13
  #
14
14
 
15
- require 'active_support'
16
- require 'active_support/inflector'
17
- require 'active_support/core_ext/object'
18
- require 'forwardable'
19
- require 'ostruct'
20
- require 'set'
15
+ require "active_support"
16
+ require "active_support/inflector"
17
+ require "active_support/core_ext/object"
18
+ require "forwardable"
19
+ require "ostruct"
20
+ require "set"
21
21
 
22
22
  module Conduit
23
23
  module Core
24
24
  class Action
25
-
26
25
  def self.inherited(base)
27
26
  base.send :include, Conduit::Core::Connection
28
27
  base.send :include, Conduit::Core::Render
@@ -41,7 +40,6 @@ module Conduit
41
40
  end
42
41
 
43
42
  module ClassMethods
44
-
45
43
  attr_accessor :_action_path
46
44
 
47
45
  # Set required attributes
@@ -74,7 +72,6 @@ module Conduit
74
72
  def attributes
75
73
  @attributes ||= Set.new
76
74
  end
77
-
78
75
  end
79
76
 
80
77
  module InstanceMethods
@@ -119,14 +116,14 @@ module Conduit
119
116
  # Can be overriden per class.
120
117
  #
121
118
  def view_path
122
- File.join(File.dirname(action_path), 'views')
119
+ File.join(File.dirname(action_path), "views")
123
120
  end
124
121
 
125
122
  # Return the rendered view
126
123
  #
127
124
  def view
128
125
  tpl = self.class.name.demodulize
129
- .underscore.downcase
126
+ .underscore.downcase
130
127
  render(tpl)
131
128
  end
132
129
 
@@ -169,7 +166,7 @@ module Conduit
169
166
  def validate!(options)
170
167
  missing_keys = (requirements.to_a - options.keys)
171
168
  either_keys = requirements.select { |key| key.is_a?(Array) }
172
- missing_keys.reject! { |key| either_keys.any? { |either| (either & options.keys).present? }}
169
+ missing_keys.reject! { |_key| either_keys.any? { |either| (either & options.keys).present? } }
173
170
  if missing_keys.any?
174
171
  raise ArgumentError,
175
172
  "Missing keys: #{missing_keys.join(', ')}"
@@ -220,7 +217,7 @@ module Conduit
220
217
  # Indicates whether the request should be mocked or not.
221
218
  #
222
219
  def mock_mode?
223
- @options.has_key?(:mock_status) && (!@options[:mock_status].nil? && !@options[:mock_status].empty?)
220
+ @options.key?(:mock_status) && (!@options[:mock_status].nil? && !@options[:mock_status].empty?)
224
221
  end
225
222
  end
226
223
  end
@@ -3,9 +3,9 @@
3
3
  # communication rom Conduit to a remote host.
4
4
  #
5
5
 
6
- require 'conduit/version'
7
- require 'forwardable'
8
- require 'excon'
6
+ require "conduit/version"
7
+ require "forwardable"
8
+ require "excon"
9
9
 
10
10
  module Conduit
11
11
  module Core
@@ -16,7 +16,6 @@ module Conduit
16
16
  end
17
17
 
18
18
  module ClassMethods
19
-
20
19
  # Define a remote_url
21
20
  #
22
21
  # e.g.
@@ -25,7 +24,6 @@ module Conduit
25
24
  def remote_url(host = nil)
26
25
  @remote_url ||= host
27
26
  end
28
-
29
27
  end
30
28
 
31
29
  module InstanceMethods
@@ -48,7 +46,7 @@ module Conduit
48
46
  #
49
47
  def request(params, &block)
50
48
  params[:headers] ||= {}
51
- params[:headers]['User-Agent'] ||= "conduit/#{Conduit::VERSION}"
49
+ params[:headers]["User-Agent"] ||= "conduit/#{Conduit::VERSION}"
52
50
  connection.request(params, &block)
53
51
  rescue Excon::Errors::Timeout => timeout
54
52
  raise(Conduit::TimeOut, timeout.message)
@@ -82,9 +80,7 @@ module Conduit
82
80
  def connection(**params)
83
81
  @excon ||= Excon.new(remote_url, params)
84
82
  end
85
-
86
83
  end
87
-
88
84
  end
89
85
  end
90
86
  end
@@ -10,8 +10,8 @@
10
10
  # for the view.
11
11
  #
12
12
 
13
- require 'delegate'
14
- require 'forwardable'
13
+ require "delegate"
14
+ require "forwardable"
15
15
 
16
16
  module Conduit
17
17
  module Core
@@ -17,14 +17,13 @@
17
17
  # => end
18
18
  #
19
19
 
20
- require 'set'
20
+ require "set"
21
21
 
22
22
  module Conduit
23
23
  module Core
24
24
  module Driver
25
-
26
25
  def self.extended(base)
27
- base.instance_variable_set('@_driver_path',
26
+ base.instance_variable_set("@_driver_path",
28
27
  File.dirname(caller.first[/^[^:]+/]))
29
28
  end
30
29
 
@@ -72,8 +71,8 @@ module Conduit
72
71
  # => action :purchase
73
72
  #
74
73
  def action(action_name)
75
- require File.join(@_driver_path, 'actions', action_name.to_s)
76
- require File.join(@_driver_path, 'parsers', action_name.to_s)
74
+ require File.join(@_driver_path, "actions", action_name.to_s)
75
+ require File.join(@_driver_path, "parsers", action_name.to_s)
77
76
  actions << action_name
78
77
  end
79
78
 
@@ -116,7 +115,7 @@ module Conduit
116
115
  # => "fusion"
117
116
  #
118
117
  def driver_name
119
- self.name.demodulize.underscore.downcase
118
+ name.demodulize.underscore.downcase
120
119
  end
121
120
 
122
121
  # Returns the current set of required attributes
@@ -130,7 +129,6 @@ module Conduit
130
129
  def optional_attribute_set
131
130
  @optional_attribute_set ||= Set.new
132
131
  end
133
-
134
132
  end
135
133
  end
136
134
  end
@@ -4,10 +4,10 @@
4
4
  # predictably consumed.
5
5
  #
6
6
 
7
- require 'active_support'
8
- require 'active_support/core_ext/object'
9
- require 'forwardable'
10
- require 'set'
7
+ require "active_support"
8
+ require "active_support/core_ext/object"
9
+ require "forwardable"
10
+ require "set"
11
11
 
12
12
  module Conduit
13
13
  module Core
@@ -15,7 +15,6 @@ module Conduit
15
15
  extend Forwardable
16
16
 
17
17
  class << self
18
-
19
18
  # Define an attribute that will be publically exposed
20
19
  # when dealing with conduit responses.
21
20
  #
@@ -29,7 +28,6 @@ module Conduit
29
28
  def attributes
30
29
  @attributes ||= Set.new
31
30
  end
32
-
33
31
  end
34
32
 
35
33
  def_delegator :'self.class', :attributes
@@ -47,14 +45,14 @@ module Conduit
47
45
  # Should be overwritten by parser implementation.
48
46
  #
49
47
  def response_status
50
- raise NoMethodError, 'Please define response_status in your parser.'
48
+ raise NoMethodError, "Please define response_status in your parser."
51
49
  end
52
50
 
53
51
  # Default response error container.
54
52
  # Should be overwritten by parser implementation.
55
53
  #
56
54
  def response_errors
57
- raise NoMethodError, 'Please define response_errors in your parser.'
55
+ raise NoMethodError, "Please define response_errors in your parser."
58
56
  end
59
57
  end
60
58
  end
@@ -5,19 +5,18 @@
5
5
  # methods to be of any use.
6
6
  #
7
7
 
8
- require 'tilt'
8
+ require "tilt"
9
9
 
10
10
  module Conduit
11
11
  module Core
12
12
  module Render
13
-
14
13
  # Create instance variables, any of these can
15
14
  # be overriden within the including class.
16
15
  #
17
16
  # view_path: Location where the view files are stored
18
17
  # view_context: Object that contains the variables used in the template
19
18
  #
20
- def self.included(base)
19
+ def self.included(_base)
21
20
  attr_accessor :view_path, :view_context
22
21
  end
23
22
 
@@ -30,7 +29,7 @@ module Conduit
30
29
  # => render :purchase
31
30
  #
32
31
  def render(file, layout: true)
33
- raise ViewPathNotDefined, '' unless view_path
32
+ raise ViewPathNotDefined, "" unless view_path
34
33
  layout ? render_with_layout(file) : render_template(file)
35
34
  end
36
35
 
@@ -63,7 +62,6 @@ module Conduit
63
62
  end
64
63
 
65
64
  class ViewPathNotDefined < StandardError; end
66
-
67
65
  end
68
66
  end
69
67
  end
@@ -10,9 +10,9 @@
10
10
  # the action with its value being the returned status.
11
11
  #
12
12
 
13
- require 'erb'
14
- require 'excon'
15
- require 'tilt'
13
+ require "erb"
14
+ require "excon"
15
+ require "tilt"
16
16
 
17
17
  module Conduit
18
18
  module Core
@@ -29,7 +29,7 @@ module Conduit
29
29
  #
30
30
  def mock
31
31
  Excon.defaults[:mock] = true
32
- Excon.stub({}, { body: response, status: @http_status })
32
+ Excon.stub({}, body: response, status: @http_status)
33
33
  end
34
34
 
35
35
  # Ends mocking, override if using something different than
@@ -59,7 +59,7 @@ module Conduit
59
59
  # Directory where fixtures are stored.
60
60
  #
61
61
  def fixtures_path
62
- raise NoMethodError, 'Please define fixtures_path in your request mocker.'
62
+ raise NoMethodError, "Please define fixtures_path in your request mocker."
63
63
  end
64
64
 
65
65
  def fixture
@@ -5,7 +5,7 @@ module Conduit
5
5
  end
6
6
 
7
7
  def to_s
8
- self.message
8
+ message
9
9
  end
10
10
 
11
11
  def as_json(options = nil)
@@ -5,12 +5,11 @@
5
5
  # TODO: Support multiple storage providers
6
6
  #
7
7
 
8
- require 'conduit/storage/aws'
9
- require 'conduit/storage/file'
8
+ require "conduit/storage/aws"
9
+ require "conduit/storage/file"
10
10
 
11
11
  module Conduit
12
12
  module Storage
13
-
14
13
  # Wrapper around the configuration object
15
14
  #
16
15
  # Configurable in:
@@ -32,6 +31,5 @@ module Conduit
32
31
  #
33
32
  storage_provider_module = const_get(provider.to_s.humanize)
34
33
  extend storage_provider_module
35
-
36
34
  end
37
35
  end
@@ -5,7 +5,7 @@
5
5
  # TODO: Support multiple storage providers
6
6
  #
7
7
 
8
- require 'aws-sdk'
8
+ require "aws-sdk"
9
9
 
10
10
  module Conduit
11
11
  module Storage
@@ -18,7 +18,6 @@ module Conduit
18
18
  end
19
19
 
20
20
  module ClassMethods
21
-
22
21
  # Configure AWS::S3 with credentials if provided, else, assume
23
22
  # IAM will provide them.
24
23
  #
@@ -87,9 +86,7 @@ module Conduit
87
86
  rescue AWS::S3::Errors::NoSuchKey
88
87
  nil
89
88
  end
90
-
91
89
  end
92
-
93
90
  end
94
91
  end
95
92
  end
@@ -5,13 +5,12 @@
5
5
  # TODO: Support multiple storage providers
6
6
  #
7
7
 
8
- require 'fileutils'
9
- require 'pathname'
8
+ require "fileutils"
9
+ require "pathname"
10
10
 
11
11
  module Conduit
12
12
  module Storage
13
13
  module File
14
-
15
14
  #
16
15
  # TODO: Rename this, I originally used file,
17
16
  # not considering the fact that it's
@@ -23,7 +22,6 @@ module Conduit
23
22
  end
24
23
 
25
24
  module ClassMethods
26
-
27
25
  # Return a Pathname object for the
28
26
  # configured file path
29
27
  #
@@ -40,7 +38,7 @@ module Conduit
40
38
  full_path = storage_path.join(key)
41
39
  FileUtils.mkdir_p(::File.dirname(full_path))
42
40
 
43
- ::File.open(full_path, 'wb') do |f|
41
+ ::File.open(full_path, "wb") do |f|
44
42
  f.write(content)
45
43
  end
46
44
  end
@@ -66,9 +64,7 @@ module Conduit
66
64
  rescue Errno::ENOENT, Errno::EPERM
67
65
  nil
68
66
  end
69
-
70
67
  end
71
-
72
68
  end
73
69
  end
74
70
  end
@@ -1,6 +1,5 @@
1
1
  module Conduit
2
2
  module Util
3
-
4
3
  # Instantiate the action class with options
5
4
  #
6
5
  # returns:
@@ -12,13 +11,12 @@ module Conduit
12
11
  end
13
12
 
14
13
  def self.find_driver!(*args)
15
- driver = args.map(&:to_s).map(&:camelize).join('::')
14
+ driver = args.map(&:to_s).map(&:camelize).join("::")
16
15
  Conduit::Driver.const_get(driver)
17
16
  rescue NameError => error
18
- message = "Unable to find driver with arguments: #{args.join ','}. " +
17
+ message = "Unable to find driver with arguments: #{args.join ','}. " \
19
18
  "Expected #{error.name} to be implemented"
20
- raise NameError.new(message)
19
+ raise NameError, message
21
20
  end
22
-
23
21
  end
24
22
  end
@@ -1,3 +1,3 @@
1
1
  module Conduit
2
- VERSION = '1.1.1'
2
+ VERSION = "1.1.2".freeze
3
3
  end
@@ -1,28 +1,27 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  shared_examples_for Conduit::Core::Action do
4
-
5
- let(:request) { read_support_file('xml/xml_request.xml') }
6
- let(:modified_request) { read_support_file('xml/xml_modified_request.xml') }
7
- let(:response) { read_support_file('xml/xml_response.xml') }
4
+ let(:request) { read_support_file("xml/xml_request.xml") }
5
+ let(:modified_request) { read_support_file("xml/xml_modified_request.xml") }
6
+ let(:response) { read_support_file("xml/xml_response.xml") }
8
7
 
9
8
  subject do
10
9
  described_class.new(request_attributes)
11
10
  end
12
11
 
13
- context 'without an instance' do
12
+ context "without an instance" do
14
13
  its(:class) { should respond_to(:remote_url) }
15
14
  its(:class) { should respond_to(:required_attributes) }
16
15
  its(:class) { should respond_to(:optional_attributes) }
17
16
 
18
- describe '.requirements' do
19
- it 'returns an array of required attributes' do
17
+ describe ".requirements" do
18
+ it "returns an array of required attributes" do
20
19
  subject.class.requirements.should == [:foo, :bar, :baz, [:either, :or]].to_set
21
20
  end
22
21
  end
23
22
 
24
- describe '.attributes' do
25
- it 'returns an array of known attributes' do
23
+ describe ".attributes" do
24
+ it "returns an array of known attributes" do
26
25
  subject.class.requirements.should == [:foo, :bar, :baz, [:either, :or]].to_set
27
26
  end
28
27
  end
@@ -43,14 +42,14 @@ shared_examples_for Conduit::Core::Action do
43
42
  end
44
43
  end
45
44
 
46
- context 'with an instance' do
47
- describe '#attributes_with_values' do
48
- context 'with optional attribute not set' do
45
+ context "with an instance" do
46
+ describe "#attributes_with_values" do
47
+ context "with optional attribute not set" do
49
48
  let (:attrs) { request_attributes.merge(buz: nil, or: nil) }
50
49
  its(:attributes_with_values) { should include(attrs) }
51
50
  end
52
51
 
53
- context 'with optional attribute set' do
52
+ context "with optional attribute set" do
54
53
  let (:attrs) { request_attributes.merge(buz: "value for buz", or: nil) }
55
54
  subject { described_class.new(attrs) }
56
55
  its(:attributes_with_values) { should include(attrs) }
@@ -61,26 +60,26 @@ shared_examples_for Conduit::Core::Action do
61
60
  end
62
61
  end
63
62
 
64
- describe '#view' do
63
+ describe "#view" do
65
64
  before do
66
65
  Excon.stub({}, body: request, status: 200)
67
66
  end
68
67
 
69
- it 'returns a rendered view for an action' do
70
- a = subject.view.gsub(/\s+/, '')
71
- b = request.gsub(/\s+/, '')
68
+ it "returns a rendered view for an action" do
69
+ a = subject.view.gsub(/\s+/, "")
70
+ b = request.gsub(/\s+/, "")
72
71
  a.should == b
73
72
  end
74
73
  end
75
74
 
76
- describe '#view_context' do
77
- context 'without decorator class' do
78
- it 'returns an instance of core decorator' do
75
+ describe "#view_context" do
76
+ context "without decorator class" do
77
+ it "returns an instance of core decorator" do
79
78
  subject.view_context.should be_a_kind_of(Conduit::Core::Decorator)
80
79
  end
81
80
  end
82
81
 
83
- context 'with decorator class' do
82
+ context "with decorator class" do
84
83
  let(:driver) { subject.class.name.deconstantize.demodulize }
85
84
  let(:action) { subject.class.name.demodulize }
86
85
 
@@ -114,31 +113,30 @@ shared_examples_for Conduit::Core::Action do
114
113
  Excon.stub({}, body: modified_request, status: 200)
115
114
  end
116
115
 
117
- it 'returns an instance of core decorator' do
118
- subject.view_context.should be_a_kind_of(Conduit.const_get(driver)::Decorators::const_get("#{action}Decorator"))
116
+ it "returns an instance of core decorator" do
117
+ subject.view_context.should be_a_kind_of(Conduit.const_get(driver)::Decorators.const_get("#{action}Decorator"))
119
118
  end
120
119
 
121
- it 'returns a new rendered view for an action' do
122
- a = subject.view.gsub(/\s+/, '')
123
- b = modified_request.gsub(/\s+/, '')
120
+ it "returns a new rendered view for an action" do
121
+ a = subject.view.gsub(/\s+/, "")
122
+ b = modified_request.gsub(/\s+/, "")
124
123
  a.should == b
125
124
  end
126
125
  end
127
126
  end
128
127
 
129
- describe '#perform' do
128
+ describe "#perform" do
130
129
  before { Excon.stub({}, body: response, status: 200) }
131
130
 
132
- it 'returns a response wrapper' do
131
+ it "returns a response wrapper" do
133
132
  subject.perform.should be_a_kind_of(Conduit::ApiResponse)
134
133
  end
135
134
 
136
- it 'should return the raw_content' do
135
+ it "should return the raw_content" do
137
136
  subject.perform.body.should_not be_nil
138
137
  end
139
138
  end
140
139
  end
141
-
142
140
  end
143
141
 
144
142
  describe Conduit::Driver::MyDriver::Foo do
@@ -1,40 +1,37 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  shared_examples_for Conduit::Core::Driver do
4
-
5
- context 'without an instance' do
6
- describe '.credentials' do
7
- it 'returns an array of required credentials' do
4
+ context "without an instance" do
5
+ describe ".credentials" do
6
+ it "returns an array of required credentials" do
8
7
  subject.credentials.should == [:username, :password].to_set
9
8
  end
10
9
  end
11
10
 
12
- describe '.actions' do
13
- it 'returns an array of known action' do
11
+ describe ".actions" do
12
+ it "returns an array of known action" do
14
13
  subject.actions.should == [:foo].to_set
15
14
  end
16
15
  end
17
16
 
18
- describe '.permitted_attributes' do
19
- it 'returns the union of required and optional attributes' do
17
+ describe ".permitted_attributes" do
18
+ it "returns the union of required and optional attributes" do
20
19
  subject.permitted_attributes.should == [:subdomain, :mock].to_set
21
20
  end
22
21
  end
23
22
 
24
- describe 'required_attributes' do
25
- it 'should return only the required attributes' do
23
+ describe "required_attributes" do
24
+ it "should return only the required attributes" do
26
25
  subject.required_attributes.should eql [:subdomain].to_set
27
26
  end
28
27
  end
29
28
 
30
- describe 'optional_attributes' do
31
- it 'should return only the optional attributes' do
29
+ describe "optional_attributes" do
30
+ it "should return only the optional attributes" do
32
31
  subject.optional_attributes.should eql [:mock].to_set
33
32
  end
34
33
  end
35
-
36
34
  end
37
-
38
35
  end
39
36
 
40
37
  describe Conduit::Driver::MyDriver do
@@ -1,50 +1,48 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  shared_examples_for Conduit::Core::Parser do
4
-
5
- let(:response) { read_support_file('xml/xml_response.xml') }
4
+ let(:response) { read_support_file("xml/xml_response.xml") }
6
5
 
7
6
  subject do
8
7
  described_class.new(response)
9
8
  end
10
9
 
11
- context 'without an instance' do
10
+ context "without an instance" do
12
11
  its(:class) { should respond_to(:attribute) }
13
12
  its(:class) { should respond_to(:attributes) }
14
13
  end
15
14
 
16
- context 'with an instance' do
17
- describe '#attributes' do
18
- it 'returns an array of known attributes' do
15
+ context "with an instance" do
16
+ describe "#attributes" do
17
+ it "returns an array of known attributes" do
19
18
  subject.attributes.should == [:foo, :bar, :baz].to_set
20
19
  end
21
20
 
22
- it 'defines a method for foo' do
23
- subject.foo.should == 'foo'
21
+ it "defines a method for foo" do
22
+ subject.foo.should == "foo"
24
23
  end
25
24
 
26
- it 'defines a method for bar' do
27
- subject.bar.should == 'bar'
25
+ it "defines a method for bar" do
26
+ subject.bar.should == "bar"
28
27
  end
29
28
 
30
- it 'defines a method for baz' do
31
- subject.baz.should == 'baz'
29
+ it "defines a method for baz" do
30
+ subject.baz.should == "baz"
32
31
  end
33
32
  end
34
33
 
35
- describe '#response_status' do
36
- it 'should respond with success' do
37
- subject.response_status.should == 'success'
34
+ describe "#response_status" do
35
+ it "should respond with success" do
36
+ subject.response_status.should == "success"
38
37
  end
39
38
  end
40
39
 
41
- describe '#response_errors' do
42
- it 'should respond with an empty array' do
40
+ describe "#response_errors" do
41
+ it "should respond with an empty array" do
43
42
  subject.response_errors.should == []
44
43
  end
45
44
  end
46
45
  end
47
-
48
46
  end
49
47
 
50
48
  describe Conduit::Driver::MyDriver::Foo::Parser do
@@ -1,40 +1,39 @@
1
- require 'spec_helper'
2
- require 'excon'
1
+ require "spec_helper"
2
+ require "excon"
3
3
 
4
4
  shared_examples_for Conduit::Core::RequestMocker do
5
-
6
- let(:success) { read_support_file('xml/success_mock.xml') }
7
- let(:failure) { read_support_file('xml/failure_mock.xml') }
5
+ let(:success) { read_support_file("xml/success_mock.xml") }
6
+ let(:failure) { read_support_file("xml/failure_mock.xml") }
8
7
  let(:fake_action) do
9
8
  class FakeAction
10
9
  def view_context
11
- OpenStruct.new({ value: "Yay!" })
10
+ OpenStruct.new(value: "Yay!")
12
11
  end
13
12
  end
14
13
 
15
14
  FakeAction.new
16
15
  end
17
16
 
18
- context 'success mocking' do
19
- subject { described_class.new(fake_action, { mock_status: 'success' }) }
20
- let(:response) { subject.with_mocking { Excon.new('http://example.com').request }.body }
21
- it 'return success response' do
17
+ context "success mocking" do
18
+ subject { described_class.new(fake_action, mock_status: "success") }
19
+ let(:response) { subject.with_mocking { Excon.new("http://example.com").request }.body }
20
+ it "return success response" do
22
21
  response.should eq(success)
23
22
  end
24
23
  end
25
24
 
26
- context 'failure mocking' do
27
- subject { described_class.new(fake_action, { mock_status: 'failure' }) }
28
- let(:response) { subject.with_mocking { Excon.new('http://example.com').request }.body }
29
- it 'return failure response' do
25
+ context "failure mocking" do
26
+ subject { described_class.new(fake_action, mock_status: "failure") }
27
+ let(:response) { subject.with_mocking { Excon.new("http://example.com").request }.body }
28
+ it "return failure response" do
30
29
  response.should eq(failure)
31
30
  end
32
31
  end
33
32
 
34
- context 'with disallowed response status' do
35
- subject { described_class.new(fake_action, { mock_status: 'fake_status' }) }
36
- let(:response) { subject.with_mocking { Excon.new('http://example.com').request }.body }
37
- it 'raises and error' do
33
+ context "with disallowed response status" do
34
+ subject { described_class.new(fake_action, mock_status: "fake_status") }
35
+ let(:response) { subject.with_mocking { Excon.new("http://example.com").request }.body }
36
+ it "raises and error" do
38
37
  lambda { response }.should raise_error(ArgumentError)
39
38
  end
40
39
  end
@@ -1,20 +1,20 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Conduit::Util do
4
- describe 'find_driver' do
5
- it 'should find MyDriver' do
4
+ describe "find_driver" do
5
+ it "should find MyDriver" do
6
6
  driver = Conduit::Util.find_driver(:my_driver)
7
7
  driver.should_not be_nil
8
8
  end
9
9
 
10
- it 'should not throw exception for missing driver' do
10
+ it "should not throw exception for missing driver" do
11
11
  driver = Conduit::Util.find_driver(:missing)
12
12
  driver.should be_nil
13
13
  end
14
14
  end
15
15
 
16
- describe 'find_driver!' do
17
- it 'should throw NameError if it driver not found' do
16
+ describe "find_driver!" do
17
+ it "should throw NameError if it driver not found" do
18
18
  lambda do
19
19
  Conduit::Util.find_driver!(:not_really_there)
20
20
  end.should raise_error(NameError)
@@ -1,16 +1,16 @@
1
1
  # Require Files
2
2
  #
3
- require 'bundler/setup'
3
+ require "bundler/setup"
4
4
  Bundler.setup
5
5
 
6
- require 'rspec'
7
- require 'rspec/its'
8
- require 'shoulda/matchers'
9
- require 'conduit'
6
+ require "rspec"
7
+ require "rspec/its"
8
+ require "shoulda/matchers"
9
+ require "conduit"
10
10
 
11
11
  # Load all of the _spec.rb files
12
12
  #
13
- Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each { |f| require f }
13
+ Dir[File.join(File.dirname(__FILE__), "support", "**", "*.rb")].each { |f| require f }
14
14
 
15
15
  # Rspec Configuration
16
16
  #
@@ -24,9 +24,9 @@ RSpec.configure do |config|
24
24
  config.before(:suite) do
25
25
  Excon.defaults[:mock] = true
26
26
  Conduit.configure do |c|
27
- c.driver_paths << File.join(__dir__, 'support')
27
+ c.driver_paths << File.join(__dir__, "support")
28
28
  end
29
29
 
30
30
  Conduit::Driver.load_drivers
31
31
  end
32
- end
32
+ end
@@ -1,5 +1,4 @@
1
1
  module Helper
2
-
3
2
  def request_attributes
4
3
  {
5
4
  foo: "value for foo",
@@ -12,5 +11,4 @@ module Helper
12
11
  def read_support_file(name)
13
12
  IO.read(File.join(File.dirname(__FILE__), name))
14
13
  end
15
-
16
14
  end
@@ -1,7 +1,6 @@
1
1
  module Conduit::Driver::MyDriver
2
2
  class Foo < Conduit::Core::Action
3
-
4
- remote_url 'http://foo.com/api.xml'
3
+ remote_url "http://foo.com/api.xml"
5
4
 
6
5
  required_attributes :foo, :bar, :baz, [:either, :or]
7
6
  optional_attributes :buz
@@ -5,5 +5,4 @@ module Conduit::Driver::MyDriver
5
5
  required_attributes :subdomain
6
6
  optional_attributes :mock
7
7
  action :foo
8
-
9
8
  end
@@ -1,22 +1,21 @@
1
- require 'nokogiri'
1
+ require "nokogiri"
2
2
 
3
3
  module Conduit::Driver::MyDriver
4
4
  class Foo::Parser < Conduit::Core::Parser
5
-
6
5
  def initialize(xml)
7
6
  @xml = xml
8
7
  end
9
8
 
10
9
  attribute :foo do
11
- 'foo'
10
+ "foo"
12
11
  end
13
12
 
14
13
  attribute :bar do
15
- 'bar'
14
+ "bar"
16
15
  end
17
16
 
18
17
  attribute :baz do
19
- 'baz'
18
+ "baz"
20
19
  end
21
20
 
22
21
  # Return "success/failure". This gets
@@ -24,7 +23,7 @@ module Conduit::Driver::MyDriver
24
23
  # as a type of notification
25
24
  #
26
25
  def response_status
27
- string_path('/BeQuick/response/@status')
26
+ string_path("/BeQuick/response/@status")
28
27
  end
29
28
 
30
29
  # Return an array of error objects
@@ -34,8 +33,8 @@ module Conduit::Driver::MyDriver
34
33
  # => [{"code"=>nil, "message"=>"Unable to locate telephone by MDN"}]
35
34
  #
36
35
  def response_errors
37
- object_path('/BeQuick/response/errors/error').map do |error|
38
- Hash.from_xml(error.to_s)['error']
36
+ object_path("/BeQuick/response/errors/error").map do |error|
37
+ Hash.from_xml(error.to_s)["error"]
39
38
  end
40
39
  end
41
40
 
@@ -70,6 +69,5 @@ module Conduit::Driver::MyDriver
70
69
  def string_path(path, node = doc)
71
70
  object_path(path, node).to_s
72
71
  end
73
-
74
72
  end
75
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conduit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Kelley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-24 00:00:00.000000000 Z
11
+ date: 2017-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: aws-sdk
28
+ name: aws-sdk-v1
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  version: '0'
238
238
  requirements: []
239
239
  rubyforge_project:
240
- rubygems_version: 2.6.7
240
+ rubygems_version: 2.2.2
241
241
  signing_key:
242
242
  specification_version: 4
243
243
  summary: Conduit is an interface for debit platforms.
@@ -262,4 +262,3 @@ test_files:
262
262
  - spec/support/xml/xml_modified_request.xml
263
263
  - spec/support/xml/xml_request.xml
264
264
  - spec/support/xml/xml_response.xml
265
- has_rdoc: