sappy 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -9,6 +9,9 @@ begin
9
9
  gemspec.authors = ["Dylan Egan", "Tim Carey-Smith"]
10
10
  gemspec.files = %w(README.markdown Rakefile VERSION) + Dir.glob("{lib,bacon}/**/*")
11
11
  gemspec.rubyforge_project = 'abcde'
12
+ gemspec.add_dependency "rack", "1.0.0"
13
+ gemspec.add_dependency "rest-client", "1.0.3"
14
+ gemspec.add_dependency "xml-simple", "1.0.12"
12
15
  end
13
16
 
14
17
  Jeweler::RubyforgeTasks.new
@@ -16,7 +19,10 @@ rescue LoadError
16
19
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
17
20
  end
18
21
 
19
- desc "Run bacon"
22
+ desc 'Run bacon'
20
23
  task :bacon do
21
24
  puts `bacon #{Dir["spec/**/*_bacon.rb"].join(" ")}`
22
25
  end
26
+
27
+ desc 'Default: Runs spec'
28
+ task :default => :bacon
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/lib/sappy.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'xmlsimple'
3
2
 
4
3
  require File.dirname(__FILE__) + '/core_ext'
@@ -14,7 +14,7 @@ module Sappy
14
14
  end
15
15
 
16
16
  def parse
17
- hash = XmlSimple.xml_in(@xml.to_s)
17
+ hash = XmlSimple.xml_in(@xml.to_s, 'KeepRoot' => false)
18
18
  if hash["stat"] == "fail"
19
19
  error = hash["err"]
20
20
  message = error.first["msg"]
@@ -0,0 +1,2 @@
1
+ USERNAME = "sappy@siteuptime.com"
2
+ PASSWORD = "password"
data/spec/helper.rb CHANGED
@@ -1,28 +1,38 @@
1
- require 'rubygems'
2
- require 'bacon'
3
- require 'fakeweb'
4
- require 'pp'
1
+ require File.dirname(__FILE__) + '/../tmp/vendor/environment'
2
+ Bundler.require_env(:test)
3
+ require 'cgi'
5
4
 
6
5
  require File.dirname(__FILE__) + '/../lib/sappy'
6
+ begin
7
+ require File.dirname(__FILE__) + '/credentials.rb'
8
+ rescue LoadError
9
+ raise "add a spec/credentials.rb that defines USERNAME and PASSWORD constants"
10
+ end
7
11
 
8
12
  SPEC_DIR = File.dirname(__FILE__) unless defined? SPEC_DIR
9
13
  $:<< SPEC_DIR
10
-
11
- # Don't allow real web requests during specs!
12
- FakeWeb.allow_net_connect = false
13
-
14
- # Setup default URL calls
15
14
 
16
15
  def cached_page(name)
17
16
  SPEC_DIR + "/xml/#{name}.xml"
18
17
  end
19
18
 
20
- FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?method=siteuptime.auth&Password=password&Email=valid%40email.com", :response => cached_page('valid_account'))
21
- FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?method=siteuptime.auth&Password=password&Email=invalid%40email.com", :response => cached_page('invalid_account'))
22
- FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.accountinfo", :response => cached_page('accountinfo'))
23
- FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.summarystatistics", :response => cached_page('summarystatistics'))
24
- FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.monitors", :response => cached_page('monitors'))
25
- FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?Name=New+Monitor&AuthKey=b7kks5mh1l300v5segaksm8gh3&Enabled=&HostName=new-sf-monitor.com&Login=&AltEmailAlerts=&Content=&Location=sf&EnablePublicStatistics=&Domain=&method=siteuptime.addmonitor&Timeout=&Password=&UpSubject=&AddToStatusPage=&SendAllDownAlerts=&IP=&SendAlertAfter=&DontSendUpAlert=&SendJabberAlert=&CheckPeriod=60&DownSubject=&SendUrlAlert=&SendSms=&PortNumber=&Service=http", :response => cached_page('addmonitor'))
26
- FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.enablemonitor&MonitorId=84043", :response => cached_page('enablemonitor'))
27
- FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.disablemonitor&MonitorId=84043", :response => cached_page('disablemonitor'))
28
- FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.removemonitor&MonitorId=84043", :response => cached_page('removemonitor'))
19
+ unless ENV['LIVE_SPECS']
20
+ # Don't allow real web requests
21
+ FakeWeb.allow_net_connect = false
22
+
23
+ FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?method=siteuptime.auth&Password=#{PASSWORD}&Email=#{CGI.escape USERNAME}", :response => cached_page('valid_account'))
24
+ FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?method=siteuptime.auth&Password=password&Email=invalid%40email.com", :response => cached_page('invalid_account'))
25
+ FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.accountinfo", :response => cached_page('accountinfo'))
26
+ FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.summarystatistics", :response => cached_page('summarystatistics'))
27
+ FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.monitors", :response => cached_page('monitors'))
28
+ FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AddToStatusPage=&AltEmailAlerts=&AuthKey=b7kks5mh1l300v5segaksm8gh3&CheckPeriod=60&Content=&Domain=&DontSendUpAlert=&DownSubject=&EnablePublicStatistics=&Enabled=&HostName=engineyard.com&IP=&Location=sf&Login=&Name=New+Monitor&Password=&PortNumber=&SendAlertAfter=&SendAllDownAlerts=&SendJabberAlert=&SendSms=&SendUrlAlert=&Service=http&Timeout=&UpSubject=&method=siteuptime.addmonitor", :response => cached_page('addmonitor'))
29
+ FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.enablemonitor&MonitorId=84043", :response => cached_page('enablemonitor'))
30
+ FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.disablemonitor&MonitorId=84043", :response => cached_page('disablemonitor'))
31
+ FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.removemonitor&MonitorId=84043", :response => cached_page('removemonitor'))
32
+ end
33
+
34
+ at_exit do
35
+ Sappy::Account.login(USERNAME, PASSWORD).monitors.each do |m|
36
+ m.destroy
37
+ end
38
+ end
@@ -12,14 +12,21 @@ module Sappy
12
12
 
