Permalink
Browse files

Refactor Configuration and Specs

  • Loading branch information...
1 parent 39ea512 commit 75a06f6a9d5252c07e663b0958fc89c1d8a2274c @dnunez24 dnunez24 committed Apr 25, 2012
Showing with 24 additions and 28 deletions.
  1. +10 −6 lib/channeladvisor.rb
  2. +11 −19 spec/lib/channeladvisor_spec.rb
  3. +3 −3 spec/support/vcr.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
@@ -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
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|

0 comments on commit 75a06f6

Please sign in to comment.