noah 0.0.5 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +9 -0
  3. data/LICENSE +201 -0
  4. data/README.md +68 -212
  5. data/Rakefile +70 -41
  6. data/TODO.md +59 -0
  7. data/bin/noah +2 -1
  8. data/bin/noah-watcher.rb +93 -0
  9. data/config.ru +6 -3
  10. data/config/warble.rb +18 -0
  11. data/examples/README.md +116 -0
  12. data/examples/cluster.ru +2 -0
  13. data/examples/custom-watcher.rb +10 -0
  14. data/examples/httpclient-server.rb +7 -0
  15. data/examples/httpclient.rb +12 -0
  16. data/examples/httpclient2.rb +28 -0
  17. data/examples/js/FABridge.js +1452 -0
  18. data/examples/js/WebSocketMain.swf +830 -0
  19. data/examples/js/swfobject.js +851 -0
  20. data/examples/js/web_socket.js +312 -0
  21. data/examples/logger.rb +11 -0
  22. data/examples/reconfiguring-sinatra-watcher.rb +11 -0
  23. data/examples/reconfiguring-sinatra.rb +32 -0
  24. data/examples/simple-post.rb +17 -0
  25. data/examples/websocket.html +24 -0
  26. data/examples/websocket.rb +41 -0
  27. data/lib/noah.rb +5 -8
  28. data/lib/noah/app.rb +20 -268
  29. data/lib/noah/application_routes.rb +70 -0
  30. data/lib/noah/ark.rb +0 -0
  31. data/lib/noah/configuration_routes.rb +81 -0
  32. data/lib/noah/ephemeral_routes.rb +19 -0
  33. data/lib/noah/helpers.rb +12 -14
  34. data/lib/noah/host_routes.rb +69 -0
  35. data/lib/noah/models.rb +86 -5
  36. data/lib/noah/models/applications.rb +41 -0
  37. data/lib/noah/models/configurations.rb +49 -0
  38. data/lib/noah/models/ephemerals.rb +33 -0
  39. data/lib/noah/models/hosts.rb +56 -0
  40. data/lib/noah/models/services.rb +54 -0
  41. data/lib/noah/models/watchers.rb +54 -0
  42. data/lib/noah/passthrough.rb +11 -0
  43. data/lib/noah/service_routes.rb +71 -0
  44. data/lib/noah/validations.rb +1 -0
  45. data/lib/noah/validations/watcher_validations.rb +48 -0
  46. data/lib/noah/version.rb +1 -1
  47. data/lib/noah/watcher.rb +75 -0
  48. data/lib/noah/watcher_routes.rb +12 -0
  49. data/lib/vendor/em-hiredis/Gemfile +4 -0
  50. data/lib/vendor/em-hiredis/README.md +61 -0
  51. data/lib/vendor/em-hiredis/Rakefile +2 -0
  52. data/lib/vendor/em-hiredis/em-hiredis-0.0.1.gem +0 -0
  53. data/lib/vendor/em-hiredis/em-hiredis.gemspec +23 -0
  54. data/lib/vendor/em-hiredis/lib/em-hiredis.rb +22 -0
  55. data/lib/vendor/em-hiredis/lib/em-hiredis/client.rb +131 -0
  56. data/lib/vendor/em-hiredis/lib/em-hiredis/connection.rb +61 -0
  57. data/lib/vendor/em-hiredis/lib/em-hiredis/event_emitter.rb +29 -0
  58. data/lib/vendor/em-hiredis/lib/em-hiredis/version.rb +5 -0
  59. data/noah.gemspec +21 -17
  60. data/spec/application_spec.rb +30 -30
  61. data/spec/configuration_spec.rb +81 -14
  62. data/spec/ephemeral_spec.rb +52 -0
  63. data/spec/host_spec.rb +21 -21
  64. data/spec/noahapp_application_spec.rb +6 -6
  65. data/spec/noahapp_configuration_spec.rb +3 -3
  66. data/spec/noahapp_host_spec.rb +2 -2
  67. data/spec/noahapp_service_spec.rb +9 -9
  68. data/spec/noahapp_watcher_spec.rb +34 -0
  69. data/spec/service_spec.rb +27 -27
  70. data/spec/spec_helper.rb +13 -22
  71. data/spec/support/db/.keep +0 -0
  72. data/spec/support/test-redis.conf +8 -0
  73. data/spec/watcher_spec.rb +62 -0
  74. data/views/index.haml +21 -15
  75. metadata +124 -148
  76. data/Gemfile.lock +0 -85
  77. data/doc/coverage/index.html +0 -138
  78. data/doc/coverage/jquery-1.3.2.min.js +0 -19
  79. data/doc/coverage/jquery.tablesorter.min.js +0 -15
  80. data/doc/coverage/lib-helpers_rb.html +0 -393
  81. data/doc/coverage/lib-models_rb.html +0 -1449
  82. data/doc/coverage/noah_rb.html +0 -2019
  83. data/doc/coverage/print.css +0 -12
  84. data/doc/coverage/rcov.js +0 -42
  85. data/doc/coverage/screen.css +0 -270
  86. data/lib/noah/applications.rb +0 -46
  87. data/lib/noah/configurations.rb +0 -49
  88. data/lib/noah/hosts.rb +0 -54
  89. data/lib/noah/services.rb +0 -57
  90. data/lib/noah/watchers.rb +0 -18
