Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[problem] added model and setup testing suite with machinist

  • Loading branch information...
commit ceaf8754901c36cd47e517fabd11f45114102e18 1 parent b9e15d2
Arthur Chiu achiu authored
4 Gemfile
@@ -14,6 +14,10 @@ gem 'bson_ext', :require => "mongo"
14 14 gem 'rr', :group => "test"
15 15 gem 'riot', :group => "test"
16 16 gem 'rack-test', :require => "rack/test", :group => "test"
  17 +gem 'riot-mongo_mapper', :group => "test"
  18 +gem 'machinist', :group => 'test'
  19 +gem 'machinist_mongo', :require => 'machinist/mongo_mapper', :group => 'test'
  20 +gem 'faker', :group => 'test'
17 21
18 22
19 23 # Padrino
180 Gemfile.lock
... ... @@ -0,0 +1,180 @@
  1 +GEM
  2 + remote: http://rubygems.org/
  3 + specs:
  4 + activesupport (2.3.8)
  5 + activesupport (2.3.8)
  6 + bson (1.0.3)
  7 + bson (1.0.3)
  8 + bson_ext (1.0.1)
  9 + bson_ext (1.0.1)
  10 + daemons (1.1.0)
  11 + daemons (1.1.0)
  12 + eventmachine (0.12.10)
  13 + eventmachine (0.12.10)
  14 + faker (0.3.1)
  15 + faker (0.3.1)
  16 + haml (3.0.13)
  17 + haml (3.0.13)
  18 + http_router (0.3.1)
  19 + rack (>= 1.0)
  20 + url_mount (>= 0.2.1)
  21 + http_router (0.3.1)
  22 + rack (>= 1.0)
  23 + url_mount (>= 0.2.1)
  24 + i18n (0.4.1)
  25 + i18n (0.4.1)
  26 + jnunemaker-validatable (1.8.4)
  27 + activesupport (>= 2.3.4)
  28 + jnunemaker-validatable (1.8.4)
  29 + activesupport (>= 2.3.4)
  30 + machinist (1.0.6)
  31 + machinist (1.0.6)
  32 + machinist_mongo (1.1.1)
  33 + machinist (~> 1.0.4)
  34 + machinist_mongo (1.1.1)
  35 + machinist (~> 1.0.4)
  36 + mail (2.2.5)
  37 + activesupport (>= 2.3.6)
  38 + mime-types
  39 + treetop (>= 1.4.5)
  40 + mail (2.2.5)
  41 + activesupport (>= 2.3.6)
  42 + mime-types
  43 + treetop (>= 1.4.5)
  44 + mime-types (1.16)
  45 + mime-types (1.16)
  46 + mongo (1.0.3)
  47 + bson (= 1.0.3)
  48 + mongo (1.0.3)
  49 + bson (= 1.0.3)
  50 + mongo_mapper (0.8.2)
  51 + activesupport (>= 2.3.4)
  52 + jnunemaker-validatable (~> 1.8.4)
  53 + plucky (~> 0.3.1)
  54 + mongo_mapper (0.8.2)
  55 + activesupport (>= 2.3.4)
  56 + jnunemaker-validatable (~> 1.8.4)
  57 + plucky (~> 0.3.1)
  58 + padrino (0.9.14)
  59 + padrino-admin (= 0.9.14)
  60 + padrino-core (= 0.9.14)
  61 + padrino-gen (= 0.9.14)
  62 + padrino-helpers (= 0.9.14)
  63 + padrino-mailer (= 0.9.14)
  64 + padrino (0.9.14)
  65 + padrino-admin (= 0.9.14)
  66 + padrino-core (= 0.9.14)
  67 + padrino-gen (= 0.9.14)
  68 + padrino-helpers (= 0.9.14)
  69 + padrino-mailer (= 0.9.14)
  70 + padrino-admin (0.9.14)
  71 + padrino-core (= 0.9.14)
  72 + padrino-gen (= 0.9.14)
  73 + padrino-helpers (= 0.9.14)
  74 + padrino-admin (0.9.14)
  75 + padrino-core (= 0.9.14)
  76 + padrino-gen (= 0.9.14)
  77 + padrino-helpers (= 0.9.14)
  78 + padrino-core (0.9.14)
  79 + activesupport (>= 2.3.8)
  80 + http_router (>= 0.3.0)
  81 + sinatra (>= 1.0.0)
  82 + thor (>= 0.13.0)
  83 + padrino-core (0.9.14)
  84 + activesupport (>= 2.3.8)
  85 + http_router (>= 0.3.0)
  86 + sinatra (>= 1.0.0)
  87 + thor (>= 0.13.0)
  88 + padrino-gen (0.9.14)
  89 + bundler (>= 0.9.7)
  90 + padrino-core (= 0.9.14)
  91 + padrino-gen (0.9.14)
  92 + bundler (>= 0.9.7)
  93 + padrino-core (= 0.9.14)
  94 + padrino-helpers (0.9.14)
  95 + i18n (>= 0.4.1)
  96 + padrino-core (= 0.9.14)
  97 + padrino-helpers (0.9.14)
  98 + i18n (>= 0.4.1)
  99 + padrino-core (= 0.9.14)
  100 + padrino-mailer (0.9.14)
  101 + mail (>= 2.2.0)
  102 + padrino-core (= 0.9.14)
  103 + padrino-mailer (0.9.14)
  104 + mail (>= 2.2.0)
  105 + padrino-core (= 0.9.14)
  106 + plucky (0.3.2)
  107 + mongo (~> 1.0.1)
  108 + plucky (0.3.2)
  109 + mongo (~> 1.0.1)
  110 + polyglot (0.3.1)
  111 + polyglot (0.3.1)
  112 + rack (1.2.1)
  113 + rack (1.2.1)
  114 + rack-flash (0.1.1)
  115 + rack
  116 + rack-flash (0.1.1)
  117 + rack
  118 + rack-test (0.5.4)
  119 + rack (>= 1.0)
  120 + rack-test (0.5.4)
  121 + rack (>= 1.0)
  122 + rake (0.8.7)
  123 + rake (0.8.7)
  124 + riot (0.11.2)
  125 + rr
  126 + term-ansicolor
  127 + riot (0.11.2)
  128 + rr
  129 + term-ansicolor
  130 + riot-mongo_mapper (0.0.1)
  131 + mongo_mapper (>= 0.8.2)
  132 + riot (>= 0.11.2)
  133 + riot-mongo_mapper (0.0.1)
  134 + mongo_mapper (>= 0.8.2)
  135 + riot (>= 0.11.2)
  136 + rr (0.10.11)
  137 + rr (0.10.11)
  138 + sinatra (1.0)
  139 + rack (>= 1.0)
  140 + sinatra (1.0)
  141 + rack (>= 1.0)
  142 + term-ansicolor (1.0.5)
  143 + term-ansicolor (1.0.5)
  144 + thin (1.2.7)
  145 + daemons (>= 1.0.9)
  146 + eventmachine (>= 0.12.6)
  147 + rack (>= 1.0.0)
  148 + thin (1.2.7)
  149 + daemons (>= 1.0.9)
  150 + eventmachine (>= 0.12.6)
  151 + rack (>= 1.0.0)
  152 + thor (0.13.7)
  153 + thor (0.13.7)
  154 + treetop (1.4.8)
  155 + polyglot (>= 0.3.1)
  156 + treetop (1.4.8)
  157 + polyglot (>= 0.3.1)
  158 + url_mount (0.2.1)
  159 + rack
  160 + url_mount (0.2.1)
  161 + rack
  162 +
  163 +PLATFORMS
  164 + ruby
  165 +
  166 +DEPENDENCIES
  167 + bson_ext
  168 + faker
  169 + haml
  170 + machinist
  171 + machinist_mongo
  172 + mongo_mapper
  173 + padrino (= 0.9.14)
  174 + rack-flash
  175 + rack-test
  176 + rake
  177 + riot
  178 + riot-mongo_mapper
  179 + rr
  180 + thin
