Commit bad01f0d authored by John E. Vincent's avatar John E. Vincent

quick cleanup of test structure

parent 9fc817d8
......@@ -48,46 +48,30 @@
<tfoot>
<tr>
<td class="left_align">TOTAL</td>
<td class='right_align'><tt>610</tt></td>
<td class='right_align'><tt>518</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>55.25%</tt></div>
<td class='right_align'><tt>612</tt></td>
<td class='right_align'><tt>521</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>83.33%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:55px"></div>
<div class="uncovered" style="width:45px"></div>
<div class="covered" style="width:83px"></div>
<div class="uncovered" style="width:17px"></div>
</div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class='coverage_total'>50.58%</tt></div>
<td class="left_align"><div class="percent_graph_legend"><tt class='coverage_total'>81.96%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:51px"></div>
<div class="uncovered" style="width:49px"></div>
<div class="covered" style="width:82px"></div>
<div class="uncovered" style="width:18px"></div>
</div></td>
</tr>
</tfoot>
<tbody>
<tr class="all_files all_coverage 50 60 70 80 90 100 even">
<td class="left_align"><a href="noah_rb.html">noah.rb</a></td>
<td class='right_align'><tt>325</tt></td>
<td class='right_align'><tt>283</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>48.31%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:48px"></div>
<div class="uncovered" style="width:52px"></div>
</div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>42.40%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:42px"></div>
<div class="uncovered" style="width:58px"></div>
</div></td>
</tr>
<tr class="all_files all_coverage 60 70 80 90 100 lib odd">
<tr class="all_files all_coverage 60 70 80 90 100 lib even">
<td class="left_align"><a href="lib-helpers_rb.html">lib/helpers.rb</a></td>
<td class='right_align'><tt>55</tt></td>
<td class='right_align'><tt>45</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>54.55%</tt></div>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>56.36%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:55px"></div>
<div class="uncovered" style="width:45px"></div>
<div class="covered" style="width:56px"></div>
<div class="uncovered" style="width:44px"></div>
</div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>57.78%</tt></div>
<div class="percent_graph">
......@@ -96,19 +80,35 @@
</div></td>
</tr>
<tr class="all_files all_coverage 70 80 90 100 lib even">
<tr class="all_files all_coverage 90 100 odd">
<td class="left_align"><a href="noah_rb.html">noah.rb</a></td>
<td class='right_align'><tt>326</tt></td>
<td class='right_align'><tt>285</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>82.52%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:83px"></div>
<div class="uncovered" style="width:17px"></div>
</div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>81.05%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:81px"></div>
<div class="uncovered" style="width:19px"></div>
</div></td>
</tr>
<tr class="all_files all_coverage 90 100 lib even">
<td class="left_align"><a href="lib-models_rb.html">lib/models.rb</a></td>
<td class='right_align'><tt>230</tt></td>
<td class='right_align'><tt>190</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>65.22%</tt></div>
<td class='right_align'><tt>231</tt></td>
<td class='right_align'><tt>191</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>90.91%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:65px"></div>
<div class="uncovered" style="width:35px"></div>
<div class="covered" style="width:91px"></div>
<div class="uncovered" style="width:9px"></div>
</div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>61.05%</tt></div>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>89.01%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:61px"></div>
<div class="uncovered" style="width:39px"></div>
<div class="covered" style="width:89px"></div>
<div class="uncovered" style="width:11px"></div>
</div></td>
</tr>
......@@ -116,7 +116,7 @@
</table>
</div>
<p>Generated on 2011-01-27 21:32:12 -0500 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p>
<p>Generated on 2011-01-31 05:03:32 -0500 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p>
<script type="text/javascript">
$(document).ready(function(){$("#report_table").tablesorter({widgets: ['zebra'], textExtraction: 'complex'});});
......
......@@ -30,10 +30,10 @@
<td class="left_align"><a href="lib-helpers_rb.html">lib/helpers.rb</a></td>
<td class='right_align'><tt>55</tt></td>
<td class='right_align'><tt>45</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>54.55%</tt></div>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>56.36%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:55px"></div>
<div class="uncovered" style="width:45px"></div>
<div class="covered" style="width:56px"></div>
<div class="uncovered" style="width:44px"></div>
</div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>57.78%</tt></div>
<div class="percent_graph">
......@@ -158,13 +158,13 @@
<tr class="inferred">
<tr class="marked">
<td><pre><a name="line18">18</a> end </pre></td>
</tr>
<tr class="uncovered">
<tr class="marked">
<td><pre><a name="line19">19</a> </pre></td>
</tr>
......@@ -387,7 +387,7 @@
</tbody>
</table>
<p>Generated on 2011-01-27 21:32:12 -0500 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p>
<p>Generated on 2011-01-31 05:03:32 -0500 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Noah Host Model", :reset_redis => true do
describe "Using the Host Model", :reset_redis => true do
it "should create a new Host with no services" do
hostname = "host1.domain.com"
hoststatus = "up"
host = Host.create(:name => hostname, :status => hoststatus)
host.valid?.should == true
host.save
host.name.should == hostname
host.status.should == hoststatus
host.services.size.should == 0
end
describe "should" do
it "create a new Host with no services" do
hostname = "host1.domain.com"
hoststatus = "up"
host = Host.create(:name => hostname, :status => hoststatus)
host.valid?.should == true
host.save
host.name.should == hostname
host.status.should == hoststatus
host.services.size.should == 0
end
it "should create a new Host with services" do
hostname = "host2.domain.com"
hoststatus = "down"
servicename = 'myservice'
servicestatus = 'pending'
host = Host.create(:name => hostname, :status => hoststatus)
host.valid?.should == true
host.save
host.services << Service.create(:name => servicename, :status => servicestatus, :host => host)
host.name.should == hostname
host.status.should == hoststatus
host.services.size.should == 1
host.services[1].valid?.should == true
host.services[1].name.should == servicename
host.services[1].status.should == servicestatus
host.services[1].host_id.should == host.id
end
it "create a new Host with services" do
hostname = "host2.domain.com"
hoststatus = "down"
servicename = 'myservice'
servicestatus = 'pending'
host = Host.create(:name => hostname, :status => hoststatus)
host.valid?.should == true
host.save
host.services << Service.create(:name => servicename, :status => servicestatus, :host => host)
host.name.should == hostname
host.status.should == hoststatus
host.services.size.should == 1
host.services[1].valid?.should == true
host.services[1].name.should == servicename
host.services[1].status.should == servicestatus
host.services[1].host_id.should == host.id
end
it "should create a Host via find_or_create" do
hostname = "host3.domain.com"
hoststatus = "up"
host = Host.find_or_create(:name => hostname, :status => hoststatus)
host.valid?.should == true
host.save
host.is_new?.should == true
end
it "create a Host via find_or_create" do
hostname = "host3.domain.com"
hoststatus = "up"
host = Host.find_or_create(:name => hostname, :status => hoststatus)
host.valid?.should == true
host.save
host.is_new?.should == true
end
it "should update a Host via find_or_create" do
hostname = "host3.domain.com"
hoststatus = "pending"
newstatus = "down"
host = Host.find_or_create(:name => hostname, :status => hoststatus)
host.valid?.should == true
host.save
host.is_new?.should == true
sleep 1
host1 = Host.find_or_create(:name => hostname, :status => newstatus)
host1.save
host1.is_new?.should == false
end
it "update a Host via find_or_create" do
hostname = "host3.domain.com"
hoststatus = "pending"
newstatus = "down"
host = Host.find_or_create(:name => hostname, :status => hoststatus)
host.valid?.should == true
host.save
host.is_new?.should == true
sleep 1
host1 = Host.find_or_create(:name => hostname, :status => newstatus)
host1.save
host1.is_new?.should == false
end
it "should delete a Host" do
hostname = "host3.domain.com"
hoststatus = "pending"
host = Host.create(:name => hostname, :status => hoststatus)
host.save
host.delete
Host.find(:name => hostname).empty?.should == true
end
it "delete a Host" do
hostname = "host3.domain.com"
hoststatus = "pending"
host = Host.create(:name => hostname, :status => hoststatus)
host.save
host.delete
Host.find(:name => hostname).empty?.should == true
end
it "should not create a new Host with missing status" do
hostname ="host3.domain.com"
host = Host.create(:name => hostname)
host.valid?.should == false
host.errors.should == [[:status, :not_present], [:status, :not_member]]
it "should return all Hosts" do
hostname1 = "host1.domain.com"
status1 = "up"
hostname2 = "host2.domain.com"
status2= "down"
host1 = Host.create(:name => hostname1, :status => status1)
host2 = Host.create(:name => hostname2, :status => status2)
host1.save
host2.save
Hosts.all.class.should == Array
Hosts.all.size.should == 2
Hosts.all.first.name.should == hostname1
Hosts.all.first.status.should == status1
Hosts.all.last.name.should == hostname2
Hosts.all.last.status.should == status2
end
end
it "should not create a new Host with missing hostname" do
status = "up"
host = Host.create(:status => status)
host.valid?.should == false
host.errors.should == [[:name, :not_present]]
end
describe "should not" do
it "create a new Host with missing status" do
hostname ="host3.domain.com"
host = Host.create(:name => hostname)
host.valid?.should == false
host.errors.should == [[:status, :not_present], [:status, :not_member]]
end
it "should not create a new Host with an invalid status" do
hostname = "host3.domain.com"
status = "online"
host = Host.create(:name => hostname, :status => status)
host.valid?.should == false
host.errors.should == [[:status, :not_member]]
end
it "create a new Host with missing hostname" do
status = "up"
host = Host.create(:status => status)
host.valid?.should == false
host.errors.should == [[:name, :not_present]]
end
it "should not create a duplicate Host" do
hostname = "host1.domain.com"
status = "up"
host1 = Host.create(:name => hostname, :status => status)
host1.save
host2 = Host.create(:name => hostname, :status => status)
host2.valid?.should == false
host2.errors.should == [[:name, :not_unique]]
end
it "create a new Host with an invalid status" do
hostname = "host3.domain.com"
status = "online"
host = Host.create(:name => hostname, :status => status)
host.valid?.should == false
host.errors.should == [[:status, :not_member]]
end
it "should return all Hosts" do
hostname1 = "host1.domain.com"
status1 = "up"
hostname2 = "host2.domain.com"
status2= "down"
host1 = Host.create(:name => hostname1, :status => status1)
host2 = Host.create(:name => hostname2, :status => status2)
host1.save
host2.save
Hosts.all.class.should == Array
Hosts.all.size.should == 2
Hosts.all.first.name.should == hostname1
Hosts.all.first.status.should == status1
Hosts.all.last.name.should == hostname2
Hosts.all.last.status.should == status2
it "create a duplicate Host" do
hostname = "host1.domain.com"
status = "up"
host1 = Host.create(:name => hostname, :status => status)
host1.save
host2 = Host.create(:name => hostname, :status => status)
host2.valid?.should == false
host2.errors.should == [[:name, :not_unique]]
end
end
end
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Noah Service Model", :reset_redis => true do
describe "should" do
it "should create a new Service" do
servicename = "myservice"
servicestatus = "up"
hostname = "mytesthost1"
hoststatus = "up"
host = Host.create(:name => hostname, :status => hoststatus)
host.save
service = Service.create(:name => servicename, :status => servicestatus, :host => host)
service.valid?.should == true
service.save
service.name.should == servicename
service.status.should == servicestatus
service.host_id.should == host.id
host.services[1].name.should == servicename
end
it "create a new Service" do
servicename = "myservice"
servicestatus = "up"
hostname = "mytesthost1"
hoststatus = "up"
host = Host.create(:name => hostname, :status => hoststatus)
host.save
service = Service.create(:name => servicename, :status => servicestatus, :host => host)
service.valid?.should == true
service.save
service.name.should == servicename
service.status.should == servicestatus
service.host_id.should == host.id
host.services[1].name.should == servicename
end
it "should not create a new Service when missing a Host" do
servicename = "myservice1"
servicestatus = "up"
service = Service.create(:name => servicename, :status => servicestatus)
service.valid?.should == false
service.errors.should == [[:host_id, :not_present]]
end
it "create a new Service with find_or_create" do
host = Host.create(:name => "h1", :status => "up")
host.save
service = Service.find_or_create(:name => "s1", :status => "up", :host => host)
service.save
service.is_new?.should == true
end
it "should not create a new Service when missing a name" do
host = Host.create(:name => "host1.domain.com", :status => "up")
host.save
service = Service.create(:status => "up", :host => host)
service.valid?.should == false
service.errors.should == [[:name, :not_present]]
end
it "update an existing Service with find_or_create" do
host = Host.create(:name => "h2", :status => "up")
host.save
service = Service.find_or_create(:name => "s2", :status => "up", :host => host)
service.save
sleep 1
service2 = Service.find_or_create(:name => "s2", :status => "up", :host => host)
service2.save
service2.is_new?.should == false
end
it "should not create a new Service when missing a status" do
host = Host.create(:name => "host1.domain.com", :status => "up")
host.save
service = Service.create(:name => 'foo', :host => host)
service.valid?.should == false
service.errors.should == [[:status, :not_present], [:status, :not_member]]
end
it "delete a Service" do
h = Host.create(:name => "h1", :status => "up")
h.save
s = Service.create(:name => "s1", :status => "up", :host => h)
s.save
s = Service.find(:name => "s1").first
s.delete
s = Service.find(:name => "s1").first
s.should == nil
end
it "should not create a new Service with an invalid status" do
host = Host.create(:name => "host1.domain.com", :status => "up")
host.save
service = Service.create(:name => "myservice", :status => "invalid_status", :host => host)
service.valid?.should == false
service.errors.should == [[:status, :not_member]]
end
it "find multiple Services" do
h = Host.create(:name => "h1", :status => "up")
if h.valid?
h.services << Service.create(:name => "s1", :status => "up", :host => h)
h.services << Service.create(:name => "s2", :status => "up", :host => h)
h.save
end
Services.all.size.should == 2
Services.all.first.name.should == "s1"
Services.all.last.name.should == "s2"
end
it "should not create a duplicate Service" do
host = Host.create(:name => "host1.domain.com", :status => "up")
host.save
s = Service.create(:name => "myservice", :status => "up", :host => host)
s.save
s1 = Service.create(:name => "myservice", :status => "up", :host => host)
s1.valid?.should == false
s1.errors.should == [[[:name, :host_id], :not_unique]]
end
it "should create a new Service with find_or_create" do
host = Host.create(:name => "h1", :status => "up")
host.save
service = Service.find_or_create(:name => "s1", :status => "up", :host => host)
service.save
service.is_new?.should == true
end
describe "should not" do
it "should update an existing Service with find_or_create" do
host = Host.create(:name => "h2", :status => "up")
host.save
service = Service.find_or_create(:name => "s2", :status => "up", :host => host)
service.save
sleep 1
service2 = Service.find_or_create(:name => "s2", :status => "up", :host => host)
service2.save
service2.is_new?.should == false
end
it "create a new Service when missing a Host" do
servicename = "myservice1"
servicestatus = "up"
service = Service.create(:name => servicename, :status => servicestatus)
service.valid?.should == false
service.errors.should == [[:host_id, :not_present]]
end
it "should delete a Service" do
h = Host.create(:name => "h1", :status => "up")
h.save
s = Service.create(:name => "s1", :status => "up", :host => h)
s.save
s = Service.find(:name => "s1").first
s.delete
s = Service.find(:name => "s1").first
s.should == nil
end
it "create a new Service when missing a name" do
host = Host.create(:name => "host1.domain.com", :status => "up")
host.save
service = Service.create(:status => "up", :host => host)
service.valid?.should == false
service.errors.should == [[:name, :not_present]]
end
it "should find multiple Services" do
h = Host.create(:name => "h1", :status => "up")
if h.valid?
h.services << Service.create(:name => "s1", :status => "up", :host => h)
h.services << Service.create(:name => "s2", :status => "up", :host => h)
h.save
it "create a new Service when missing a status" do
host = Host.create(:name => "host1.domain.com", :status => "up")
host.save
service = Service.create(:name => 'foo', :host => host)
service.valid?.should == false
service.errors.should == [[:status, :not_present], [:status, :not_member]]
end
it "create a new Service with an invalid status" do
host = Host.create(:name => "host1.domain.com", :status => "up")
host.save
service = Service.create(:name => "myservice", :status => "invalid_status", :host => host)
service.valid?.should == false
service.errors.should == [[:status, :not_member]]
end
Services.all.size.should == 2
Services.all.first.name.should == "s1"
Services.all.last.name.should == "s2"
end
it "create a duplicate Service" do
host = Host.create(:name => "host1.domain.com", :status => "up")
host.save
s = Service.create(:name => "myservice", :status => "up", :host => host)
s.save
s1 = Service.create(:name => "myservice", :status => "up", :host => host)
s1.valid?.should == false
s1.errors.should == [[[:name, :host_id], :not_unique]]
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment