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 +7 -1
- data/VERSION +1 -1
- data/lib/sappy.rb +0 -1
- data/lib/sappy/response.rb +1 -1
- data/spec/credentials.integrity.rb +2 -0
- data/spec/helper.rb +28 -18
- data/spec/sappy/account_bacon.rb +15 -4
- data/spec/sappy/monitor_bacon.rb +11 -4
- metadata +35 -5
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
|
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
|
+
0.1.2
|
data/lib/sappy.rb
CHANGED
data/lib/sappy/response.rb
CHANGED
data/spec/helper.rb
CHANGED
@@ -1,28 +1,38 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
require '
|
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
|
-
|
21
|
-
|
22
|
-
FakeWeb.
|
23
|
-
|
24
|
-
FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?
|
25
|
-
FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?
|
26
|
-
FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.
|
27
|
-
FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.
|
28
|
-
FakeWeb.register_uri(:get, "https://siteuptime.com/api/rest/?AuthKey=b7kks5mh1l300v5segaksm8gh3&method=siteuptime.
|
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
|
data/spec/sappy/account_bacon.rb
CHANGED
@@ -12,14 +12,21 @@ module Sappy
|
|
12
12
|
|
13
13
|
describe "with correct credentials" do
|
14
14
|
before do
|
15
|
-
@account = Account.login(
|
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
|
-
|
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 => "
|
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
|
-
|
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"
|
data/spec/sappy/monitor_bacon.rb
CHANGED
@@ -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(
|
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 => "
|
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
|
-
|
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
|
-
|
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.
|
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-
|
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.
|
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
|