Permalink
Browse files

Raise argument error for malformatted api keys (in case of user input…

… + bad copy/paste)
  • Loading branch information...
1 parent 6055453 commit b40bd9789496a5857abbed10d8b4b8d7c42b53eb @radicaled committed Aug 18, 2010
Showing with 6 additions and 0 deletions.
  1. +1 −0 lib/hominid/base.rb
  2. +5 −0 test/hominid_test.rb
View
1 lib/hominid/base.rb
@@ -10,6 +10,7 @@ class Base
def initialize(config = {})
raise StandardError.new('Please provide your Mailchimp API key.') unless config[:api_key]
+ raise ArgumentError.new('Your Mailchimp API key is malformatted.') unless config[:api_key].include?('-')
dc = config[:api_key].split('-').last
defaults = {
:double_opt_in => false,
View
5 test/hominid_test.rb
@@ -4,4 +4,9 @@ class HominidTest < Test::Unit::TestCase
should "probably rename this file and start testing for real" do
flunk "hey buddy, you should probably rename this file and start testing for real"
end
+ should "raise an error when accepting an API key without the datacenter prefix (-)" do
+ assert_raise(ArgumentError) do
+ Hominid::Base.new({ :api_key => 'this_is_wrong' })
+ end
+ end
end

0 comments on commit b40bd97

Please sign in to comment.