8 app/models/problem.rb
... ... @@ -0,0 +1,8 @@
  1 +class Problem
  2 + include MongoMapper::Document
  3 +
  4 + # key <name>, <type>
  5 + key :title, String
  6 + key :description, String
  7 + timestamps!
  8 +end
15 test/blueprints.rb
... ... @@ -0,0 +1,15 @@
  1 +Sham.define do
  2 + username { Faker::Internet.user_name }
  3 + first_name { Faker::Name.first_name }
  4 + last_name { Faker::Name.last_name }
  5 + password { (1..10).map { ('a'..'z').to_a.rand }.join }
  6 + email { Faker::Internet.email }
  7 + title { Faker::Lorem.words(5).join(' ') }
  8 + body { Faker::Lorem.words(10).join(' ') }
  9 + tag_name { Faker::Lorem.words(1).join }
  10 +end
  11 +
  12 +Problem.blueprint do
  13 + title { Sham.title }
  14 + description { Sham.body }
  15 +end
10 test/models/problem_test.rb
... ... @@ -0,0 +1,10 @@
  1 +require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
  2 +
  3 +context "Problem Model" do
  4 + setup { Problem.delete_all }
  5 + context "definition" do
  6 + setup { Problem.make }
  7 + asserts_topic.has_key :title, String
  8 + asserts_topic.has_key :description, String
  9 + end
  10 +end
1  test/test_config.rb
... ... @@ -1,5 +1,6 @@
1 1 PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
2 2 require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
  3 +require File.join(File.dirname(__FILE__),'blueprints')
3 4 require 'riot/rr'
4 5
5 6 # Specify your app using the #app helper inside a context.

0 comments on commit ceaf875

Please sign in to comment.
Something went wrong with that request. Please try again.