@@ -2,8 +2,8 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Using the Application API", :reset_redis => false do
4
4
  before(:all) do
5
- @a = Application.create(:name => 'rspec_sample_app')
6
- @a.configurations << Configuration.create(:name => 'rspec_config', :format => 'string', :body => 'rspec is great', :application => @a)
5
+ @a = Noah::Application.create(:name => 'rspec_sample_app')
6
+ @a.configurations << Noah::Configuration.create(:name => 'rspec_config', :format => 'string', :body => 'rspec is great', :application => @a)
7
7
  @a.save
8
8
  @c = @a.configurations.first
9
9
  end
@@ -62,8 +62,8 @@ describe "Using the Application API", :reset_redis => false do
62
62
  response["id"].nil?.should == false
63
63
  response["name"].should == @appdata[:name]
64
64
  response["action"].should == "create"
65
- Application.find(:name => @appdata[:name]).size.should == 1
66
- Application.find(:name => @appdata[:name]).first.is_new?.should == true
65
+ Noah::Application.find(:name => @appdata[:name]).size.should == 1
66
+ Noah::Application.find(:name => @appdata[:name]).first.is_new?.should == true
67
67
  end
68
68
  it "new application with missing name should not work" do
69
69
  put "/a/should_not_work", '{"foo":"bar"}', "CONTENT_TYPE" => "application/json"
@@ -79,8 +79,8 @@ describe "Using the Application API", :reset_redis => false do
79
79
  response["id"].nil?.should == false
80
80
  response["name"].should == @appdata[:name]
81
81
  response["action"].should == "update"
82
- Application.find(:name => @appdata[:name]).size.should == 1
83
- Application.find(:name => @appdata[:name]).first.is_new?.should == false
82
+ Noah::Application.find(:name => @appdata[:name]).size.should == 1
83
+ Noah::Application.find(:name => @appdata[:name]).first.is_new?.should == false
84
84
  end
85
85
  end
86
86
 
@@ -85,9 +85,9 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
85
85
 
86
86
  describe "DELETE" do
87
87
  before(:all) do
88
- cparms = {:name => 'a', :format => 'string', :body => 'asdf'}
89
- @a = Application.create(:name => 'delete_test_app')
90
- @a.configurations << Configuration.create(cparms)
88
+ @a = Noah::Application.create(:name => 'delete_test_app')
89
+ cparms = {:name => 'a', :format => 'string', :body => 'asdf', :application_id => @a.id}
90
+ @a.configurations << Noah::Configuration.create(cparms)
91
91
  @a.save
92
92
  @c = @a.configurations.first
93
93
  end
@@ -88,9 +88,9 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
88
88
 
89
89
  describe "DELETE" do
90
90
  before(:all) do
91
- @h = Host.create(:name => 'h', :status => 'up')
91
+ @h = Noah::Host.create(:name => 'h', :status => 'up')
92
92
  sparms = {:name => 's', :status => "up"}
