Permalink
Browse files

Set default configuration values when extended

  • Loading branch information...
1 parent fbf30c6 commit abae84d22e97deb82cb3e79a88f7c961f8f4c9cc @vigosan committed Jul 8, 2012
Showing with 24 additions and 0 deletions.
  1. +5 −0 lib/big_ml/util/config.rb
  2. +19 −0 spec/units/client_spec.rb
View
5 lib/big_ml/util/config.rb
@@ -12,6 +12,11 @@ module Config
attr_accessor *VALID_OPTIONS_KEYS
+ # When this module is extended, set all configuration options to their default values
+ def self.extended(base)
+ base.reset
+ end
+
def configure
yield self
self
View
19 spec/units/client_spec.rb
@@ -47,4 +47,23 @@
end
end
end
+
+ context "reset module configuration" do
+ let(:api) {
+ BigML::Util::Client.new
+ }
+
+ before(:each) {
+ BigML.reset
+ }
+
+ it "sets default username to nil" do
+ api.username.should be_nil
+ end
+
+ it "sets default api key to nil" do
+ api.api_key.should be_nil
+ end
+ end
+
end

0 comments on commit abae84d

Please sign in to comment.