-
Notifications
You must be signed in to change notification settings - Fork 4
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
Tim Stephenson
committed
Mar 17, 2011
1 parent
b192a87
commit 9894073
Showing
8 changed files
with
91 additions
and
6 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 |
---|---|---|
|
@@ -19,4 +19,7 @@ pkg | |
|
||
# For TextMate | ||
*.tmproj | ||
tmtags | ||
tmtags | ||
|
||
#api key info | ||
keys.txt |
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
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,6 @@ | ||
require File.expand_path('../r_hapi/lead', __FILE__) | ||
require File.expand_path('../r_hapi/configuration', __FILE__) | ||
|
||
module RHapi | ||
extend Configuration | ||
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,28 @@ | ||
module RHapi | ||
module Configuration | ||
VALID_OPTIONS_KEYS = [:api_key, :end_point, :hub_spot_site] | ||
DEFAULT_API_KEY = nil | ||
DEFAULT_END_POINT = "https://hubapi.com" | ||
DEFAULT_HUB_SPOT_SITE = nil | ||
|
||
attr_accessor *VALID_OPTIONS_KEYS | ||
|
||
def configure | ||
yield self | ||
end | ||
|
||
# Create a hash of options and their values | ||
def options | ||
Hash[VALID_OPTIONS_KEYS.map {|key| [key, send(key)] }] | ||
end | ||
|
||
# Reset all configuration options to defaults | ||
def reset | ||
self.api_key = DEFAULT_API_KEY | ||
self.end_point = DEFAULT_END_POINT | ||
self.hub_spot_site = DEFAULT_HUB_SPOT_SITE | ||
self | ||
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,9 @@ | ||
module RHapi | ||
|
||
class Lead | ||
def truth | ||
true | ||
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,30 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') | ||
|
||
describe "Configuration" do | ||
before do | ||
RHapi.configure do |config| | ||
config.api_key = "123" | ||
config.end_point = "https://mysite.com" | ||
config.hub_spot_site = "http://mysite.hubspot.com" | ||
end | ||
end | ||
|
||
it "sets the api key" do | ||
RHapi.options[:api_key].should == "123" | ||
end | ||
|
||
it "sets the endpoint" do | ||
RHapi.options[:end_point].should == "https://mysite.com" | ||
end | ||
|
||
it "sets the hub_spot_site" do | ||
RHapi.options[:hub_spot_site].should == "http://mysite.hubspot.com" | ||
end | ||
|
||
it "resets to the default values" do | ||
RHapi.reset | ||
RHapi.options[:api_key].should == nil | ||
RHapi.options[:end_point].should == "https://hubapi.com" | ||
RHapi.options[:hub_spot_site].should == nil | ||
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,8 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') | ||
|
||
describe "RHapi::Lead" do | ||
it "passes" do | ||
lead = RHapi::Lead.new | ||
lead.truth.should == true | ||
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,7 +1,8 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') | ||
|
||
describe "RHapi" do | ||
it "fails" do | ||
fail "hey buddy, you should probably rename this file and start specing for real" | ||
it "passes" do | ||
lead = RHapi::Lead.new | ||
lead.truth.should == true | ||
end | ||
end |