93
- @h.services << Service.create(sparms.merge({:host => @h}))
93
+ @h.services << Noah::Service.create(sparms.merge({:host => @h}))
94
94
  @h.save
95
95
  @s = @h.services.first
96
96
  end
@@ -4,10 +4,10 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
4
4
  before(:all) do
5
5
  @sample_host = {:name => 'rspec_sample_host', :status => 'up'}
6
6
  @sample_service = {:name => 'rspec_sample_service', :status => 'up'}
7
- @h = Host.create(:name => 'rspec_sample_host', :status => 'up')
8
- @h.services << Service.create({:host => @h}.merge(@sample_service))
7
+ @h = Noah::Host.create(:name => 'rspec_sample_host', :status => 'up')
8
+ @h.services << Noah::Service.create({:host => @h}.merge(@sample_service))
9
9
  @h.save
10
- @s = Service.find(@sample_service).first
10
+ @s = Noah::Service.find(@sample_service).first
11
11
  end
12
12
  describe "calling" do
13
13
 
@@ -57,8 +57,8 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
57
57
  response["id"].nil?.should == false
58
58
  response["name"].should == @payload[:name]
59
59
  response["host"].should == @payload[:host]
60
- Service.find(:name => @payload[:name]).size.should == 1
61
- Service.find(:name => @payload[:name]).first.is_new?.should == true
60
+ Noah::Service.find(:name => @payload[:name]).size.should == 1
61
+ Noah::Service.find(:name => @payload[:name]).first.is_new?.should == true
62
62
  end
63
63
  it "new service without host should not work" do
64
64
  put "/s/foobar", {:name => "foobar", :status => "up"}.to_json, "CONTENT_TYPE" => "application/json"
@@ -88,15 +88,15 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
88
88
  response["id"].nil?.should == false
89
89
  response["name"].should == @payload[:name]
90
90
  response["host"].should == @payload[:host]
91
- Service.find(:name => @payload[:name]).size.should == 1
92
- Service.find(:name => @payload[:name]).first.is_new?.should == false
91
+ Noah::Service.find(:name => @payload[:name]).size.should == 1
92
+ Noah::Service.find(:name => @payload[:name]).first.is_new?.should == false
93
93
  end
94
94
  end
95
95
 
96
96
  describe "DELETE" do
97
97
  before(:all) do
98
- @h = Host.create(:name => "h1", :status => "up")
99
- @h.services << Service.create(:name => "s1", :status => "up", :host => @h)
98
+ @h = Noah::Host.create(:name => "h1", :status => "up")
99
+ @h.services << Noah::Service.create(:name => "s1", :status => "up", :host => @h)
100
100
  @h.save
101
101
  @s = @h.services.first
102
102
  end
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Using the Watcher API", :reset_redis => true do
4
+ before(:each) do
5
+ endpoint = 'http://localhost:4567/webhook'
6
+ Ohm.redis.flushdb
7
+ a = Noah::Application.create :name => 'fooapp'
8
+ a.watch! :endpoint => endpoint
9
+ c = Noah::Configuration.create :name => 'fooconfig'
10
+ c.watch! :endpoint => endpoint
11
+ h = Noah::Host.create :name => 'localhost', :status => 'up'
12
+ h.watch! :endpoint => endpoint
13
+ s = Noah::Service.create :name => 'localhostservice', :status => 'up', :host => h
14
+ s.watch! :endpoint => endpoint
15
+ end
16
+
17
+ after(:all) do
18
+ Ohm.redis.flushdb
19
+ end
20
+
21
+ describe "calling" do
22
+
23
+ describe "GET" do
24
+ it "all watches should work" do
25
+ get '/w'
26
+ last_response.should be_ok
27
+ response = last_response.should return_json
28
+ response.is_a?(Array).should == true
29
+ response.size.should == 4
30
+ end
31
+ end
32
+
33
+ end
34
+ end
data/spec/service_spec.rb CHANGED
@@ -8,9 +8,9 @@ describe "Noah Service Model", :reset_redis => true do
8
8
  servicestatus = "up"
9
9
  hostname = "mytesthost1"
10
10
  hoststatus = "up"
11
- host = Host.create(:name => hostname, :status => hoststatus)
11
+ host = Noah::Host.create(:name => hostname, :status => hoststatus)
12
12
  host.save
13
- service = Service.create(:name => servicename, :status => servicestatus, :host => host)
13
+ service = Noah::Service.create(:name => servicename, :status => servicestatus, :host => host)
14
14
  service.valid?.should == true
15
15
  service.save
16
16
  service.name.should == servicename
@@ -20,45 +20,45 @@ describe "Noah Service Model", :reset_redis => true do
20
20
  end
21
21
 
22
22
  it "create a new Service with find_or_create" do
23
- host = Host.create(:name => "h1", :status => "up")
23
+ host = Noah::Host.create(:name => "h1", :status => "up")
24
24
  host.save
25
- service = Service.find_or_create(:name => "s1", :status => "up", :host => host)
25
+ service = Noah::Service.find_or_create(:name => "s1", :status => "up", :host => host)
26
26
  service.save
27
27
  service.is_new?.should == true
28
28
  end
29
29
 
30
30
  it "update an existing Service with find_or_create" do
31
- host = Host.create(:name => "h2", :status => "up")
31
+ host = Noah::Host.create(:name => "h2", :status => "up")
32
32
  host.save
33
- service = Service.find_or_create(:name => "s2", :status => "up", :host => host)
33
+ service = Noah::Service.find_or_create(:name => "s2", :status => "up", :host => host)
34
34
  service.save
35
35
  sleep 1
36
- service2 = Service.find_or_create(:name => "s2", :status => "up", :host => host)
36
+ service2 = Noah::Service.find_or_create(:name => "s2", :status => "up", :host => host)
37
37
  service2.save
38
38
  service2.is_new?.should == false
39
39
  end
40
40
 
41
41
  it "delete a Service" do
42
- h = Host.create(:name => "h1", :status => "up")
42
+ h = Noah::Host.create(:name => "h1", :status => "up")
43
43
  h.save
44
- s = Service.create(:name => "s1", :status => "up", :host => h)
44
+ s = Noah::Service.create(:name => "s1", :status => "up", :host => h)
45
45
  s.save
46
- s = Service.find(:name => "s1").first
46
+ s = Noah::Service.find(:name => "s1").first
47
47
  s.delete
48
- s = Service.find(:name => "s1").first
48
+ s = Noah::Service.find(:name => "s1").first
49
49
  s.should == nil
50
50
  end
51
51
 
52
52
  it "find multiple Services" do
53
- h = Host.create(:name => "h1", :status => "up")
53
+ h = Noah::Host.create(:name => "h1", :status => "up")
54
54
  if h.valid?
55
- h.services << Service.create(:name => "s1", :status => "up", :host => h)
56
- h.services << Service.create(:name => "s2", :status => "up", :host => h)
55
+ h.services << Noah::Service.create(:name => "s1", :status => "up", :host => h)
56
+ h.services << Noah::Service.create(:name => "s2", :status => "up", :host => h)
57
57
  h.save
58
58
  end
59
- Services.all.size.should == 2
60
- Services.all.first.name.should == "s1"
61
- Services.all.last.name.should == "s2"
59
+ Noah::Services.all.size.should == 2
60
+ Noah::Services.all.first.name.should == "s1"
61
+ Noah::Services.all.last.name.should == "s2"
62
62
  end
63
63
 
64
64
  end
@@ -68,41 +68,41 @@ describe "Noah Service Model", :reset_redis => true do
68
68
  it "create a new Service when missing a Host" do
69
69
  servicename = "myservice1"
70
70
  servicestatus = "up"
71
- service = Service.create(:name => servicename, :status => servicestatus)
71
+ service = Noah::Service.create(:name => servicename, :status => servicestatus)
72
72
  service.valid?.should == false
73
73
  service.errors.should == [[:host_id, :not_present]]
74
74
  end
75
75
 
76
76
  it "create a new Service when missing a name" do
77
- host = Host.create(:name => "host1.domain.com", :status => "up")
77
+ host = Noah::Host.create(:name => "host1.domain.com", :status => "up")
78
78
  host.save
79
- service = Service.create(:status => "up", :host => host)
79
+ service = Noah::Service.create(:status => "up", :host => host)
80
80
  service.valid?.should == false
