Slight trouble with Specs2 + Squeryl

20 views
Skip to first unread message

Seyi Ogunyemi

unread,
Jul 3, 2011, 8:32:21 PM7/3/11
to specs2...@googlegroups.com
Hi,

I've having some trouble with mixing specs2 & Squeryl (probably due to being new to specs2.) 

Figurative examples of my initial attempts and the subsequent error messages: https://gist.github.com/1062739

I suspect that the Session.create issues are related to the test suite being executed concurrently. Some thoughts on how more experienced hands might tackle this would be welcome.

Regards,

Seyi


etorreborre

unread,
Jul 3, 2011, 8:58:03 PM7/3/11
to specs2...@googlegroups.com
Hi Seyi,

Thanks for posting your examples and output.

I suggest the following:
  • if you have issues with examples being executed concurrently you can try to use the `sequential` argument at the beginning of the specification
class DatabaseSpec extends Specification { def is = sequential ^
  "This is a specification to check the database schema" ^

However in your case it might be something entirely different because of the way Squeryl works. Maybe there's something smarter to do by attaching the database session to the current thread as suggested so that you can still have your examples being executed concurrently.
  • For the second example you can avoid the implicits clash by using the `>>` operator:
"Schema stored in database should" >> {
    "allow creation of new entries" >> {
      val datum = data.insert(new AppData(0, Some(1),Some(""), Some("ftp.example.org"), Some("username"), Some("password"), Some(new java.util.Date)))
      datum.id must_== 1
    }

Also, in that second example, if you create a `Before` context object, you need to `apply` it to your example body:

    "allow creation of new entries" >> setupData {
      val datum = data.insert(new AppData(0, Some(1),Some(""), Some("ftp.example.org"), Some("username"), Some("password"), Some(new java.util.Date)))
      datum.id must_== 1
    }

But the easiest thing to do is to use the BeforeExample trait in that case.

I hope that'll get you started.

Eric.


Reply all
Reply to author
Forward
0 new messages