13
13
  describe "with correct credentials" do
14
14
  before do
15
- @account = Account.login("valid@email.com", "password")
15
+ @account = Account.login(USERNAME, PASSWORD)
16
+ end
17
+
18
+ before do
16
19
  @account.monitors.each do |m|
17
20
  m.destroy
18
21
  end
19
22
  end
20
23
 
21
24
  it "should obtain an auth key" do
22
- @account.authkey.should == "b7kks5mh1l300v5segaksm8gh3"
25
+ if ENV['LIVE_SPECS']
26
+ @account.authkey.should.be.kind_of(String)
27
+ else
28
+ @account.authkey.should == "b7kks5mh1l300v5segaksm8gh3"
29
+ end
23
30
  end
24
31
 
25
32
  describe "with no monitors" do
@@ -36,9 +43,13 @@ module Sappy
36
43
  end
37
44
 
38
45
  it "can create a new monitor" do
39
- monitor = @account.add_monitor({:name => "New Monitor", :service => "http", :location => "sf", :host => "new-sf-monitor.com", :period => "60"})
46
+ monitor = @account.add_monitor({:name => "New Monitor", :service => "http", :location => "sf", :host => "engineyard.com", :period => "60"})
40
47
  monitor.id.should.not.be.nil
41
- FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.monitors", :response => cached_page('monitors_1'))
48
+ if ENV['LIVE_SPECS']
49
+ @account.available_monitors.should == 2
50
+ else
51
+ FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.monitors", :response => cached_page('monitors_1'))
52
+ end
42
53
  monitors = @account.monitors
43
54
  monitors.size.should == 1
44
55
  monitors.first.name.should == "New Monitor"
@@ -3,9 +3,12 @@ require File.dirname(__FILE__) + '/../helper'
3
3
  module Sappy
4
4
  describe Monitor do
5
5
  before do
6
- @account = Account.login("valid@email.com", "password")
6
+ @account = Account.login(USERNAME, PASSWORD)
7
+ end
8
+
9
+ before do
7
10
  @account.monitors.each { |m| m.destroy }
8
- @monitor = @account.add_monitor({:name => "New Monitor", :service => "http", :location => "sf", :host => "new-sf-monitor.com", :period => "60"})
11
+ @monitor = @account.add_monitor({:name => "New Monitor", :service => "http", :location => "sf", :host => "engineyard.com", :period => "60"})
9
12
  end
10
13
 
11
14
  describe "an active monitor" do
@@ -32,10 +35,14 @@ module Sappy
32
35
 
33
36
  describe "a monitor" do
34
37
  it "can be destroyed" do
35
- FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.monitors", :response => cached_page('monitors_1'))
38
+ unless ENV['LIVE_SPECS']
39
+ FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.monitors", :response => cached_page('monitors_1'))
40
+ end
36
41
  @account.monitors.size.should == 1
37
42
  lambda { @monitor.destroy }.should.not.raise
38
- FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.monitors", :response => cached_page('monitors'))
43
+ unless ENV['LIVE_SPECS']
44
+ FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.monitors", :response => cached_page('monitors'))
45
+ end
39
46
  @account.monitors.size.should == 0
40
47
  end
41
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sappy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Egan
@@ -10,10 +10,39 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-08-26 00:00:00 +10:00
13
+ date: 2009-10-03 00:00:00 +10:00
14
14
  default_executable: shell
15
- dependencies: []
16
-
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rack
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - "="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.0.0
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: rest-client
28
+ type: :runtime
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "="
33
+ - !ruby/object:Gem::Version
34
+ version: 1.0.3
35
+ version:
36
+ - !ruby/object:Gem::Dependency
37
+ name: xml-simple
38
+ type: :runtime
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - "="
43
+ - !ruby/object:Gem::Version
44
+ version: 1.0.12
45
+ version:
17
46
  description: A wrapper for the SiteUptime API
18
47
  email:
19
48
  - dylanegan@gmail.com
@@ -70,11 +99,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
99
  requirements: []
71
100
 
72
101
  rubyforge_project: abcde
73
- rubygems_version: 1.3.4
102
+ rubygems_version: 1.3.5
74
103
  signing_key:
75
104
  specification_version: 3
76
105
  summary: Wrapping that shit!
77
106
  test_files:
107
+ - spec/credentials.integrity.rb
78
108
  - spec/helper.rb
79
109
  - spec/sappy/account_bacon.rb
80
110
  - spec/sappy/monitor_bacon.rb