[ANN] specs 1.2: jMock integration

View: New views
1 Messages — Rating Filter:   Alert me  

[ANN] specs 1.2: jMock integration

by Eric Torreborre :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi,

I am very glad to announce the version 1.2 of specs.

This version provides an integration with the jMock library and allow you to define expectations on mocks in your specifications and tests:
object mockExample extends Specification with ButtonAndLightMock {
val mock = mock(classOf[Light])
  val button
= Button(mock)

  "A button and light mock example" should {
   
"not fail if the mock receives the expected messages" in {
      expect
{
        one
(mock).on
        one
(mock).off
     
}
      button
.push
      button
.push  // if the button is pressed twice, then the light will go on and off
   
}
 
}
}
Thanks to Lalit Pant (http://lalitpant.blogspot.com/2007/12/using-jmock-with-scala.html) for showing that this was indeed possible!

I also added 2 matchers (requested by David Pollak) for Partial Functions:
  val f = new PartialFunction[Int, String] {
def isDefinedAt(i: Int) = i % 2 == 0
def apply(i: Int) = (i*2).toString
}
"provide a beDefinedAt matcher checking if a PartialFunction is defined at specific values" in {
f must beDefinedAt(2, 4, 6)
}
"provide a beDefinedBy matcher checking if a PartialFunction is defined at specific values" +
 "and returns appropriate results" in {
f must beDefinedBy(2 -> "4", 4 -> "8")
}
A mailing list:  specs-users (http://groups.google.com/group/specs-users) is also available for your feedback about the library.

Happy specs!

Eric.




Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail