-
Notifications
You must be signed in to change notification settings - Fork 2
Project Requirements
A program that demonstrates a Scala program calling a standard JRuby/Rails ActiveRecord model object which uses a postgres database. Implement unit tests on the scala program to test the functionality. The calling interface will be the java JSR 223 Scripting API’s.
-
Submission
-
Work will start by forking the project
- post any questions as issues here
-
Submit work by issuing a git pull request
-
Requirements can be verified by following these steps on a test machine:
-
install software prerequisites
-
do a git clone/git pull
-
(optionally) creating an empty database
-
running ‘sbt publish-local’ or ‘mvn install’ to run all tests
-
inspecting the code
-
-
Submission is accepted by accepting the pull request
-
Submission is rejected by opening a ticket in the developers fork on github
-
-
Supported platforms
- Either of Apple OSX 10.8.2 or Ubuntu 12.04.3 LTS
-
Software Versions
-
Maven 3.0.3 or higher (if used)
-
Java 1.7.0_x (Oracle java SE)
-
Jruby 1.7.3 or higher
-
Rails 4.0.1 or higher
-
SBT 0.13.0 or higher
-
Scala 2.10.2 or higher
-
Postgresql 9.2.2.0 or higher
-
-
Software Prerequisites
-
Assume that the above software versions are already installed on the test machine
-
Assume the default ‘empty’ postgresql user
-
-
Directory Structure
scala-jruby-activerecord/ .gitignore README.md pom.xml or sbt project/ (to build,test,package the whole project) model-gem/ (a gem following the ‘bundle gem’ convention) scala-client/ (a scala project following sbt or maven convention) .../resources/ config.__ - a config file holding the db credentials -
Packaging
-
Project will package as:
-
com.drsquidop.scala-jruby-activerecord:model-gem-1.0.SNAPSHOT:jar
- this gem will package as both a gem and a jar
-
com.drsquidop.scala-jruby-activerecord:scala-client-1.0.SNAPSHOT:jar
- this jar will include a dependency on the model-gem jar
-
-
-
General Requirements
-
scala-client
-
based on scala 2.10 maven or sbt convention
-
depends on model-gem jar
-
calls model-gem using JSR 223 Scripting API (see references)
-
passes database configuration to model-gem
-
contains MyModel case class with these fields
-
id: Option[Int]
-
name: String
-
-
contains Client object with these methods
-
new(MyModel): Try[MyModel] - returns with assigned id
-
get(id:Int): Try[MyModel] - returns record with id
-
all(): Try[List[MyModel]] - returns all records
-
-
contains ValidationException extends Exception that contains ActiveRecord generated validation errors
-
-
model-gem
-
based on ‘bundle gem ’ convention
-
based on rails ActiveRecord model object convention
-
passed its database configuration from scala-client
-
contains MyGemModel ActiveRecord object with
-
id - autoassigned pk
-
name - string
-
-
‘mvn package’ (or shell script) handles
-
reloading db from migrations
-
running rspec
-
packaging as gem
-
packaging as jar
-
deploying jar to local repo
-
-
-
-
Tests
-
Scala tests will use ScalaTest or Specs2
-
Unit Tests
-
model-gem
-
Configuration
-
tests are implemented in rspec
-
database configuration comes from gem/config/database.yml
-
-
Test cases
-
MyGemModel.new with (any string) creates a record in the database
-
MyGemModel.new with (blank string) returns rails standard validation error
-
MyGemModel.get(id) returns a valid object
-
MyGemModel.all returns multiple entries
-
-
-
scala-client
-
Configuration
-
model-gem is packaged as a jar
-
scala-client includes model-gem jar as dependency
-
tests run under scala-client using mvn or sbt
-
tests are written in scalatest or specs2
-
database config comes from scala-client/...config file
-
-
Test cases
-
Client.new(any string) returns Success(MyModel)
-
Client.new(empty string) returns Failure(ValidationException) with ActiveRecord validation error map
-
Client.get(valid id) returns Success(MyModel)
-
Client.get(invalid id) returns Failure(Exception("MyModel not found"))
-
Client.all returns Success(List[MyModel]) with several records
-
-
-
-