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

working on specs before refactor

parent af0b589b
...@@ -6,6 +6,8 @@ gem "ohm-contrib", "= 0.1.0" ...@@ -6,6 +6,8 @@ gem "ohm-contrib", "= 0.1.0"
gem "haml", "= 3.0.25" gem "haml", "= 3.0.25"
group :development do group :development do
gem "sinatra-reloader", "= 0.5.0" gem "sinatra-reloader", "= 0.5.0"
gem "rspec", "= 2.4.0"
gem "rcov", "= 0.9.9"
end end
platforms :mri do platforms :mri do
gem "yajl-ruby", "= 0.7.9", :require => "yajl" gem "yajl-ruby", "= 0.7.9", :require => "yajl"
......
...@@ -2,6 +2,7 @@ GEM ...@@ -2,6 +2,7 @@ GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
backports (1.18.2) backports (1.18.2)
diff-lcs (1.1.2)
haml (3.0.25) haml (3.0.25)
json (1.4.6-java) json (1.4.6-java)
json-jruby (1.4.6-java) json-jruby (1.4.6-java)
...@@ -15,7 +16,17 @@ GEM ...@@ -15,7 +16,17 @@ GEM
ohm-contrib (0.1.0) ohm-contrib (0.1.0)
ohm ohm
rack (1.2.1) rack (1.2.1)
rcov (0.9.9)
rcov (0.9.9-java)
redis (2.1.1) redis (2.1.1)
rspec (2.4.0)
rspec-core (~> 2.4.0)
rspec-expectations (~> 2.4.0)
rspec-mocks (~> 2.4.0)
rspec-core (2.4.0)
rspec-expectations (2.4.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.4.0)
sinatra (1.1.2) sinatra (1.1.2)
rack (~> 1.1) rack (~> 1.1)
tilt (~> 1.2) tilt (~> 1.2)
...@@ -43,6 +54,8 @@ DEPENDENCIES ...@@ -43,6 +54,8 @@ DEPENDENCIES
json-jruby (= 1.4.6) json-jruby (= 1.4.6)
ohm (= 0.1.3) ohm (= 0.1.3)
ohm-contrib (= 0.1.0) ohm-contrib (= 0.1.0)
rcov (= 0.9.9)
rspec (= 2.4.0)
sinatra (= 1.1.2) sinatra (= 1.1.2)
sinatra-namespace (= 0.6.1) sinatra-namespace (= 0.6.1)
sinatra-reloader (= 0.5.0) sinatra-reloader (= 0.5.0)
......
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Host", :reset_redis => true do
it "should create a new Host with no services" do
hostname = "host1.domain.com"
status = "up"
host = Host.create(:name => hostname, :status => status)
host.valid?.should == true
host.save
host.name.should == hostname
host.status.should == status
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
end
require 'bundler/setup'
require 'ohm'
begin
require 'yajl'
rescue LoadError
require 'json'
end
require File.join(File.dirname(__FILE__), '..', 'config','db')
require File.join(File.dirname(__FILE__), '..', 'models')
require 'rspec'
RSpec.configure do |config|
config.before(:each, :reset_redis => true) { Ohm::redis.flushdb }
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