81
81
  service.errors.should == [[:name, :not_present]]
82
82
  end
83
83
 
84
84
  it "create a new Service when missing a status" do
85
- host = Host.create(:name => "host1.domain.com", :status => "up")
85
+ host = Noah::Host.create(:name => "host1.domain.com", :status => "up")
86
86
  host.save
87
- service = Service.create(:name => 'foo', :host => host)
87
+ service = Noah::Service.create(:name => 'foo', :host => host)
88
88
  service.valid?.should == false
89
89
  service.errors.should == [[:status, :not_present], [:status, :not_member]]
90
90
  end
91
91
 
92
92
  it "create a new Service with an invalid status" do
93
- host = Host.create(:name => "host1.domain.com", :status => "up")
93
+ host = Noah::Host.create(:name => "host1.domain.com", :status => "up")
94
94
  host.save
95
- service = Service.create(:name => "myservice", :status => "invalid_status", :host => host)
95
+ service = Noah::Service.create(:name => "myservice", :status => "invalid_status", :host => host)
96
96
  service.valid?.should == false
97
97
  service.errors.should == [[:status, :not_member]]
98
98
  end
99
99
 
100
100
  it "create a duplicate Service" do
101
- host = Host.create(:name => "host1.domain.com", :status => "up")
101
+ host = Noah::Host.create(:name => "host1.domain.com", :status => "up")
102
102
  host.save
103
- s = Service.create(:name => "myservice", :status => "up", :host => host)
103
+ s = Noah::Service.create(:name => "myservice", :status => "up", :host => host)
104
104
  s.save
105
- s1 = Service.create(:name => "myservice", :status => "up", :host => host)
105
+ s1 = Noah::Service.create(:name => "myservice", :status => "up", :host => host)
106
106
  s1.valid?.should == false
107
107
  s1.errors.should == [[[:name, :host_id], :not_unique]]
108
108
  end
data/spec/spec_helper.rb CHANGED
@@ -1,19 +1,10 @@
1
- require 'bundler/setup'
2
- require 'ohm'
3
- begin
4
- require 'yajl'
5
- rescue LoadError
6
- require 'json'
7
- end
8
-
9
- ENV['RACK_ENV'] = 'test'
10
- ENV['REDIS_URL'] = 'redis://localhost:6379/3'
11
- Ohm::connect
12
-
13
1
  require File.join(File.dirname(__FILE__), '..', 'lib', 'noah')
14
2
  require File.join(File.dirname(__FILE__), '..', 'lib', 'noah', 'app')
15
3
  require 'rspec'
16
4
  require 'rack/test'
5
+ ENV['RACK_ENV'] = 'test'
6
+ ENV['REDIS_URL'] = 'redis://localhost:6379/3'
7
+ Ohm::connect
17
8
 
18
9
  RSpec.configure do |config|
19
10
  config.color_enabled = true
@@ -23,19 +14,19 @@ RSpec.configure do |config|
23
14
  config.after(:all, :populate_sample_data => true) {Ohm::redis.flushdb }
24
15
  config.before(:all, :populate_sample_data => true) do
25
16
  Ohm::redis.flushdb
26
- h = Host.create(:name => 'localhost', :status => "up")
17
+ h = Noah::Host.create(:name => 'localhost', :status => "up")
27
18
  if h.save
28
19
  %w[redis noah].each do |service|
29
- s = Service.create(:name => service, :status => "up", :host => h)
20
+ s = Noah::Service.create(:name => service, :status => "up", :host => h)
30
21
  h.services << s
31
22
  end
32
23
  end
33
24
 
34
- a = Application.create(:name => 'noah')
25
+ a = Noah::Application.create(:name => 'noah')
35
26
  if a.save
36
- cr = Configuration.create(:name => 'redis', :format => 'string', :body => 'redis://127.0.0.1:6379/0', :application => a)
37
- ch = Configuration.create(:name => 'host', :format => 'string', :body => 'localhost', :application => a)
38
- cp = Configuration.create(:name => 'port', :format => 'string', :body => '9292', :application => a)
27
+ cr = Noah::Configuration.create(:name => 'redis', :format => 'string', :body => 'redis://127.0.0.1:6379/0', :application => a)
28
+ ch = Noah::Configuration.create(:name => 'host', :format => 'string', :body => 'localhost', :application => a)
29
+ cp = Noah::Configuration.create(:name => 'port', :format => 'string', :body => '9292', :application => a)
39
30
  %w[cr ch cp].each do |c|
