Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor Configuration and Specs

  • Loading branch information...
commit 75a06f6a9d5252c07e663b0958fc89c1d8a2274c 1 parent 39ea512
Dave Nunez dnunez24 authored
16 lib/channeladvisor.rb
View
@@ -3,15 +3,19 @@
require 'channeladvisor/error'
require 'channeladvisor/configuration'
require 'channeladvisor/client'
+require 'channeladvisor/services'
+require 'channeladvisor/base'
require 'channeladvisor/order'
require 'channeladvisor/admin'
module ChannelAdvisor
- def self.configuration
- @configuration ||= Configuration.new
- end
+ class << self
+ def configuration
+ @configuration ||= Configuration.new
+ end
- def self.configure
- yield configuration if block_given?
- end
+ def configure
+ yield configuration if block_given?
+ end
+ end
end
30 spec/lib/channeladvisor_spec.rb
View
@@ -1,26 +1,18 @@
require 'spec_helper'
describe ChannelAdvisor do
- describe ".configure" do
- describe "account_id" do
- it "sets the account ID" do
- ChannelAdvisor.configure { |config| config.account_id = "e83a0b1e-75f7-41e3-8aac-d8ff01f9d1ea" }
- ChannelAdvisor.configuration.account_id.should == "e83a0b1e-75f7-41e3-8aac-d8ff01f9d1ea"
- end
- end
+ describe ".configuration" do
+ subject { ChannelAdvisor.configuration }
- describe "developer_key" do
- it "sets the developer ID" do
- ChannelAdvisor.configure { |config| config.developer_key = "11111111-1111-1111-1111-999999999999" }
- ChannelAdvisor.configuration.developer_key.should == "11111111-1111-1111-1111-999999999999"
- end
- end
+ it { should be_an_instance_of ChannelAdvisor::Configuration }
+ it { should equal ChannelAdvisor.configuration }
+ end
- describe "password" do
- it "sets the password" do
- ChannelAdvisor.configure { |config| config.password = "mypassword" }
- ChannelAdvisor.configuration.password.should == "mypassword"
- end
- end
+ describe ".configure" do
+ it "yields the current configuration" do
+ ChannelAdvisor.configure do |config|
+ config.should equal ChannelAdvisor.configuration
+ end
+ end
end
end
6 spec/support/vcr.rb
View
@@ -9,9 +9,9 @@
}
config.hook_into :fakeweb
config.configure_rspec_metadata!
- config.filter_sensitive_data("$$ACCOUNT_ID$$") { ChannelAdvisor.account_id }
- config.filter_sensitive_data("$$DEVELOPER_KEY$$") { ChannelAdvisor.developer_key }
- config.filter_sensitive_data("$$PASSWORD$$") { ChannelAdvisor.password }
+ config.filter_sensitive_data("$$ACCOUNT_ID$$") { ChannelAdvisor.configuration.account_id }
+ config.filter_sensitive_data("$$DEVELOPER_KEY$$") { ChannelAdvisor.configuration.developer_key }
+ config.filter_sensitive_data("$$PASSWORD$$") { ChannelAdvisor.configuration.password }
end
RSpec.configure do |config|
Please sign in to comment.
Something went wrong with that request. Please try again.