Created
December 26, 2013 11:20
-
-
Save guipdutra/8132496 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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