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
@@ -0,0 +1,61 @@
1
+ require 'hiredis/reader'
2
+
3
+ module EM::Hiredis
4
+ class Connection < EM::Connection
5
+ include EM::Hiredis::EventEmitter
6
+
7
+ def initialize(host, port)
8
+ super
9
+ @host, @port = host, port
10
+ end
11
+
12
+ def connection_completed
13
+ EM::Hiredis.logger.info("Connected to Redis")
14
+ @reader = ::Hiredis::Reader.new
15
+ emit(:connected)
16
+ end
17
+
18
+ def receive_data(data)
19
+ @reader.feed(data)
20
+ until (reply = @reader.gets) == false
21
+ emit(:message, reply)
22
+ end
23
+ end
24
+
25
+ def unbind
26
+ EM::Hiredis.logger.info("Disconnected from Redis")
27
+ emit(:closed)
28
+ end
29
+
30
+ def send_command(sym, *args)
31
+ send_data(command(sym, *args))
32
+ end
33
+
34
+ protected
35
+
36
+ COMMAND_DELIMITER = "\r\n"
37
+
38
+ def command(*args)
39
+ command = []
40
+ command << "*#{args.size}"
41
+
42
+ args.each do |arg|
43
+ arg = arg.to_s
44
+ command << "$#{string_size arg}"
45
+ command << arg
46
+ end
47
+
48
+ command.join(COMMAND_DELIMITER) + COMMAND_DELIMITER
49
+ end
50
+
51
+ if "".respond_to?(:bytesize)
52
+ def string_size(string)
53
+ string.to_s.bytesize
54
+ end
55
+ else
56
+ def string_size(string)
57
+ string.to_s.size
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,29 @@
1
+ module EM::Hiredis
2
+ module EventEmitter
3
+ def on(event, &listener)
4
+ _listeners[event] << listener
5
+ end
6
+
7
+ def emit(event, *args)
8
+ _listeners[event].each { |l| l.call(*args) }
9
+ end
10
+
11
+ def remove_listener(event, &listener)
12
+ _listeners[event].delete(listener)
13
+ end
14
+
15
+ def remove_all_listeners(event)
16
+ _listeners.delete(event)
17
+ end
18
+
19
+ def listeners(event)
20
+ _listeners[event]
21
+ end
22
+
23
+ private
24
+
25
+ def _listeners
26
+ @_listeners ||= Hash.new { |h,k| h[k] = [] }
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ module EM
2
+ module Hiredis
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
data/noah.gemspec CHANGED
@@ -5,8 +5,8 @@ require "noah/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "noah"
7
7
  s.version = Noah::VERSION
8
- s.platform = RUBY_ENGINE
9
- s.authors = ["lusis"]
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["John E. Vincent"]
10
10
  s.email = ["lusis.org+rubygems.org@gmail.com"]
11
11
  s.homepage = "https://github.com/lusis/noah"
12
12
  s.summary = %q{Application registry based on Apache Zookeeper}
@@ -19,26 +19,30 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency("rake", ["= 0.8.7"])
22
+ s.add_dependency("hiredis", ["= 0.3.1"])
23
+ s.add_dependency("redis", ["= 2.1.1"])
24
+ s.add_dependency("nest", ["= 1.1.0"])
25
+ s.add_dependency("rack", ["= 1.2.1"])
26
+ s.add_dependency("tilt", ["= 1.2.2"])
23
27
  s.add_dependency("sinatra", ["= 1.1.2"])
24
- s.add_dependency("sinatra-namespace", ["0.6.1"])
25
28
  s.add_dependency("ohm", ["= 0.1.3"])
26
- s.add_dependency("ohm-contrib", ["= 0.1.0"])
29
+ s.add_dependency("ohm-contrib", ["= 0.1.1"])
27
30
  s.add_dependency("haml", ["= 3.0.25"])
28
31
  s.add_dependency("vegas", ["= 0.1.8"])
29
- s.add_dependency("yajl-ruby", ["= 0.7.9"]) if s.platform.to_s == 'ruby'
30
- s.add_dependency("jruby-json", ["= 1.5.0"]) if s.platform.to_s == 'jruby'
31
- s.add_dependency("thin", ["= 1.2.7"]) if s.platform.to_s == 'ruby'
32
- s.add_dependency("json-jruby", ["= 1.4.6"]) if s.platform.to_s == 'jruby'
33
- s.add_dependency("jruby-openssl", ["= 0.7.3"]) if s.platform.to_s == 'jruby'
34
32
 
33
+
34
+ if RUBY_PLATFORM =~ /java/
35
+ s.add_dependency("jruby-openssl")
36
+ s.add_dependency("json")
37
+ s.add_development_dependency("warbler", ["= 1.2.1"])
38
+ else
39
+ s.add_dependency("yajl-ruby")
40
+ s.add_dependency("thin")
41
+ end
42
+
43
+ s.add_development_dependency("diff-lcs", ["= 1.1.2"])
35
44
  s.add_development_dependency("sinatra-reloader", ["= 0.5.0"])
36
- s.add_development_dependency("rspec", ["= 2.4.0"])
37
- s.add_development_dependency("rcov", ["= 0.9.9"]) if s.platform.to_s == 'ruby'
45
+ s.add_development_dependency("rspec", ["~> 2.5"])
46
+ s.add_development_dependency("rcov", ["= 0.9.9"])
38
47
  s.add_development_dependency("rack-test", ["= 0.5.7"])
39
- s.add_development_dependency("ZenTest", ["= 4.4.2"])
40
- s.add_development_dependency("autotest", ["= 4.4.6"])
41
- s.add_development_dependency("autotest-growl", ["= 0.2.9"])
42
- s.add_development_dependency("warbler", ["= 1.2.1"]) if s.platform.to_s == 'java'
43
-
44
48
  end
@@ -14,52 +14,52 @@ describe "Using the Application Model", :reset_redis => true do
14
14
  Ohm.redis.flushdb
15
15
  end
16
16
  describe "should" do
17
- it "create a new Application" do
18
- a = Application.create(@appdata1)
17
+ it "create a new Noah::Application" do
18
+ a = Noah::Application.create(@appdata1)
19
19
  a.valid?.should == true
20
20
  a.is_new?.should == true
21
- b = Application.find(@appdata1).first
21
+ b = Noah::Application.find(@appdata1).first
22
22
  b.should == a
23
23
  end
24
- it "create a new Application with Configurations" do
25
- a = Application.create(@appdata1)
26
- a.configurations << Configuration.create(@appconf_string.merge({:application => a}))
24
+ it "create a new Noah::Application with Configurations" do
25
+ a = Noah::Application.create(@appdata1)
26
+ a.configurations << Noah::Configuration.create(@appconf_string.merge({:application => a}))
27
27
  a.valid?.should == true
28
28
  a.is_new?.should == true
29
29
  a.save
30
- b = Application.find(@appdata1).first
30
+ b = Noah::Application.find(@appdata1).first
31
31
  b.should == a
32
32
  b.configurations.size.should == 1
33
33
  b.configurations.first.name.should == @appconf_string[:name]
34
34
  b.configurations.first.format.should == @appconf_string[:format]
35
35
  b.configurations.first.body.should == @appconf_string[:body]
36
36
  end
37
- it "create a new Application via find_or_create" do
38
- a = Application.find_or_create(@appdata2)
37
+ it "create a new Noah::Application via find_or_create" do
38
+ a = Noah::Application.find_or_create(@appdata2)
39
39
  a.valid?.should == true
40
40
  a.is_new?.should == true
41
- b = Application.find(@appdata2).first
41
+ b = Noah::Application.find(@appdata2).first
42
42
  b.should == a
43
43
  end
44
- it "update an existing Application via find_or_create" do
45
- a = Application.create(@appdata1)
44
+ it "update an existing Noah::Application via find_or_create" do
45
+ a = Noah::Application.create(@appdata1)
46
46
  a.is_new?.should == true
47
47
  sleep 2
48
- b = Application.find_or_create(@appdata1)
48
+ b = Noah::Application.find_or_create(@appdata1)
49
49
  b.is_new?.should == false
50
50
  end
51
- it "delete an existing Application" do
52
- a = Application.create(@appdata1)
53
- b = Application.find(@appdata1).first
51
+ it "delete an existing Noah::Application" do
52
+ a = Noah::Application.create(@appdata1)
53
+ b = Noah::Application.find(@appdata1).first
54
54
  b.should == a
55
55
  b.delete
56
- c = Application.find(@appdata1).first
56
+ c = Noah::Application.find(@appdata1).first
57
57
  c.nil?.should == true
58
58
  end
59
- it "return all Applications" do
60
- a = Application.create(@appdata1)
61
- b = Application.create(@appdata2)
62
- c = Applications.all
59
+ it "return all Noah::Applications" do
60
+ a = Noah::Application.create(@appdata1)
61
+ b = Noah::Application.create(@appdata2)
62
+ c = Noah::Applications.all
63
63
  c.size.should == 2
64
64
  c.member?(a).should == true
65
65
  c.member?(b).should == true
