Permalink
Browse files

Config specs

  • Loading branch information...
1 parent 6b17a8a commit 09fe1b34ff20d5cd3da3f7625ff76725f9e798f2 @winton committed Dec 7, 2009
@@ -10,7 +10,7 @@ def api_key(api_key=nil, &block)
def deploy_url(url=nil)
@deploy_url = url unless url.nil?
- @deploy_url || "http://hoptoadapp.com/deploys.txt"
+ @deploy_url || "http://hoptoadapp.com:80/deploys.txt"
end
def environments(environments=nil)
@@ -20,7 +20,7 @@ def environments(environments=nil)
def filters(filters=nil)
@filters = filters unless filters.nil?
- @filters
+ @filters || []
end
def log(log=nil)
@@ -30,7 +30,7 @@ def log(log=nil)
def notify_url(url=nil)
@notify_url = url unless url.nil?
- @url || "http://hoptoadapp.com:80/notify_url/v2/notices"
+ @notify_url || "http://hoptoadapp.com:80/notify_url/v2/notices"
end
def rails
@@ -36,7 +36,7 @@ def backtrace
end
def filter(hash)
- return hash unless Config.filters
+ return hash if Config.filters.empty?
hash.inject({}) do |acc, (key, val)|
match = Config.filters.any? { |f| key.to_s =~ Regexp.new(f) }
acc[key] = match ? "[FILTERED]" : val
@@ -65,13 +65,14 @@ def parse
if @env
request = Rack::Request.new @env
+ params = filter request.params
request_path = request.script_name + request.path_info
else
- request = nil
+ params = {}
request_path = 'Internal'
end
- [ backtrace, env, @exception, request, request_path ]
+ [ backtrace, env, @exception, params, request_path ]
end
def success?
@@ -5,7 +5,7 @@ class <<self
include Config::Methods
- def build(backtrace, env, exception, request, request_path)
+ def build(backtrace, env, exception, params, request_path)
@@last_request = nil
xml = ::Builder::XmlMarkup.new
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
@@ -29,9 +29,9 @@ def build(backtrace, env, exception, request, request_path)
r.action Config::Request.action
r.component Config::Request.component || request_path
r.url request_path
- if request && request.params.any?
+ if params.any?
r.params do |p|
- request.params.each do |key, value|
+ params.each do |key, value|
p.var value.to_s, :key => key
end
end
View
@@ -1,3 +1,5 @@
+require File.expand_path("#{File.dirname __FILE__}/../lilypad")
+
module Rack
class Lilypad
@@ -0,0 +1,27 @@
+require File.expand_path("#{File.dirname __FILE__}/../../spec_helper")
+
+describe Lilypad::Config::Request do
+
+ before(:each) do
+ Lilypad::Config::Request.action 'action'
+ Lilypad::Config::Request.component 'component'
+ end
+
+ after(:each) do
+ Lilypad::Config::Request.class_eval do
+ @action = nil
+ @component = nil
+ end
+ end
+
+ it "should set options" do
+ Lilypad::Config::Request.action.should == 'action'
+ Lilypad::Config::Request.component.should == 'component'
+ end
+
+ it "should provide a method to reset all options" do
+ Lilypad::Config::Request.reset!
+ Lilypad::Config::Request.action.should == nil
+ Lilypad::Config::Request.component.should == nil
+ end
+end
@@ -0,0 +1,45 @@
+require File.expand_path("#{File.dirname __FILE__}/../spec_helper")
+
+describe Lilypad::Config do
+
+ before(:each) do
+ Lilypad::Config.api_key 'api_key'
+ Lilypad::Config.deploy_url 'deploy_url'
+ Lilypad::Config.environments 'environments'
+ Lilypad::Config.filters 'filters'
+ Lilypad::Config.log 'log'
+ Lilypad::Config.notify_url 'notify_url'
+ end
+
+ after(:each) do
+ Lilypad::Config.class_eval do
+ @api_key = nil
+ @deploy_url = nil
+ @environments = nil
+ @filters = nil
+ @log = nil
+ @notify_url = nil
+ end
+ end
+
+ it "should set options" do
+ Lilypad::Config.api_key.should == 'api_key'
+ Lilypad::Config.deploy_url.should == 'deploy_url'
+ Lilypad::Config.environments.should == 'environments'
+ Lilypad::Config.filters.should == 'filters'
+ Lilypad::Config.log.should == 'log'
+ Lilypad::Config.notify_url.should == 'notify_url'
+ end
+
+ it "should require the rails adapter when the rails method is called" do
+ adapter = File.expand_path "#{SPEC}/../lib/lilypad/adapters/rails"
+ Lilypad::Config.should_receive(:require).with(adapter)
+ Lilypad::Config.rails
+ end
+
+ it "should require the rails adapter when the sinatra method is called" do
+ adapter = File.expand_path "#{SPEC}/../lib/lilypad/adapters/sinatra"
+ Lilypad::Config.should_receive(:require).with(adapter)
+ Lilypad::Config.sinatra
+ end
+end
@@ -62,7 +62,6 @@
rescue Exception => e
Lilypad.notify(e)
end
- validate_xml
end
it "should provide a deploy method" do

0 comments on commit 09fe1b3

Please sign in to comment.