org.specs.mock.JMocker.JMockAction

class JMockAction

class JMockAction[T](v : T)

 extends ScalaObject


This class allows a block of code to be followed by some actions like returning a value or throwing an exception When we wish to return a mock and define expectations at the same time: willReturn[MyInterface] { m1: MyInterface => one(m1).method } It is necessary to first create the mock, set it as a returned object through a ReturnValueAction then to trigger the block containing the expectations for that mock


Source: JMocker.scala(252)

 Constructors

def this(v : T)

 Methods

!= final def !=(arg0 : Any) Boolean Any
!= final def !=(arg0 : Object) Boolean AnyRef
== final def ==(arg0 : Object) Boolean AnyRef
== final def ==(arg0 : Any) Boolean Any
asInstanceOf final def asInstanceOf[T0] T0 Any
clone protected def clone Object AnyRef
eq final def eq(arg0 : Object) Boolean AnyRef
equals def equals(arg0 : Any) Boolean AnyRef
finalize protected def finalize Unit AnyRef
getClass final def getClass Class[Object] AnyRef
hashCode def hashCode Int AnyRef
isInstanceOf final def isInstanceOf[T0] Boolean Any
ne final def ne(arg0 : Object) Boolean AnyRef
notify final def notify Unit AnyRef
notifyAll final def notifyAll Unit AnyRef
synchronized final def synchronized[T0](arg0 : T0) T0 AnyRef
toString def toString String AnyRef
wait final def wait(arg0 : Long) Unit AnyRef
wait final def wait Unit AnyRef
wait final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
will def will(action : Action)
set up a JMock action to be executed
Unit
willReturn def willReturn[S, T <: Iterable[S]](results : List[(S, (S) => Any)])
will return a list of values of type S, and containing some associated blocks to set expectations for those values which may be mocks Usage willReturnIterable(List(as[MyInterface]{m1: MyInterface => one(m1) [details]
method }, as[MyInterface]{m2: MyInterface => one(m2).method }))
Unit
willReturn def willReturn[T](stored : CapturingParam[T]) Unit
willReturn def willReturn(result : (T, (T) => Any))
sets an action which will return a mock of type Class[T] and being specified by a function triggering expectations [details]
It is supposed to be used in conjunction with the as method which mocks an object and creates a function defining the mock expectations
Any
willReturn def willReturn(result : T)
sets a value to be returned by the mock
Unit
willReturn def willReturn[T](f : (T) => Any)(implicit m : Manifest[T])
sets an action which will return a mock of type Class[T] and being specified by a function triggering expectations
Unit
willReturnEach def willReturnEach(values : T*) Unit
willReturnIterable def willReturnIterable[S, T <: Iterable[S]](results : (S) => Any*)(implicit m : Manifest[S])
will return a list of mocks from the same class several times and add expectations for each mock [details]
Usage willReturnIterable(as[MyInterface]( {m1: MyInterface => one(m1).method }, {m2: MyInterface => one(m2).method }, ) However, it is shorter to use willReturnIterable: one(workspace).projects willReturnIterable[Project]( {p: Project => one(p).name willReturn "p1" }, {p: Project => one(p).name willReturn "p2" })
Unit
willReturnIterable def willReturnIterable[S, T <: Iterable[S]](results : (S, (S) => Any)*)
will return a list of values of type S, and containing some associated blocks to set expectations for those values which may be mocks Usage willReturnIterable(as[MyInterface]{m1: MyInterface => one(m1) [details]
method }, as[MyInterface]{m2: MyInterface => one(m2).method })
Unit
willReturnValue def willReturnValue(result : T)
sets a value to be returned by the mock
Unit
willThrow def willThrow[X <: Throwable](implicit m : Manifest[X])
sets an exception to be thrown by the mock
Unit
willThrow def willThrow[X <: Throwable](t : X)
sets an exception to be thrown by the mock
Unit
Copyright (c) 2007-2009. All Rights Reserved.