@@ -67,17 +67,17 @@ describe "Using the Application Model", :reset_redis => true do
67
67
  end
68
68
 
69
69
  describe "should not" do
70
- it "should not create a new Application without a name" do
71
- a = Application.create
70
+ it "should not create a new Noah::Application without a name" do
71
+ a = Noah::Application.create
72
72
  a.valid?.should == false
73
73
  a.errors.should == [[:name, :not_present]]
74
74
  end
75
- it "should not create a duplicate Application" do
76
- a = Application.create(@appdata1)
77
- a.valid?.should == true
78
- b = Application.create(@appdata1)
79
- b.valid?.should == false
80
- b.errors.should == [[:name, :not_unique]]
81
- end
75
+ # it "should not create a duplicate Noah::Application" do
76
+ # a = Noah::Application.create(@appdata1)
77
+ # a.valid?.should == true
78
+ # b = Noah::Application.create(@appdata1)
79
+ # b.valid?.should == false
80
+ # b.errors.should == [[:name, :not_unique]]
81
+ # end
82
82
  end
83
83
  end
@@ -1,25 +1,92 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Using the Configuration Model", :reset_redis => true do
4
+ before(:all) do
5
+ app = Noah::Application.create(:name => "my_application")
6
+ app.save
7
+ @appconf_string = {:name => "mystringconf", :format => "string", :body => "some_var", :application_id => app.id}
8
+ @appconf_json = {:name => "myjsonconf", :format => "json", :body => @appconf_string.to_json, :application_id => app.id}
9
+ @appconf_missing_name = @appconf_string.reject {|x| x == :name}
10
+ @appconf_missing_format = @appconf_string.reject {|x| x == :format}
11
+ @appconf_missing_body = @appconf_string.reject {|x| x == :body}
12
+ @appconf_missing_application = @appconf_string.reject {|x| x == :application_id}
13
+ end
14
+ before(:each) do
15
+ Ohm.redis.flushdb
16
+ end
17
+ after(:each) do
18
+ Ohm.redis.flushdb
19
+ end
4
20
 
5
21
  describe "should" do
6
-
7
- it "create a new Configuration"
8
- it "create a new Configuration via find_or_create"
9
- it "update an existing Configuration via find_or_create"
10
- it "delete an existing Configuration"
11
- it "return all Configurations"
12
-
22
+ it "create a new Configuration" do
23
+ c = Noah::Configuration.create(@appconf_string)
24
+ c.valid?.should == true
25
+ c.is_new?.should == true
26
+ b = Noah::Configuration[c.id]
27
+ b.should == c
28
+ end
29
+ it "create a new Configuration via find_or_create" do
30
+ c = Noah::Configuration.find_or_create(@appconf_string)
31
+ c.valid?.should == true
32
+ c.is_new?.should == true
33
+ a = Noah::Configuration[c.id]
34
+ a.should == c
35
+ end
36
+ it "update an existing Configuration via find_or_create" do
37
+ c = Noah::Configuration.find_or_create(@appconf_string)
38
+ c.valid?.should == true
39
+ c.is_new?.should == true
40
+ sleep(3)
41
+ c.body = "some_other_var"
42
+ c.save
43
+ c.body.should == "some_other_var"
44
+ c.is_new?.should == false
45
+ end
46
+ it "delete an existing Configuration" do
47
+ a = Noah::Configuration.find_or_create(@appconf_string)
48
+ b = Noah::Configuration.find(@appconf_string).first
49
+ b.should == a
50
+ a.delete
51
+ c = Noah::Configuration.find(@appconf_string).first
52
+ c.nil?.should == true
53
+ end
54
+ it "return all Configurations" do
55
+ a = Noah::Configuration.find_or_create(@appconf_string)
56
+ b = Noah::Configuration.find_or_create(@appconf_json)
57
+ c = Noah::Configurations.all
58
+ c.size.should == 2
59
+ c.member?(a).should == true
60
+ c.member?(b).should == true
61
+ end
13
62
  end
14
63
 
15
64
  describe "should not" do
