Skip to content

Instantly share code, notes, and snippets.

@lightcap
Created March 19, 2010 05:07
Show Gist options
  • Save lightcap/337257 to your computer and use it in GitHub Desktop.
Save lightcap/337257 to your computer and use it in GitHub Desktop.
class ActiveSupport::TestCase
def setup_fault
@inverter_model = Factory(:inverter_model)
@inverter = Factory(:inverter, :inverter_model => @inverter_model)
@fault_message = Factory(:fault_message, :inverter => @inverter)
@inverter_property = Factory(:inverter_property, :inverter => @inverter)
@inverter_state = Factory(:inverter_state)
@old_inverter_state = Factory(:old_inverter_state)
@device = Factory(:device)
@fault_group = Factory(:fault_group, :device => @device)
@fault_poll = Factory(:fault_poll, :inverter => @inverter, :inverter_property => @inverter_property, :inverter_state => @inverter_state, :old_inverter_state => @old_inverter_state, :fault_message => @fault_message)
@fault = Factory(:fault, :fault_poll => @fault_poll)
@fault_name = Factory(:fault_name, :fault_group => @fault_group)
assert @fault
end
end
require 'test_helper'
class FaultTest < ActiveSupport::TestCase
should_belong_to :fault_name
should_belong_to :fault_poll
context "A fault instance" do
setup do
setup_fault
end
should "be saveable" do
assert @fault.save!
end
should "find recent" do
assert_equal 1, Fault.recent.count
end
end
context "A set of faults" do
setup do
100.times { setup_fault }
assert_equal 100, Fault.count
end
should "save them all" do
assert_equal 100, Fault.count
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment