Created
April 6, 2012 18:25
-
-
Save cmrichards/2321869 to your computer and use it in GitHub Desktop.
This file contains 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 "minitest_helper" | |
require "mocha" | |
describe Contexts::MoveAreaBeforeArea do | |
it "should add area before area" do | |
Area.expects(:find).with(100).returns(Area.new) | |
context = Contexts::MoveAreaBeforeArea.new 100, 100 | |
context.area.must_respond_to(:move_before_an_area) | |
context.call | |
Area.unstub(:find) | |
end | |
end | |
---------------- | |
module Contexts | |
class MoveAreaBeforeArea < Contexts::Base | |
attr_reader :area, :target_area | |
def initialize(area_id, target_area_id) | |
@area = Area.find area_id | |
@target_area = Area.find target_area_id | |
@target_area_parent = @target_area.parent | |
@area.extend Roles::MoveableArea | |
@target_area_parent.extend Roles::SubAreaManager | |
end | |
def call | |
@area.move_before_an_area(@target_area, @target_area_parent) | |
end | |
end | |
end | |
-------------- | |
Contexts::AddingSectionToArea | |
PASS test_0001_adds_a_section_to_an_area (0:00:00.159) | |
Contexts::AddingSubAreaToArea | |
PASS test_0001_adds_a_sub_area_to_an_area (0:00:00.182) | |
Contexts::ChangeSectionLockState | |
PASS test_0001_user_locks_a_section (0:00:00.232) | |
PASS test_0002_user_unlocks_a_section (0:00:00.285) | |
Contexts::CollapseArea | |
PASS test_0001_calls_collapse_on_area (0:00:00.305) | |
Contexts::ExpandArea | |
PASS test_0001_calls_expand_on_area (0:00:00.324) | |
Contexts::MoveAreaBeforeArea | |
ERROR test_0001_should_add_area_before_area (0:00:00.325) | |
unexpected invocation: Area(id: integer, name: string, position: integer, created_at: datetime, updated_at: datetime, ancestry: string, expanded: boolean, next_id: integer, first: boolean).find(100) | |
unsatisfied expectations: | |
- expected exactly once, invoked twice: Area(id: integer, name: string, position: integer, created_at: datetime, updated_at: datetime, ancestry: string, expanded: boolean, next_id: integer, first: boolean).find(100) | |
@ app/contexts/move_area_before_area.rb:9:in `initialize' | |
test/contexts/move_area_before_area_test.rb:9:in `new' | |
test/contexts/move_area_before_area_test.rb:9:in `block (2 levels) in <top (required)>' | |
Contexts::MoveSection | |
ERROR test_0001_should_move_item_to_top_of_list (0:00:00.328) | |
unexpected invocation: Area(id: integer, name: string, position: integer, created_at: datetime, updated_at: datetime, ancestry: string, expanded: boolean, next_id: integer, first: boolean).find(8, {:lock => true}) | |
unsatisfied expectations: | |
- expected exactly once, invoked twice: Area(id: integer, name: string, position: integer, created_at: datetime, updated_at: datetime, ancestry: string, expanded: boolean, next_id: integer, first: boolean).find(100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment