@Before public void setUp() { super.setUp(); task = createTask(TestCopyTask.class); task.action = context.mock(CopyActionImpl.class); task.defaultSource = context.mock(FileCollection.class); }
@Test public void copySpecMethodsDelegateToMainSpecOfCopyAction() { context.checking( new Expectations() { { one(task.action).include("include"); one(task.action).from("source"); } }); assertThat(task.include("include"), sameInstance((AbstractCopyTask) task)); assertThat(task.from("source"), sameInstance((AbstractCopyTask) task)); }
@Test public void usesDefaultSourceWhenNoSourceHasBeenSpecified() { context.checking( new Expectations() { { one(task.action).hasSource(); will(returnValue(false)); } }); assertThat(task.getSource(), sameInstance(task.defaultSource)); }
@Test public void doesNotUseDefaultSourceWhenSourceHasBeenSpecifiedOnSpec() { final FileTree source = context.mock(FileTree.class, "source"); context.checking( new Expectations() { { one(task.action).hasSource(); will(returnValue(true)); one(task.action).getAllSource(); will(returnValue(source)); } }); assertThat(task.getSource(), sameInstance((FileCollection) source)); }