forked from hashrocket/namecheap
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
parasquid
committed
Oct 14, 2011
1 parent
2431b42
commit 012df9b
Showing
9 changed files
with
49 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
require "bundler/gem_tasks" | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => :spec |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Hash | ||
def symbolize_keys! | ||
keys.each do |key| | ||
self[(key.to_sym rescue key) || key] = delete(key) | ||
end | ||
self | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
require 'monkey_patch' | ||
require 'httparty' | ||
|
||
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/namecheap") | ||
Dir.glob("#{File.dirname(__FILE__)}/namecheap/*.rb") { |lib| require File.basename(lib, '.*') } | ||
|
||
|
||
module Namecheap | ||
class Namecheap | ||
attr_reader :username, :key, :client_ip | ||
def initialize(options = {}) | ||
config = YAML.load_file("#{File.dirname(__FILE__)}/../config/namecheap.yml").symbolize_keys! | ||
@key = options[:key] || config[:key] | ||
@username = options[:username] || config[:username] | ||
@client_ip = options[:client_ip] || config[:client_ip] | ||
end | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require File.dirname(__FILE__) + '/../namecheap.rb' | ||
|
||
module Namecheap | ||
class Domains < Namecheap::Namecheap | ||
|
||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,36 @@ | ||
require File.dirname(__FILE__) + '/spec_helper' | ||
require File.dirname(__FILE__) + '/../lib/namecheap' | ||
require 'mocha' | ||
|
||
describe "NamecheapAPI Wrapper" do | ||
describe "initializating settings" do | ||
describe "with defaults" do | ||
describe "with defaults" do | ||
it "should contain a username" do | ||
namecheap = Namecheap.new | ||
namecheap.send(:username).should == 'apiuser' | ||
end | ||
namecheap = Namecheap::Namecheap.new | ||
namecheap.send(:username).should == 'apiuser' | ||
end | ||
it "should contain a key" do | ||
namecheap = Namecheap.new | ||
namecheap.send(:key).should == 'apikey' | ||
namecheap = Namecheap::Namecheap.new | ||
namecheap.send(:key).should == 'apikey' | ||
end | ||
it "should contain a client_ip" do | ||
namecheap = Namecheap.new | ||
namecheap.send(:client_ip).should == '127.0.0.1' | ||
namecheap = Namecheap::Namecheap.new | ||
namecheap.send(:client_ip).should == '127.0.0.1' | ||
end | ||
end | ||
|
||
describe "with defaults overidden" do | ||
describe "with defaults overidden" do | ||
it "shoud contain a overidden username" do | ||
namecheap = Namecheap.new(:username => 'testuser') | ||
namecheap.send(:username).should == 'testuser' | ||
end | ||
namecheap = Namecheap::Namecheap.new(:username => 'testuser') | ||
namecheap.send(:username).should == 'testuser' | ||
end | ||
|
||
it "shoud contain a key" do | ||
namecheap = Namecheap.new(:key => 'testkey') | ||
namecheap.send(:key).should == 'testkey' | ||
namecheap = Namecheap::Namecheap.new(:key => 'testkey') | ||
namecheap.send(:key).should == 'testkey' | ||
end | ||
it "shoud contain a client_ip" do | ||
namecheap = Namecheap.new(:client_ip => '66.11.22.44') | ||
namecheap.send(:client_ip).should == '66.11.22.44' | ||
end | ||
end | ||
end | ||
|
||
describe "Attempt to connect with bad credentials" do | ||
it "should report an error on erroneous account information" do | ||
namecheap = Namecheap.new | ||
namecheap.domain_check("fakedomain").status.should == "ERROR" | ||
namecheap = Namecheap::Namecheap.new(:client_ip => '66.11.22.44') | ||
namecheap.send(:client_ip).should == '66.11.22.44' | ||
end | ||
|
||
it "should give error message for invalid api key when using an invalid key" do | ||
namecheap = Namecheap.new | ||
namecheap.domain_check("fakedomain").message.should include("API Key is invalid") | ||
end | ||
end | ||
|
||
describe "Attempt to connect with valid credentials" do | ||
|
||
end | ||
|
||
describe "#domain_check" do | ||
it "should build query with multiple domains" do | ||
namecheap = Namecheap.new() | ||
namecheap.expects(:do_query).with("namecheap.domains.check", "&DomainList=domain1.com,domain2.com") | ||
namecheap.domain_check(['domain1.com','domain2.com']) | ||
end | ||
end | ||
|
||
describe "#is_domain_available?" do | ||
it "should return false if connection fails" do | ||
namecheap = Namecheap.new(:apikey => 'BADKEY') | ||
lambda { | ||
namecheap.is_domain_available?('fakedomain.tld').should be_false | ||
}.should raise_error(NilNamecheapResponse) | ||
end | ||
|
||
it "should return true if connections succeeds and domain is available" do | ||
pending "Need API Access To Namecheap.com" | ||
namecheap = Namecheap.new | ||
namecheap.is_domain_available?('saucytuborswithashoefetish.com').should be_true | ||
end | ||
|
||
it "should return false if connections succeeds and domain is not available" do | ||
namecheap = Namecheap.new | ||
lambda { | ||
namecheap.is_domain_available?('hashrocket.com').should be_false | ||
}.should raise_error(NilNamecheapResponse) | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
begin | ||
require 'spec' | ||
require 'rspec' | ||
rescue LoadError | ||
require 'rubygems' | ||
gem 'rspec' | ||
require 'spec' | ||
end | ||
|
||
require 'activesupport' | ||
require 'activerecord' | ||
|
||
$:.unshift(File.dirname(__FILE__) + '/../lib') | ||
require File.dirname(__FILE__) + '/../lib/namecheap' |