Browse files

[problem] added model and setup testing suite with machinist

  • Loading branch information...
1 parent b9e15d2 commit ceaf8754901c36cd47e517fabd11f45114102e18 @achiu achiu committed Jul 12, 2010
Showing with 218 additions and 0 deletions.
  1. +4 −0 Gemfile
  2. +180 −0 Gemfile.lock
  3. +8 −0 app/models/problem.rb
  4. +15 −0 test/blueprints.rb
  5. +10 −0 test/models/problem_test.rb
  6. +1 −0 test/test_config.rb
View
4 Gemfile
@@ -14,6 +14,10 @@ gem 'bson_ext', :require => "mongo"
gem 'rr', :group => "test"
gem 'riot', :group => "test"
gem 'rack-test', :require => "rack/test", :group => "test"
+gem 'riot-mongo_mapper', :group => "test"
+gem 'machinist', :group => 'test'
+gem 'machinist_mongo', :require => 'machinist/mongo_mapper', :group => 'test'
+gem 'faker', :group => 'test'
# Padrino
View
180 Gemfile.lock
@@ -0,0 +1,180 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ activesupport (2.3.8)
+ activesupport (2.3.8)
+ bson (1.0.3)
+ bson (1.0.3)
+ bson_ext (1.0.1)
+ bson_ext (1.0.1)
+ daemons (1.1.0)
+ daemons (1.1.0)
+ eventmachine (0.12.10)
+ eventmachine (0.12.10)
+ faker (0.3.1)
+ faker (0.3.1)
+ haml (3.0.13)
+ haml (3.0.13)
+ http_router (0.3.1)
+ rack (>= 1.0)
+ url_mount (>= 0.2.1)
+ http_router (0.3.1)
+ rack (>= 1.0)
+ url_mount (>= 0.2.1)
+ i18n (0.4.1)
+ i18n (0.4.1)
+ jnunemaker-validatable (1.8.4)
+ activesupport (>= 2.3.4)
+ jnunemaker-validatable (1.8.4)
+ activesupport (>= 2.3.4)
+ machinist (1.0.6)
+ machinist (1.0.6)
+ machinist_mongo (1.1.1)
+ machinist (~> 1.0.4)
+ machinist_mongo (1.1.1)
+ machinist (~> 1.0.4)
+ mail (2.2.5)
+ activesupport (>= 2.3.6)
+ mime-types
+ treetop (>= 1.4.5)
+ mail (2.2.5)
+ activesupport (>= 2.3.6)
+ mime-types
+ treetop (>= 1.4.5)
+ mime-types (1.16)
+ mime-types (1.16)
+ mongo (1.0.3)
+ bson (= 1.0.3)
+ mongo (1.0.3)
+ bson (= 1.0.3)
+ mongo_mapper (0.8.2)
+ activesupport (>= 2.3.4)
+ jnunemaker-validatable (~> 1.8.4)
+ plucky (~> 0.3.1)
+ mongo_mapper (0.8.2)
+ activesupport (>= 2.3.4)
+ jnunemaker-validatable (~> 1.8.4)
+ plucky (~> 0.3.1)
+ padrino (0.9.14)
+ padrino-admin (= 0.9.14)
+ padrino-core (= 0.9.14)
+ padrino-gen (= 0.9.14)
+ padrino-helpers (= 0.9.14)
+ padrino-mailer (= 0.9.14)
+ padrino (0.9.14)
+ padrino-admin (= 0.9.14)
+ padrino-core (= 0.9.14)
+ padrino-gen (= 0.9.14)
+ padrino-helpers (= 0.9.14)
+ padrino-mailer (= 0.9.14)
+ padrino-admin (0.9.14)
+ padrino-core (= 0.9.14)
+ padrino-gen (= 0.9.14)
+ padrino-helpers (= 0.9.14)
+ padrino-admin (0.9.14)
+ padrino-core (= 0.9.14)
+ padrino-gen (= 0.9.14)
+ padrino-helpers (= 0.9.14)
+ padrino-core (0.9.14)
+ activesupport (>= 2.3.8)
+ http_router (>= 0.3.0)
+ sinatra (>= 1.0.0)
+ thor (>= 0.13.0)
+ padrino-core (0.9.14)
+ activesupport (>= 2.3.8)
+ http_router (>= 0.3.0)
+ sinatra (>= 1.0.0)
+ thor (>= 0.13.0)
+ padrino-gen (0.9.14)
+ bundler (>= 0.9.7)
+ padrino-core (= 0.9.14)
+ padrino-gen (0.9.14)
+ bundler (>= 0.9.7)
+ padrino-core (= 0.9.14)
+ padrino-helpers (0.9.14)
+ i18n (>= 0.4.1)
+ padrino-core (= 0.9.14)
+ padrino-helpers (0.9.14)
+ i18n (>= 0.4.1)
+ padrino-core (= 0.9.14)
+ padrino-mailer (0.9.14)
+ mail (>= 2.2.0)
+ padrino-core (= 0.9.14)
+ padrino-mailer (0.9.14)
+ mail (>= 2.2.0)
+ padrino-core (= 0.9.14)
+ plucky (0.3.2)
+ mongo (~> 1.0.1)
+ plucky (0.3.2)
+ mongo (~> 1.0.1)
+ polyglot (0.3.1)
+ polyglot (0.3.1)
+ rack (1.2.1)
+ rack (1.2.1)
+ rack-flash (0.1.1)
+ rack
+ rack-flash (0.1.1)
+ rack
+ rack-test (0.5.4)
+ rack (>= 1.0)
+ rack-test (0.5.4)
+ rack (>= 1.0)
+ rake (0.8.7)
+ rake (0.8.7)
+ riot (0.11.2)
+ rr
+ term-ansicolor
+ riot (0.11.2)
+ rr
+ term-ansicolor
+ riot-mongo_mapper (0.0.1)
+ mongo_mapper (>= 0.8.2)
+ riot (>= 0.11.2)
+ riot-mongo_mapper (0.0.1)
+ mongo_mapper (>= 0.8.2)
+ riot (>= 0.11.2)
+ rr (0.10.11)
+ rr (0.10.11)
+ sinatra (1.0)
+ rack (>= 1.0)
+ sinatra (1.0)
+ rack (>= 1.0)
+ term-ansicolor (1.0.5)
+ term-ansicolor (1.0.5)
+ thin (1.2.7)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
+ thin (1.2.7)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
+ thor (0.13.7)
+ thor (0.13.7)
+ treetop (1.4.8)
+ polyglot (>= 0.3.1)
+ treetop (1.4.8)
+ polyglot (>= 0.3.1)
+ url_mount (0.2.1)
+ rack
+ url_mount (0.2.1)
+ rack
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bson_ext
+ faker
+ haml
+ machinist
+ machinist_mongo
+ mongo_mapper
+ padrino (= 0.9.14)
+ rack-flash
+ rack-test
+ rake
+ riot
+ riot-mongo_mapper
+ rr
+ thin
View
8 app/models/problem.rb
@@ -0,0 +1,8 @@
+class Problem
+ include MongoMapper::Document
+
+ # key <name>, <type>
+ key :title, String
+ key :description, String
+ timestamps!
+end
View
15 test/blueprints.rb
@@ -0,0 +1,15 @@
+Sham.define do
+ username { Faker::Internet.user_name }
+ first_name { Faker::Name.first_name }
+ last_name { Faker::Name.last_name }
+ password { (1..10).map { ('a'..'z').to_a.rand }.join }
+ email { Faker::Internet.email }
+ title { Faker::Lorem.words(5).join(' ') }
+ body { Faker::Lorem.words(10).join(' ') }
+ tag_name { Faker::Lorem.words(1).join }
+end
+
+Problem.blueprint do
+ title { Sham.title }
+ description { Sham.body }
+end
View
10 test/models/problem_test.rb
@@ -0,0 +1,10 @@
+require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
+
+context "Problem Model" do
+ setup { Problem.delete_all }
+ context "definition" do
+ setup { Problem.make }
+ asserts_topic.has_key :title, String
+ asserts_topic.has_key :description, String
+ end
+end
View
1 test/test_config.rb
@@ -1,5 +1,6 @@
PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
+require File.join(File.dirname(__FILE__),'blueprints')
require 'riot/rr'
# Specify your app using the #app helper inside a context.

0 comments on commit ceaf875

Please sign in to comment.