Permalink
Browse files

ORMのテスト用クラス追加。

skinny testOnly skinny.orm.SkinnyORMSpec
  • Loading branch information...
soha authored and sohatach committed May 19, 2014
1 parent fb931c3 commit 4e2b4511bf86aabbb751f8ac03ec944e2fa9f5b1
Showing with 42 additions and 0 deletions.
  1. +42 −0 src/test/scala/skinny/orm/SkinnyORMSpec.scala
@@ -0,0 +1,42 @@
package skinny.orm
import scalikejdbc._, SQLInterpolation._
import org.joda.time.DateTime
import scalikejdbc.scalatest.AutoRollback
import org.scalatest.fixture
import org.scalatest.matchers.ShouldMatchers
import skinny._
import skinny.orm.exception.OptimisticLockException
import model._
class SkinnyORMSpec extends fixture.FunSpec with DBSettings with AutoRollback with ShouldMatchers {
override def fixture(implicit session: DBSession) {
}
describe("EventMembers") {
it("should Event has Members") { implicit session =>
// #createWithNamedValues
val eventId1 = Event.createWithAttributes('title -> "イベント1")
val eventId2 = Event.createWithAttributes('title -> "イベント2")
val memberId1 = Member.createWithAttributes('name -> "メンバー1", 'email -> "hoge")
val memberId2 = Member.createWithAttributes('name -> "メンバー2", 'email -> "")
EventMember.createWithAttributes('eventId -> eventId1, 'memberId -> memberId1, 'createdAt -> DateTime.now, 'updatedAt -> DateTime.now)
EventMember.createWithAttributes('eventId -> eventId1, 'memberId -> memberId2, 'createdAt -> DateTime.now, 'updatedAt -> DateTime.now)
EventMember.createWithAttributes('eventId -> eventId2, 'memberId -> memberId2, 'createdAt -> DateTime.now, 'updatedAt -> DateTime.now)
val event1 = Event.findById(eventId1).get
event1.title should equal("イベント1")
event1.members.size should equal(2)
val event2 = Event.findById(eventId2).get
event2.title should equal("イベント2")
event2.members.size should equal(1)
}
}
}

0 comments on commit 4e2b451

Please sign in to comment.