40
31
  a.configurations << eval(c)
41
32
  end
@@ -55,15 +46,15 @@ EOY
55
46
  }
56
47
  EOJ
57
48
 
58
- a1 = Application.create(:name => 'myrailsapp1')
49
+ a1 = Noah::Application.create(:name => 'myrailsapp1')
59
50
  if a1.save
60
- c1 = Configuration.create(:name => 'database.yml', :format => 'yaml', :body => my_yaml, :application => a1)
51
+ c1 = Noah::Configuration.create(:name => 'database.yml', :format => 'yaml', :body => my_yaml, :application => a1)
61
52
  a1.configurations << c1
62
53
  end
63
54
 
64
- a2 = Application.create(:name => 'myrestapp1')
55
+ a2 = Noah::Application.create(:name => 'myrestapp1')
65
56
  if a2.save
66
- c2 = Configuration.create(:name => 'config.json', :format => 'json', :body => my_json, :application => a2)
57
+ c2 = Noah::Configuration.create(:name => 'config.json', :format => 'json', :body => my_json, :application => a2)
67
58
  a2.configurations << c2
68
59
  end
69
60
  end
File without changes
@@ -0,0 +1,8 @@
1
+ dir spec/support/db
2
+ pidfile spec/support/db/redis.pid
3
+ port 6379
4
+ timeout 300
5
+ loglevel debug
6
+ logfile stdout
7
+ databases 16
8
+ daemonize yes
@@ -0,0 +1,62 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Using the Watcher Model", :reset_redis => true do
4
+ before(:each) do
5
+ Ohm.redis.flushdb
6
+ @test_endpoint = "http://localhost/webhook"
7
+ @test_pattern = "/foo/bar"
8
+ Noah::Watcher.create :pattern => @test_pattern, :endpoint => @test_webhook
9
+ @test_watch = Noah::Watcher.new :endpoint => "http://localhost/webhook"
10
+ end
11
+ after(:each) do
12
+ #Ohm.redis.flushdb
13
+ end
14
+
15
+ describe "should" do
16
+ it "create a new Noah::Watcher" do
17
+ @test_watch.pattern = "/snarf"
18
+ @test_watch.valid?.should == true
19
+ @test_watch.save
20
+ a = Noah::Watcher.find(:endpoint => @test_watch.endpoint, :pattern => @test_watch.pattern).first
21
+ a.should == @test_watch
22
+ end
23
+ it "delete an existing Noah::Watcher" do
24
+ @test_watch.pattern = "/snarf"
25
+ @test_watch.save
26
+ @test_watch.delete
27
+ Noah::Watcher.find(:endpoint => @test_endpoint, :pattern => @test_pattern).first.should == nil
28
+ end
29
+ end
30
+
31
+ describe "should not" do
32
+ it "create a new Noah::Watcher with missing endpoint" do
33
+ a = Noah::Watcher.create(:pattern => "/foo/bar")
34
+ a.valid?.should == false
35
+ a.errors.to_s.should == "[[:endpoint, :not_present]]"
36
+ end
37
+ it "create a new Noah::Watcher with missing pattern" do
38
+ a = Noah::Watcher.create(:endpoint => "http://localhost/webhook")
39
+ a.valid?.should == false
40
+ a.errors.to_s.should == "[[:pattern, :not_present]]"
41
+ end
42
+ it "create a new Noah::Watcher with subset pattern" do
43
+ a = Noah::Watcher.create(:endpoint => "http://localhost.domain.com/webhook", :pattern => "//noah/")
44
+ b = Noah::Watcher.create(:endpoint => "http://localhost.domain.com/webhook", :pattern => "//noah/foobar")
45
+ b.valid?.should == false
46
+ b.errors.to_s.should == "[[:pattern, :already_provided]]"
47
+ end
48
+ it "create a new Noah::Watcher with superset pattern" do
49
+ a = Noah::Watcher.create(:endpoint => "http://localhost.domain.com/webhook", :pattern => "//noah/foobar")
50
+ b = Noah::Watcher.create(:endpoint => "http://localhost.domain.com/webhook", :pattern => "//noah")
51
+ b.valid?.should == false
52
+ b.errors.to_s.should == "[[:pattern, :replaces_existing]]"
53
+ end
54
+ it "create a duplicate Noah::Watcher" do
55
+ a = Noah::Watcher.create(:endpoint => "http://localhost.domain.com/webhook", :pattern => "//noah/foobar")
56
+ b = Noah::Watcher.create(:endpoint => "http://localhost.domain.com/webhook", :pattern => "//noah/foobar")
57
+ b.valid?.should == false
58
+ b.errors.to_s.should == "[[[:endpoint, :pattern], :not_unique]]"
59
+ end
60
+ end
61
+
62
+ end
data/views/index.haml CHANGED
@@ -4,46 +4,52 @@
4
4
 