16
-
17
- it "create a new Configuration without a name"
18
- it "create a new Configuration without a format"
19
- it "create a new Configuration without a body"
20
- it "create a new Configuration without an Application"
21
- it "create a duplicate Configuration"
22
-
65
+ it "create a new Configuration without a name" do
66
+ a = Noah::Configuration.create(@appconf_missing_name)
67
+ a.valid?.should == false
68
+ a.errors.should == [[:name, :not_present]]
69
+ end
70
+ it "create a new Configuration without a format" do
71
+ a = Noah::Configuration.create(@appconf_missing_format)
72
+ a.valid?.should == false
73
+ a.errors.should == [[:format, :not_present]]
74
+ end
75
+ it "create a new Configuration without a body" do
76
+ a = Noah::Configuration.create(@appconf_missing_body)
77
+ a.valid?.should == false
78
+ a.errors.should == [[:body, :not_present]]
79
+ end
80
+ it "create a new Confguration without an application" do
81
+ a = Noah::Configuration.create(@appconf_missing_application)
82
+ a.valid?.should == false
83
+ a.errors.should == [[:application_id, :not_present]]
84
+ end
85
+ it "create a duplicate Configuration" do
86
+ a = Noah::Configuration.create(@appconf_string)
87
+ b = Noah::Configuration.create(@appconf_string)
88
+ b.errors.should == [[[:name, :application_id], :not_unique]]
89
+ end
23
90
  end
24
91
 
25
92
  end
@@ -0,0 +1,52 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Using the Ephemeral Model", :reset_redis => true do
4
+ before(:all) do
5
+ @edata = {:path => "/foo/bar/baz", :data => "some_value"}
6
+ @emissing_path = @edata.reject {|x| x == :path}
7
+ @emissing_data = @edata.reject {|x| x == :data}
8
+ @good_ephemeral = Noah::Ephemeral.new(@edata)
9
+ @missing_path = Noah::Ephemeral.new(@emissing_path)
10
+ @missing_data = Noah::Ephemeral.new(@emissing_data)
11
+ end
12
+ before(:each) do
13
+ Ohm.redis.flushdb
14
+ end
15
+ after(:each) do
16
+ Ohm.redis.flushdb
17
+ end
18
+ describe "should" do
19
+ it "create a new Noah::Ephemeral" do
20
+ @good_ephemeral.valid?.should == true
21
+ @good_ephemeral.save
22
+ b = Noah::Ephemeral[@good_ephemeral.id]
23
+ b.should == @good_ephemeral
24
+ end
25
+ it "create a new Noah::Ephemeral with missing data" do
26
+ @missing_data.valid?.should == true
27
+ @missing_data.save
28
+ b = Noah::Ephemeral[@missing_data.id]
29
+ b.should == @missing_data
30
+ end
31
+ # it "update an existing Noah::Ephemeral" do
32
+ # @good_ephemeral.save
33
+ # Noah::Ephemeral.all.size.should == 1
34
+ # c = Noah::Ephemeral[@good_ephemeral.id]
35
+ # c.data = "updated_data"
36
+ # c.save
37
+ # sleep(2)
38
+ # c.is_new?.should == false
39
+ # end
40
+ it "delete an existing Noah::Ephemeral" do
41
+ @good_ephemeral.save
42
+ @good_ephemeral.delete
43
+ Noah::Ephemeral[@good_ephemeral.id].should == nil
44
+ end
45
+ end
46
+ describe "should not" do
47
+ it "create a new Noah::Ephemeral with missing path" do
48
+ @missing_path.valid?.should == false
49
+ @missing_path.errors.should == [[:path, :not_present]]
50
+ end
51
+ end
52
+ end
data/spec/host_spec.rb CHANGED
@@ -6,7 +6,7 @@ describe "Using the Host Model", :reset_redis => true do
6
6
  it "create a new Host with no services" do
7
7
  hostname = "host1.domain.com"
8
8
  hoststatus = "up"
9
- host = Host.create(:name => hostname, :status => hoststatus)
9
+ host = Noah::Host.create(:name => hostname, :status => hoststatus)
10
10
  host.valid?.should == true
11
11
  host.save
12
12
  host.name.should == hostname
@@ -19,10 +19,10 @@ describe "Using the Host Model", :reset_redis => true do
19
19
  hoststatus = "down"
20
20
  servicename = 'myservice'
21
21
  servicestatus = 'pending'
22
- host = Host.create(:name => hostname, :status => hoststatus)
22
+ host = Noah::Host.create(:name => hostname, :status => hoststatus)
23
23
  host.valid?.should == true
24
24
  host.save
25
- host.services << Service.create(:name => servicename, :status => servicestatus, :host => host)
25
+ host.services << Noah::Service.create(:name => servicename, :status => servicestatus, :host => host)
26
26
  host.name.should == hostname
27
27
  host.status.should == hoststatus
28
28
  host.services.size.should == 1
@@ -35,7 +35,7 @@ describe "Using the Host Model", :reset_redis => true do
35
35
  it "create a Host via find_or_create" do
36
36
  hostname = "host3.domain.com"
37
37
  hoststatus = "up"
