Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save guipdutra/8132496 to your computer and use it in GitHub Desktop.

Select an option

Save guipdutra/8132496 to your computer and use it in GitHub Desktop.
require 'spec_helper_lite'
require 'app/business/cell_supervision_name_functions_business'
describe CellSupervisionNameFunctionsBusiness do
let(:function_one) { 1 }
let(:find_result) { double }
let(:functions) {
[
:id => function_one
]
}
subject { CellSupervisionNameFunctionsBusiness.new(:functions => functions)}
context "when cell supervision item is equal CellSupervisionFunctionItem::NEW" do
it "should create cell supervision function" do
stub_const("CellSupervisionFunction", Class.new)
CellSupervisionFunction.should_receive(:create).with({:id => 1})
stub_const("CellSupervisionFunctionItem::NEW", 1)
subject.save!
end
end
context "when cell supervision item is not CellSupervisionFunctionItem::NEW" do
it "should update cell supervision function" do
stub_const("CellSupervisionFunction", Class.new)
stub_const("CellSupervisionFunctionItem::NEW", 2)
CellSupervisionFunction.should_receive(:find).with(1).and_return(find_result)
find_result.should_receive(:update_attributes).with({:id => 1})
subject.save!
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment