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

quick cleanup of test structure

parent 9fc817d8
...@@ -48,46 +48,30 @@ ...@@ -48,46 +48,30 @@
<tfoot> <tfoot>
<tr> <tr>
<td class="left_align">TOTAL</td> <td class="left_align">TOTAL</td>
<td class='right_align'><tt>610</tt></td> <td class='right_align'><tt>612</tt></td>
<td class='right_align'><tt>518</tt></td> <td class='right_align'><tt>521</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>55.25%</tt></div> <td class="left_align"><div class="percent_graph_legend"><tt class=''>83.33%</tt></div>
<div class="percent_graph"> <div class="percent_graph">
<div class="covered" style="width:55px"></div> <div class="covered" style="width:83px"></div>
<div class="uncovered" style="width:45px"></div> <div class="uncovered" style="width:17px"></div>
</div></td> </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="percent_graph">
<div class="covered" style="width:51px"></div> <div class="covered" style="width:82px"></div>
<div class="uncovered" style="width:49px"></div> <div class="uncovered" style="width:18px"></div>
</div></td> </div></td>
</tr> </tr>
</tfoot> </tfoot>
<tbody> <tbody>
<tr class="all_files all_coverage 50 60 70 80 90 100 even"> <tr class="all_files all_coverage 60 70 80 90 100 lib 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">
<td class="left_align"><a href="lib-helpers_rb.html">lib/helpers.rb</a></td> <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>55</tt></td>
<td class='right_align'><tt>45</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="percent_graph">
<div class="covered" style="width:55px"></div> <div class="covered" style="width:56px"></div>
<div class="uncovered" style="width:45px"></div> <div class="uncovered" style="width:44px"></div>
</div></td> </div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>57.78%</tt></div> <td class="left_align"><div class="percent_graph_legend"><tt class=''>57.78%</tt></div>
<div class="percent_graph"> <div class="percent_graph">
...@@ -96,19 +80,35 @@ ...@@ -96,19 +80,35 @@
</div></td> </div></td>
</tr> </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="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>231</tt></td>
<td class='right_align'><tt>190</tt></td> <td class='right_align'><tt>191</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>65.22%</tt></div> <td class="left_align"><div class="percent_graph_legend"><tt class=''>90.91%</tt></div>
<div class="percent_graph"> <div class="percent_graph">
<div class="covered" style="width:65px"></div> <div class="covered" style="width:91px"></div>
<div class="uncovered" style="width:35px"></div> <div class="uncovered" style="width:9px"></div>
</div></td> </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="percent_graph">
<div class="covered" style="width:61px"></div> <div class="covered" style="width:89px"></div>
<div class="uncovered" style="width:39px"></div> <div class="uncovered" style="width:11px"></div>
</div></td> </div></td>
</tr> </tr>
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
</table> </table>
</div> </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"> <script type="text/javascript">
$(document).ready(function(){$("#report_table").tablesorter({widgets: ['zebra'], textExtraction: 'complex'});}); $(document).ready(function(){$("#report_table").tablesorter({widgets: ['zebra'], textExtraction: 'complex'});});
......
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
<td class="left_align"><a href="lib-helpers_rb.html">lib/helpers.rb</a></td> <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>55</tt></td>
<td class='right_align'><tt>45</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="percent_graph">
<div class="covered" style="width:55px"></div> <div class="covered" style="width:56px"></div>
<div class="uncovered" style="width:45px"></div> <div class="uncovered" style="width:44px"></div>
</div></td> </div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>57.78%</tt></div> <td class="left_align"><div class="percent_graph_legend"><tt class=''>57.78%</tt></div>
<div class="percent_graph"> <div class="percent_graph">
...@@ -158,13 +158,13 @@ ...@@ -158,13 +158,13 @@
<tr class="inferred"> <tr class="marked">
<td><pre><a name="line18">18</a> end </pre></td> <td><pre><a name="line18">18</a> end </pre></td>
</tr> </tr>
<tr class="uncovered"> <tr class="marked">
<td><pre><a name="line19">19</a> </pre></td> <td><pre><a name="line19">19</a> </pre></td>
</tr> </tr>
...@@ -387,7 +387,7 @@ ...@@ -387,7 +387,7 @@
</tbody> </tbody>
</table> </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> </body>
</html> </html>
This diff is collapsed.
This diff is collapsed.
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') 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 describe "should" do
it "create a new Host with no services" do
hostname = "host1.domain.com" hostname = "host1.domain.com"
hoststatus = "up" hoststatus = "up"
host = Host.create(:name => hostname, :status => hoststatus) host = Host.create(:name => hostname, :status => hoststatus)
...@@ -13,7 +14,7 @@ describe "Noah Host Model", :reset_redis => true do ...@@ -13,7 +14,7 @@ describe "Noah Host Model", :reset_redis => true do
host.services.size.should == 0 host.services.size.should == 0
end end
it "should create a new Host with services" do it "create a new Host with services" do
hostname = "host2.domain.com" hostname = "host2.domain.com"
hoststatus = "down" hoststatus = "down"
servicename = 'myservice' servicename = 'myservice'
...@@ -31,7 +32,7 @@ describe "Noah Host Model", :reset_redis => true do ...@@ -31,7 +32,7 @@ describe "Noah Host Model", :reset_redis => true do
host.services[1].host_id.should == host.id host.services[1].host_id.should == host.id
end end
it "should create a Host via find_or_create" do it "create a Host via find_or_create" do
hostname = "host3.domain.com" hostname = "host3.domain.com"
hoststatus = "up" hoststatus = "up"
host = Host.find_or_create(:name => hostname, :status => hoststatus) host = Host.find_or_create(:name => hostname, :status => hoststatus)
...@@ -40,7 +41,7 @@ describe "Noah Host Model", :reset_redis => true do ...@@ -40,7 +41,7 @@ describe "Noah Host Model", :reset_redis => true do
host.is_new?.should == true host.is_new?.should == true
end end
it "should update a Host via find_or_create" do it "update a Host via find_or_create" do
hostname = "host3.domain.com" hostname = "host3.domain.com"
hoststatus = "pending" hoststatus = "pending"
newstatus = "down" newstatus = "down"
...@@ -54,7 +55,7 @@ describe "Noah Host Model", :reset_redis => true do ...@@ -54,7 +55,7 @@ describe "Noah Host Model", :reset_redis => true do
host1.is_new?.should == false host1.is_new?.should == false
end end
it "should delete a Host" do it "delete a Host" do
hostname = "host3.domain.com" hostname = "host3.domain.com"
hoststatus = "pending" hoststatus = "pending"
host = Host.create(:name => hostname, :status => hoststatus) host = Host.create(:name => hostname, :status => hoststatus)
...@@ -63,21 +64,40 @@ describe "Noah Host Model", :reset_redis => true do ...@@ -63,21 +64,40 @@ describe "Noah Host Model", :reset_redis => true do
Host.find(:name => hostname).empty?.should == true Host.find(:name => hostname).empty?.should == true
end end
it "should not create a new Host with missing status" do 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
describe "should not" do
it "create a new Host with missing status" do
hostname ="host3.domain.com" hostname ="host3.domain.com"
host = Host.create(:name => hostname) host = Host.create(:name => hostname)
host.valid?.should == false host.valid?.should == false
host.errors.should == [[:status, :not_present], [:status, :not_member]] host.errors.should == [[:status, :not_present], [:status, :not_member]]
end end
it "should not create a new Host with missing hostname" do it "create a new Host with missing hostname" do
status = "up" status = "up"
host = Host.create(:status => status) host = Host.create(:status => status)
host.valid?.should == false host.valid?.should == false
host.errors.should == [[:name, :not_present]] host.errors.should == [[:name, :not_present]]
end end
it "should not create a new Host with an invalid status" do it "create a new Host with an invalid status" do
hostname = "host3.domain.com" hostname = "host3.domain.com"
status = "online" status = "online"
host = Host.create(:name => hostname, :status => status) host = Host.create(:name => hostname, :status => status)
...@@ -85,7 +105,7 @@ describe "Noah Host Model", :reset_redis => true do ...@@ -85,7 +105,7 @@ describe "Noah Host Model", :reset_redis => true do
host.errors.should == [[:status, :not_member]] host.errors.should == [[:status, :not_member]]
end end
it "should not create a duplicate Host" do it "create a duplicate Host" do
hostname = "host1.domain.com" hostname = "host1.domain.com"
status = "up" status = "up"
host1 = Host.create(:name => hostname, :status => status) host1 = Host.create(:name => hostname, :status => status)
...@@ -94,22 +114,6 @@ describe "Noah Host Model", :reset_redis => true do ...@@ -94,22 +114,6 @@ describe "Noah Host Model", :reset_redis => true do
host2.valid?.should == false host2.valid?.should == false
host2.errors.should == [[:name, :not_unique]] host2.errors.should == [[:name, :not_unique]]
end 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
end end
end end
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Noah Service Model", :reset_redis => true do describe "Noah Service Model", :reset_redis => true do
describe "should" do
it "should create a new Service" do it "create a new Service" do
servicename = "myservice" servicename = "myservice"
servicestatus = "up" servicestatus = "up"
hostname = "mytesthost1" hostname = "mytesthost1"
...@@ -18,7 +19,53 @@ describe "Noah Service Model", :reset_redis => true do ...@@ -18,7 +19,53 @@ describe "Noah Service Model", :reset_redis => true do
host.services[1].name.should == servicename host.services[1].name.should == servicename
end end
it "should not create a new Service when missing a Host" do 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 "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 "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 "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
end
describe "should not" do
it "create a new Service when missing a Host" do
servicename = "myservice1" servicename = "myservice1"
servicestatus = "up" servicestatus = "up"
service = Service.create(:name => servicename, :status => servicestatus) service = Service.create(:name => servicename, :status => servicestatus)
...@@ -26,7 +73,7 @@ describe "Noah Service Model", :reset_redis => true do ...@@ -26,7 +73,7 @@ describe "Noah Service Model", :reset_redis => true do
service.errors.should == [[:host_id, :not_present]] service.errors.should == [[:host_id, :not_present]]
end end
it "should not create a new Service when missing a name" do it "create a new Service when missing a name" do
host = Host.create(:name => "host1.domain.com", :status => "up") host = Host.create(:name => "host1.domain.com", :status => "up")
host.save host.save
service = Service.create(:status => "up", :host => host) service = Service.create(:status => "up", :host => host)
...@@ -34,7 +81,7 @@ describe "Noah Service Model", :reset_redis => true do ...@@ -34,7 +81,7 @@ describe "Noah Service Model", :reset_redis => true do
service.errors.should == [[:name, :not_present]] service.errors.should == [[:name, :not_present]]
end end
it "should not create a new Service when missing a status" do it "create a new Service when missing a status" do
host = Host.create(:name => "host1.domain.com", :status => "up") host = Host.create(:name => "host1.domain.com", :status => "up")
host.save host.save
service = Service.create(:name => 'foo', :host => host) service = Service.create(:name => 'foo', :host => host)
...@@ -42,7 +89,7 @@ describe "Noah Service Model", :reset_redis => true do ...@@ -42,7 +89,7 @@ describe "Noah Service Model", :reset_redis => true do
service.errors.should == [[:status, :not_present], [:status, :not_member]] service.errors.should == [[:status, :not_present], [:status, :not_member]]
end end
it "should not create a new Service with an invalid status" do it "create a new Service with an invalid status" do
host = Host.create(:name => "host1.domain.com", :status => "up") host = Host.create(:name => "host1.domain.com", :status => "up")
host.save host.save
service = Service.create(:name => "myservice", :status => "invalid_status", :host => host) service = Service.create(:name => "myservice", :status => "invalid_status", :host => host)
...@@ -50,7 +97,7 @@ describe "Noah Service Model", :reset_redis => true do ...@@ -50,7 +97,7 @@ describe "Noah Service Model", :reset_redis => true do
service.errors.should == [[:status, :not_member]] service.errors.should == [[:status, :not_member]]
end end
it "should not create a duplicate Service" do it "create a duplicate Service" do
host = Host.create(:name => "host1.domain.com", :status => "up") host = Host.create(:name => "host1.domain.com", :status => "up")
host.save host.save
s = Service.create(:name => "myservice", :status => "up", :host => host) s = Service.create(:name => "myservice", :status => "up", :host => host)
...@@ -60,45 +107,6 @@ describe "Noah Service Model", :reset_redis => true do ...@@ -60,45 +107,6 @@ describe "Noah Service Model", :reset_redis => true do
s1.errors.should == [[[:name, :host_id], :not_unique]] s1.errors.should == [[[:name, :host_id], :not_unique]]
end 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
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 "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 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
end
Services.all.size.should == 2
Services.all.first.name.should == "s1"
Services.all.last.name.should == "s2"
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