38
- host = Host.find_or_create(:name => hostname, :status => hoststatus)
38
+ host = Noah::Host.find_or_create(:name => hostname, :status => hoststatus)
39
39
  host.valid?.should == true
40
40
  host.save
41
41
  host.is_new?.should == true
@@ -45,12 +45,12 @@ describe "Using the Host Model", :reset_redis => true do
45
45
  hostname = "host3.domain.com"
46
46
  hoststatus = "pending"
47
47
  newstatus = "down"
48
- host = Host.find_or_create(:name => hostname, :status => hoststatus)
48
+ host = Noah::Host.find_or_create(:name => hostname, :status => hoststatus)
49
49
  host.valid?.should == true
50
50
  host.save
51
51
  host.is_new?.should == true
52
52
  sleep 1
53
- host1 = Host.find_or_create(:name => hostname, :status => newstatus)
53
+ host1 = Noah::Host.find_or_create(:name => hostname, :status => newstatus)
54
54
  host1.save
55
55
  host1.is_new?.should == false
56
56
  end
@@ -58,10 +58,10 @@ describe "Using the Host Model", :reset_redis => true do
58
58
  it "delete a Host" do
59
59
  hostname = "host3.domain.com"
60
60
  hoststatus = "pending"
61
- host = Host.create(:name => hostname, :status => hoststatus)
61
+ host = Noah::Host.create(:name => hostname, :status => hoststatus)
62
62
  host.save
63
63
  host.delete
64
- Host.find(:name => hostname).empty?.should == true
64
+ Noah::Host.find(:name => hostname).empty?.should == true
65
65
  end
66
66
 
67
67
  it "should return all Hosts" do
@@ -69,30 +69,30 @@ describe "Using the Host Model", :reset_redis => true do
69
69
  status1 = "up"
70
70
  hostname2 = "host2.domain.com"
71
71
  status2= "down"
72
- host1 = Host.create(:name => hostname1, :status => status1)
73
- host2 = Host.create(:name => hostname2, :status => status2)
72
+ host1 = Noah::Host.create(:name => hostname1, :status => status1)
73
+ host2 = Noah::Host.create(:name => hostname2, :status => status2)
74
74
  host1.save
75
75
  host2.save
76
- Hosts.all.class.should == Array
77
- Hosts.all.size.should == 2
78
- Hosts.all.first.name.should == hostname1
79
- Hosts.all.first.status.should == status1
80
- Hosts.all.last.name.should == hostname2
81
- Hosts.all.last.status.should == status2
76
+ Noah::Hosts.all.class.should == Array
77
+ Noah::Hosts.all.size.should == 2
78
+ Noah::Hosts.all.first.name.should == hostname1
79
+ Noah::Hosts.all.first.status.should == status1
80
+ Noah::Hosts.all.last.name.should == hostname2
81
+ Noah::Hosts.all.last.status.should == status2
82
82
  end
83
83
  end
84
84
 
85
85
  describe "should not" do
86
86
  it "create a new Host with missing status" do
87
87
  hostname ="host3.domain.com"
88
- host = Host.create(:name => hostname)
88
+ host = Noah::Host.create(:name => hostname)
89
89
  host.valid?.should == false
90
90
  host.errors.should == [[:status, :not_present], [:status, :not_member]]
91
91
  end
92
92
 
93
93
  it "create a new Host with missing hostname" do
94
94
  status = "up"
95
- host = Host.create(:status => status)
95
+ host = Noah::Host.create(:status => status)
96
96
  host.valid?.should == false
97
97
  host.errors.should == [[:name, :not_present]]
98
98
  end
@@ -100,7 +100,7 @@ describe "Using the Host Model", :reset_redis => true do
100
100
  it "create a new Host with an invalid status" do
101
101
  hostname = "host3.domain.com"
102
102
  status = "online"
103
- host = Host.create(:name => hostname, :status => status)
103
+ host = Noah::Host.create(:name => hostname, :status => status)
104
104
  host.valid?.should == false
105
105
  host.errors.should == [[:status, :not_member]]
106
106
  end
@@ -108,9 +108,9 @@ describe "Using the Host Model", :reset_redis => true do
108
108
  it "create a duplicate Host" do
109
109
  hostname = "host1.domain.com"
110
110
  status = "up"
111
- host1 = Host.create(:name => hostname, :status => status)
111
+ host1 = Noah::Host.create(:name => hostname, :status => status)
112
112
  host1.save
113
- host2 = Host.create(:name => hostname, :status => status)
113
+ host2 = Noah::Host.create(:name => hostname, :status => status)
114
114
  host2.valid?.should == false
115
115
  host2.errors.should == [[:name, :not_unique]]
116
116
  end