5
5
  #header
6
6
  %h1 Sample links
7
+ %h2 System Information
8
+ %ul
9
+ %li
10
+ Noah Version: #{locals[:noah_version]}
11
+ %li
12
+ Redis URL: #{locals[:redis_url]}
7
13
  #header
8
14
  %h2 Hosts
9
15
  %ul
10
16
  %li
11
- %a{:href => "/h/"} All registered Hosts
17
+ %a{:href => "h/"} All registered Hosts
12
18
  %li
13
- %a{:href => "/h/localhost"} localhost (this server)
19
+ %a{:href => "h/localhost"} localhost (this server)
14
20
  %li
15
- %a{:href => "/h/localhost/noah"} localhost noah service
21
+ %a{:href => "h/localhost/noah"} localhost noah service
16
22
  #header
17
23
  %h2 Services
18
24
  %ul
19
25
  %li
20
- %a{:href => "/s/"} All registered Services
26
+ %a{:href => "s/"} All registered Services
21
27
  %li
22
- %a{:href => "/s/http"} All hosts providing 'http'
28
+ %a{:href => "s/http"} All hosts providing 'http'
23
29
  %li
24
- %a{:href => "/s/noah/localhost"} localhost noah service
30
+ %a{:href => "s/noah/localhost"} localhost noah service
25
31
  #header
26
32
  %h2 Applications
27
33
  %ul
28
34
  %li
29
- %a{:href => "/a/"} All registered Applications
35
+ %a{:href => "a/"} All registered Applications
30
36
  %li
31
- %a{:href => "/a/noah"} Noah Application entry
37
+ %a{:href => "a/noah"} Noah Application entry
32
38
  %li
33
- %a{:href => "/a/noah/redis"} Noah Redis configuration entry
39
+ %a{:href => "a/noah/redis"} Noah Redis configuration entry
34
40
  #header
35
41
  %h2 Configurations
36
42
  %ul
37
43
  %li
38
- %a{:href => "/c/"} All registered Configurations
44
+ %a{:href => "c/"} All registered Configurations
39
45
  %li
40
- %a{:href => "/c/noah"} Noah Configuration entry
46
+ %a{:href => "c/noah"} Noah Configuration entry
41
47
  %li
42
- %a{:href => "/c/myrailsapp1"} myrailsapp1 Configuration entry
48
+ %a{:href => "c/myrailsapp1"} myrailsapp1 Configuration entry
43
49
  %li
44
- %a{:href => "/c/myrestapp1"} myrestapp1 Configuration entry
50
+ %a{:href => "c/myrestapp1"} myrestapp1 Configuration entry
45
51
  %li
46
- %a{:href => "/c/myrailsapp1/database.yml"} database.yml file for myrailsapp1 (should return the proper content-type)
52
+ %a{:href => "c/myrailsapp1/database.yml"} database.yml file for myrailsapp1 (should return the proper content-type)
47
53
  %li
48
- %a{:href => "/c/myrestapp1/config.json"} config.json file for myrestapp1
54
+ %a{:href => "c/myrestapp1/config.json"} config.json file for myrestapp1
49
55