Permalink
Browse files

return boolean from ToLang.start to indicate successful initialization

  • Loading branch information...
1 parent a5f11ae commit 91ec284542f45959b5b4f9d5719deed5b24f38c5 @jimmycuadra jimmycuadra committed Dec 26, 2010
Showing with 6 additions and 0 deletions.
  1. +2 −0 lib/to_lang.rb
  2. +4 −0 spec/to_lang_spec.rb
View
@@ -6,9 +6,11 @@ class << self
attr_reader :connector
def start(key)
+ return false if defined?(@connector) && !@connector.nil?
@connector = ToLang::Connector.new(key)
String.send(:include, StringMethods)
add_magic_methods
+ true
end
private
View
@@ -6,6 +6,10 @@
ToLang.start('apikey')
end
+ it "returns false if :start was already called" do
+ ToLang.start('apikey').should == false
+ end
+
it "stores a ToLang::Connector object" do
ToLang.connector.should be_an_instance_of ToLang::Connector
end

0 comments on commit 91ec284

Please sign in to comment.