filtrum 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE.txt +20 -0
- data/README.md +8 -0
- data/VERSION +1 -0
- data/lib/filtrum.rb +4 -0
- data/lib/filtrum/config.rb +33 -0
- data/lib/filtrum/engine.rb +4 -0
- data/lib/filtrum/errors.rb +5 -0
- data/lib/filtrum/ext.rb +13 -0
- data/lib/filtrum/field.rb +84 -0
- data/lib/filtrum/global.rb +10 -0
- data/lib/filtrum/settings.rb +33 -0
- data/lib/filtrum/type_serializer.rb +17 -0
- data/lib/filtrum/version.rb +3 -0
- data/lib/filtrum/view.rb +116 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +14 -0
- data/spec/dummy/app/assets/stylesheets/application.css.sass +17 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/books_controller.rb +6 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/books_helper.rb +2 -0
- data/spec/dummy/app/models/book.rb +17 -0
- data/spec/dummy/app/views/books/index.html.haml +1 -0
- data/spec/dummy/app/views/layouts/application.html.haml +16 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +53 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +73 -0
- data/spec/dummy/config/environments/test.rb +34 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +66 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20121008115302_create_books.rb +12 -0
- data/spec/dummy/db/schema.rb +26 -0
- data/spec/dummy/db/seeds.rb +73 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +19 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/tmp/cache/assets/BF1/770/sprockets%2F8228a53c539c582499241527570aa216 +0 -0
- data/spec/dummy/tmp/cache/assets/C3F/0C0/sprockets%2F4643701467ac62c314510c8dd021916f +0 -0
- data/spec/dummy/tmp/cache/assets/C53/AD0/sprockets%2F712078516a81502575c831cb0a8e898e +0 -0
- data/spec/dummy/tmp/cache/assets/C59/0F0/sprockets%2F099f4e84a443568245ff0674030f6e05 +0 -0
- data/spec/dummy/tmp/cache/assets/C60/CF0/sprockets%2F32a45292ee67867d8715952f3072ad84 +0 -0
- data/spec/dummy/tmp/cache/assets/C6F/0E0/sprockets%2F82372776487d948ef7666d304d6fb345 +0 -0
- data/spec/dummy/tmp/cache/assets/C80/840/sprockets%2F562c2d168da585f80579347d10790a0a +0 -0
- data/spec/dummy/tmp/cache/assets/C82/F20/sprockets%2F117015d65237e3682f5b21c87d58ab95 +0 -0
- data/spec/dummy/tmp/cache/assets/C86/280/sprockets%2F1345c9947753f018f45371ec5083fa2d +0 -0
- data/spec/dummy/tmp/cache/assets/C91/350/sprockets%2F6864c49a10954375948d9f306db308fb +0 -0
- data/spec/dummy/tmp/cache/assets/C9A/900/sprockets%2Fc1b5b7611d7c10e124512724f29f241d +0 -0
- data/spec/dummy/tmp/cache/assets/CAF/540/sprockets%2F8f42e689b84f0b25c0180046467adf31 +0 -0
- data/spec/dummy/tmp/cache/assets/CB1/9A0/sprockets%2F57805dfa396248a9665cb4a0c85116d0 +0 -0
- data/spec/dummy/tmp/cache/assets/CC1/4E0/sprockets%2F6ef77414c793c84a437244d7d965ba90 +0 -0
- data/spec/dummy/tmp/cache/assets/CC3/B10/sprockets%2F0a2c59284c7a5d99581883a9763b5ad8 +0 -0
- data/spec/dummy/tmp/cache/assets/CC9/940/sprockets%2F8128c279185cf97dba7914278ce838b4 +0 -0
- data/spec/dummy/tmp/cache/assets/CCA/0C0/sprockets%2F6c3e053393afe303432ca73f1b41490b +0 -0
- data/spec/dummy/tmp/cache/assets/CD5/2C0/sprockets%2F166c056119ebdfb8b7104c97b424b423 +0 -0
- data/spec/dummy/tmp/cache/assets/CDB/610/sprockets%2F7adf20860b018477a95cdb8321b49d16 +0 -0
- data/spec/dummy/tmp/cache/assets/CDD/F50/sprockets%2F7353f31f80f1139aade47728a62af336 +0 -0
- data/spec/dummy/tmp/cache/assets/CE9/760/sprockets%2F5ae7fab601683996918936cad21fc244 +0 -0
- data/spec/dummy/tmp/cache/assets/CE9/B90/sprockets%2Fea2eb066933b1d8b5949972c3c79353a +0 -0
- data/spec/dummy/tmp/cache/assets/CF1/AF0/sprockets%2F14dc9633b61024231ebec0c1a4a0259f +0 -0
- data/spec/dummy/tmp/cache/assets/D02/340/sprockets%2Fae58ed66f72137a594b0912bab600e03 +0 -0
- data/spec/dummy/tmp/cache/assets/D0A/AC0/sprockets%2Fc154991d0a7564e15c0fb4a555c5c73d +0 -0
- data/spec/dummy/tmp/cache/assets/D0B/190/sprockets%2F68cb0d1054ca546fc473274c4ac8737c +0 -0
- data/spec/dummy/tmp/cache/assets/D11/530/sprockets%2F13bc8c66140adef2e97648630866aae3 +0 -0
- data/spec/dummy/tmp/cache/assets/D16/AA0/sprockets%2Ff181e659a47e2cf9c257f32d80452bd3 +0 -0
- data/spec/dummy/tmp/cache/assets/D18/840/sprockets%2F50c1885539f61359c48af74fcae1df31 +0 -0
- data/spec/dummy/tmp/cache/assets/D1B/940/sprockets%2F7c4819d1dd9b64a22941d8c7bd1e6954 +0 -0
- data/spec/dummy/tmp/cache/assets/D2B/1F0/sprockets%2F6a4c116e8316d082bb0ffae02e94b107 +0 -0
- data/spec/dummy/tmp/cache/assets/D3C/E20/sprockets%2Ffc6c44ec250bc532c55649e5292b5c1f +0 -0
- data/spec/dummy/tmp/cache/assets/D4B/C30/sprockets%2Fe8aa746e637d69ff0ac1e71e528c5292 +0 -0
- data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/D5A/E20/sprockets%2Febf23d670481ba70b341aa2eb6e37b08 +0 -0
- data/spec/dummy/tmp/cache/assets/D5C/1F0/sprockets%2F2d3f2cfd98bf787168fb59f84ab24784 +0 -0
- data/spec/dummy/tmp/cache/assets/D5D/C60/sprockets%2Ffa0336b42d01aa9173d9d4c12fc4e82d +0 -0
- data/spec/dummy/tmp/cache/assets/D65/DD0/sprockets%2Fed4503679ef66f0e597bfc738bc9e698 +0 -0
- data/spec/dummy/tmp/cache/assets/D68/930/sprockets%2F5a15e52e84502f9fceb7ea04020f65fc +0 -0
- data/spec/dummy/tmp/cache/assets/D8C/140/sprockets%2F2afdbb3902a1be5d2f045cfc837903a3 +0 -0
- data/spec/dummy/tmp/cache/assets/D8E/660/sprockets%2F3a3eed926bdf64000ccacb36022f78d4 +0 -0
- data/spec/dummy/tmp/cache/assets/D95/690/sprockets%2Fe4d19a04705ee5d72c7fa64dc2070ddb +0 -0
- data/spec/dummy/tmp/cache/assets/DA4/EC0/sprockets%2F8da2289e16c1d0cac94aa825ee18d99d +0 -0
- data/spec/dummy/tmp/cache/assets/DA6/120/sprockets%2Fc5880aca76ccbb51f9388362e8afc1e6 +0 -0
- data/spec/dummy/tmp/cache/assets/DA7/390/sprockets%2F25e744cd1b6f8f7ce1d52c1e86a8f19a +0 -0
- data/spec/dummy/tmp/cache/assets/DAB/3E0/sprockets%2F63d2fa621beec4fe878f9eb2884426ab +0 -0
- data/spec/dummy/tmp/cache/assets/DAB/660/sprockets%2F9a8c36769afcc7027b4b6ee0c3e77ce5 +0 -0
- data/spec/dummy/tmp/cache/assets/DBF/EB0/sprockets%2F2afcec323c8ba12a2b7c852f23aa589e +0 -0
- data/spec/dummy/tmp/cache/assets/DCE/9F0/sprockets%2F8fa8c08ea8da97c06cd6c32fe3e613b0 +0 -0
- data/spec/dummy/tmp/cache/assets/DCF/E50/sprockets%2Fc39ff2ed4e1fb4269c39d415acf0d90b +0 -0
- data/spec/dummy/tmp/cache/assets/DD8/0A0/sprockets%2Fb2c3097effcd6084ec75e1f745d1d7dd +0 -0
- data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/DF0/040/sprockets%2F04bbbe1ee5ca914173cd90cf6e8a4e0b +0 -0
- data/spec/dummy/tmp/cache/assets/DF7/C80/sprockets%2Ff503b3666caf04beb7cfe54cbdb0575e +0 -0
- data/spec/dummy/tmp/cache/assets/DFA/B70/sprockets%2F262fb95d3f7cfc16febb0f0128ac38ce +0 -0
- data/spec/dummy/tmp/cache/assets/E03/260/sprockets%2Fd1fcfea59ff53c32557ffcd93016cb2e +0 -0
- data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/E0A/510/sprockets%2F8efee416ba436e75bea85d4d367faea7 +0 -0
- data/spec/dummy/tmp/cache/assets/E43/810/sprockets%2F79b0ef75ceb26a9c8fca797db3efba96 +0 -0
- data/spec/dummy/tmp/cache/assets/E96/1B0/sprockets%2F6d5fe51f9c1a3d2f898becd0bcddef3e +0 -0
- data/spec/dummy/tmp/cache/assets/ED4/410/sprockets%2F082adbb8e2abd8a21c8b34aebbbfbfad +0 -0
- data/spec/dummy/tmp/pids/server.pid +1 -0
- data/spec/models/book_spec.rb +8 -0
- data/spec/spec_helper.rb +94 -0
- data/spec/version_spec.rb +8 -0
- metadata +278 -0
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateBooks < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :books do |t|
|
4
|
+
t.string :title, :null => false
|
5
|
+
t.string :author, :null => false
|
6
|
+
t.integer :year, :null => false
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index :books, :title, :unique => true
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20121008115302) do
|
15
|
+
|
16
|
+
create_table "books", :force => true do |t|
|
17
|
+
t.string "title", :null => false
|
18
|
+
t.string "author", :null => false
|
19
|
+
t.integer "year", :null => false
|
20
|
+
t.datetime "created_at", :null => false
|
21
|
+
t.datetime "updated_at", :null => false
|
22
|
+
end
|
23
|
+
|
24
|
+
add_index "books", ["title"], :name => "index_books_on_title", :unique => true
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
[
|
4
|
+
{
|
5
|
+
:title => "Nineteen Eighty-Four",
|
6
|
+
:author => "George Orwell",
|
7
|
+
:year => 1949
|
8
|
+
},
|
9
|
+
{
|
10
|
+
:title => "Fahrenheit 451",
|
11
|
+
:author => "Ray Bradbury",
|
12
|
+
:year => 1953
|
13
|
+
},
|
14
|
+
{
|
15
|
+
:title => "A Tale of Two Cities",
|
16
|
+
:author => "Charles Dickens",
|
17
|
+
:year => 1859
|
18
|
+
},
|
19
|
+
{
|
20
|
+
:title => "Robinson Crusoe",
|
21
|
+
:author => "Daniel Defoe",
|
22
|
+
:year => 1719
|
23
|
+
},
|
24
|
+
{
|
25
|
+
:title => "Emma",
|
26
|
+
:author => "Jane Austen",
|
27
|
+
:year => 1815
|
28
|
+
},
|
29
|
+
{
|
30
|
+
:title => "Frankenstein",
|
31
|
+
:author => "Mary Shelley",
|
32
|
+
:year => 1818
|
33
|
+
},
|
34
|
+
{
|
35
|
+
:title => "The Count of Monte Cristo",
|
36
|
+
:author => "Alexandre Dumas",
|
37
|
+
:year => 1844
|
38
|
+
},
|
39
|
+
{
|
40
|
+
:title => "Wuthering Heights",
|
41
|
+
:author => "Emily Brontë",
|
42
|
+
:year => 1847
|
43
|
+
},
|
44
|
+
{
|
45
|
+
:title => "The Woman in White",
|
46
|
+
:author => "Wilkie Collins",
|
47
|
+
:year => 1859
|
48
|
+
},
|
49
|
+
{
|
50
|
+
:title => "Alice's Adventures In Wonderland",
|
51
|
+
:author => "Lewis Carroll",
|
52
|
+
:year => 1865
|
53
|
+
},
|
54
|
+
{
|
55
|
+
:title => "The Portrait of a Lady",
|
56
|
+
:author => "Henry James",
|
57
|
+
:year => 1881
|
58
|
+
},
|
59
|
+
{
|
60
|
+
:title => "Brave New World",
|
61
|
+
:author => "Aldous Huxley",
|
62
|
+
:year => 1932
|
63
|
+
}
|
64
|
+
].each_with_index do |data,i|
|
65
|
+
b = Book.new
|
66
|
+
b.title = data[:title]
|
67
|
+
b.author = data[:author]
|
68
|
+
b.year = data[:year]
|
69
|
+
b.created_at = (Time.now - (i + 5).days)
|
70
|
+
b.updated_at = b.created_at + rand(3).days
|
71
|
+
puts %|Added "#{data[:title]}"|
|
72
|
+
b.save!
|
73
|
+
end
|
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Connecting to database specified by database.yml
|
2
|
+
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
3
|
+
Migrating to CreateBooks (20121008115302)
|
4
|
+
[1m[35m (0.1ms)[0m begin transaction
|
5
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
6
|
+
[1m[35m (0.0ms)[0m begin transaction
|
7
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
8
|
+
[1m[36m (1.4ms)[0m [1mCREATE TABLE "books" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "author" varchar(255) NOT NULL, "year" integer NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
9
|
+
[1m[35m (0.7ms)[0m CREATE UNIQUE INDEX "index_books_on_title" ON "books" ("title")
|
10
|
+
[1m[36m (0.7ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
11
|
+
[1m[35m (0.7ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
12
|
+
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
13
|
+
[1m[35m (0.6ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20121008115302')
|
14
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
15
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.3ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
16
|
+
[1m[35m (0.1ms)[0m begin transaction
|
17
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
18
|
+
[1m[35m (0.1ms)[0m begin transaction
|
19
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
3682
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'rspec/autorun'
|
6
|
+
require 'capybara/rspec'
|
7
|
+
require 'database_cleaner'
|
8
|
+
require 'factory_girl'
|
9
|
+
|
10
|
+
DatabaseCleaner.strategy = :truncation
|
11
|
+
Capybara.default_driver = :selenium
|
12
|
+
FactoryGirl.find_definitions
|
13
|
+
|
14
|
+
# Run any available migration
|
15
|
+
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
16
|
+
|
17
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
18
|
+
# in spec/support/ and its subdirectories.
|
19
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
20
|
+
|
21
|
+
module TestServerHelper
|
22
|
+
def visit_test_server *args
|
23
|
+
args.unshift test_server_root_url
|
24
|
+
visit URI.join(*args).to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_server_root_url
|
28
|
+
"http://localhost:#{RSpec.configuration.test_server_port}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
RSpec.configure do |config|
|
33
|
+
# ## Mock Framework
|
34
|
+
#
|
35
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
36
|
+
#
|
37
|
+
# config.mock_with :mocha
|
38
|
+
# config.mock_with :flexmock
|
39
|
+
# config.mock_with :rr
|
40
|
+
|
41
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
42
|
+
#config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
43
|
+
config.include FactoryGirl::Syntax::Methods
|
44
|
+
|
45
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
46
|
+
# examples within a transaction, remove the following line or assign false
|
47
|
+
# instead of true.
|
48
|
+
config.use_transactional_fixtures = true
|
49
|
+
|
50
|
+
# If true, the base class of anonymous controllers will be inferred
|
51
|
+
# automatically. This will be the default behavior in future versions of
|
52
|
+
# rspec-rails.
|
53
|
+
config.infer_base_class_for_anonymous_controllers = false
|
54
|
+
|
55
|
+
# Run specs in random order to surface order dependencies. If you find an
|
56
|
+
# order dependency and want to debug it, you can fix the order by providing
|
57
|
+
# the seed, which is printed after each run.
|
58
|
+
# --seed 1234
|
59
|
+
config.order = "random"
|
60
|
+
|
61
|
+
# Test server for capybara tests
|
62
|
+
# Skip it for fast specs
|
63
|
+
=begin
|
64
|
+
unless config.try(:exclusion_filter).try(:[], :type) == 'request'
|
65
|
+
|
66
|
+
# Test server settings
|
67
|
+
config.add_setting :test_server_wait
|
68
|
+
config.add_setting :test_server_port
|
69
|
+
config.test_server_wait = 3
|
70
|
+
config.test_server_port = 3001
|
71
|
+
config.include TestServerHelper
|
72
|
+
|
73
|
+
# Start test server before all tests
|
74
|
+
config.before :suite do
|
75
|
+
puts
|
76
|
+
port = config.test_server_port
|
77
|
+
wait = config.test_server_wait
|
78
|
+
puts Paint["Starting test server...", :magenta]
|
79
|
+
raise 'Could not start test server' unless system "bundle exec thin start -e test -p #{port} -d"
|
80
|
+
puts Paint["Waiting #{wait} seconds for test server to start...", :magenta]
|
81
|
+
sleep wait
|
82
|
+
puts Paint["Successfully started test server on port #{port}.", :cyan, :bold]
|
83
|
+
end
|
84
|
+
|
85
|
+
# Stop test server after all tests
|
86
|
+
config.after :suite do
|
87
|
+
puts
|
88
|
+
puts Paint["Stopping test server...", :magenta]
|
89
|
+
raise 'Could not stop test server' unless system "bundle exec thin stop -e test"
|
90
|
+
puts Paint["Successfully stopped test server.", :cyan, :bold]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
=end
|
94
|
+
end
|