resource_inclusion 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +95 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +126 -0
- data/Rakefile +44 -0
- data/lib/resource_inclusion/class_methods.rb +24 -0
- data/lib/resource_inclusion/instance_methods.rb +9 -0
- data/lib/resource_inclusion/resource_include_responder.rb +10 -0
- data/lib/resource_inclusion/resource_inclusion.rb +13 -0
- data/lib/resource_inclusion/version.rb +3 -0
- data/lib/resource_inclusion.rb +4 -0
- data/resource_inclusion.gemspec +97 -0
- data/test/app/Gemfile +8 -0
- data/test/app/Gemfile.lock +88 -0
- data/test/app/Rakefile +7 -0
- data/test/app/app/controllers/application_controller.rb +4 -0
- data/test/app/app/controllers/comments_controller.rb +17 -0
- data/test/app/app/models/comment.rb +3 -0
- data/test/app/app/models/user.rb +2 -0
- data/test/app/config/application.rb +17 -0
- data/test/app/config/boot.rb +13 -0
- data/test/app/config/database.yml +17 -0
- data/test/app/config/environment.rb +5 -0
- data/test/app/config/environments/test.rb +35 -0
- data/test/app/config/routes.rb +3 -0
- data/test/app/config.ru +4 -0
- data/test/app/db/development.sqlite3 +0 -0
- data/test/app/db/migrate/20110111090943_initial_test.rb +22 -0
- data/test/app/db/test.sqlite3 +0 -0
- data/test/app/log/development.log +288 -0
- data/test/app/log/test.log +90 -0
- data/test/app/spec/controllers/comments_controller_spec.rb +53 -0
- data/test/app/spec/spec_helper.rb +27 -0
- data/test/app/spec/support/xpath_matcher.rb +108 -0
- metadata +170 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
App::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Raise exceptions instead of rendering exception templates
|
18
|
+
config.action_dispatch.show_exceptions = false
|
19
|
+
|
20
|
+
# Disable request forgery protection in test environment
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
22
|
+
|
23
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
24
|
+
# The :test delivery method accumulates sent emails in the
|
25
|
+
# ActionMailer::Base.deliveries array.
|
26
|
+
config.action_mailer.delivery_method = :test
|
27
|
+
|
28
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
29
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
30
|
+
# like if you have constraints or database-specific column types
|
31
|
+
# config.active_record.schema_format = :sql
|
32
|
+
|
33
|
+
# Print deprecation notices to the stderr
|
34
|
+
config.active_support.deprecation = :stderr
|
35
|
+
end
|
data/test/app/config.ru
ADDED
Binary file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class InitialTest < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
|
4
|
+
create_table :users do |t|
|
5
|
+
t.string :login_id
|
6
|
+
t.string :display_name
|
7
|
+
t.string :email
|
8
|
+
end
|
9
|
+
|
10
|
+
create_table :comments do |t|
|
11
|
+
t.text :text
|
12
|
+
t.references :user
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.down
|
18
|
+
drop_table :users
|
19
|
+
drop_table :comments
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
Binary file
|
@@ -0,0 +1,288 @@
|
|
1
|
+
[1m[36mSQL (0.4ms)[0m [1m SELECT name
|
2
|
+
FROM sqlite_master
|
3
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
4
|
+
[0m
|
5
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
6
|
+
FROM sqlite_master
|
7
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
8
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations"[0m
|
9
|
+
[1m[35mSQL (0.1ms)[0m select sqlite_version(*)
|
10
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
11
|
+
FROM sqlite_master
|
12
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
13
|
+
[0m
|
14
|
+
[1m[35mSQL (3.2ms)[0m CREATE TABLE "comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "text" text, "user_id" integer)
|
15
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
16
|
+
FROM sqlite_master
|
17
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
18
|
+
[0m
|
19
|
+
[1m[35mSQL (1.8ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login_id" varchar(255), "display_name" varchar(255), "email" varchar(255))
|
20
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
21
|
+
FROM sqlite_master
|
22
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
23
|
+
[0m
|
24
|
+
[1m[35mSQL (2.2ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
25
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
26
|
+
[1m[35mSQL (1.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
27
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
28
|
+
FROM sqlite_master
|
29
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
30
|
+
[0m
|
31
|
+
[1m[35mSQL (0.1ms)[0m SELECT version FROM "schema_migrations"
|
32
|
+
[1m[36mSQL (3.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110111090943')[0m
|
33
|
+
[1m[36mSQL (0.4ms)[0m [1m SELECT name
|
34
|
+
FROM sqlite_master
|
35
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
36
|
+
[0m
|
37
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
38
|
+
FROM sqlite_master
|
39
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
40
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations"[0m
|
41
|
+
[1m[35mSQL (0.1ms)[0m select sqlite_version(*)
|
42
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
43
|
+
FROM sqlite_master
|
44
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
45
|
+
[0m
|
46
|
+
[1m[35mSQL (3.0ms)[0m CREATE TABLE "comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "text" text, "user_id" integer)
|
47
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
48
|
+
FROM sqlite_master
|
49
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
50
|
+
[0m
|
51
|
+
[1m[35mSQL (1.8ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login_id" varchar(255), "display_name" varchar(255), "email" varchar(255))
|
52
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
53
|
+
FROM sqlite_master
|
54
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
55
|
+
[0m
|
56
|
+
[1m[35mSQL (2.3ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
57
|
+
[1m[36mSQL (0.1ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
58
|
+
[1m[35mSQL (2.2ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
59
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
60
|
+
FROM sqlite_master
|
61
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
62
|
+
[0m
|
63
|
+
[1m[35mSQL (0.1ms)[0m SELECT version FROM "schema_migrations"
|
64
|
+
[1m[36mSQL (4.5ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110111090943')[0m
|
65
|
+
[1m[36mSQL (0.4ms)[0m [1m SELECT name
|
66
|
+
FROM sqlite_master
|
67
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
68
|
+
[0m
|
69
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
70
|
+
FROM sqlite_master
|
71
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
72
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations"[0m
|
73
|
+
[1m[35mSQL (0.1ms)[0m select sqlite_version(*)
|
74
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
75
|
+
FROM sqlite_master
|
76
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
77
|
+
[0m
|
78
|
+
[1m[35mSQL (3.0ms)[0m CREATE TABLE "comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "text" text, "user_id" integer)
|
79
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
80
|
+
FROM sqlite_master
|
81
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
82
|
+
[0m
|
83
|
+
[1m[35mSQL (1.8ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login_id" varchar(255), "display_name" varchar(255), "email" varchar(255))
|
84
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
85
|
+
FROM sqlite_master
|
86
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
87
|
+
[0m
|
88
|
+
[1m[35mSQL (2.3ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
89
|
+
[1m[36mSQL (0.1ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
90
|
+
[1m[35mSQL (2.6ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
91
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
92
|
+
FROM sqlite_master
|
93
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
94
|
+
[0m
|
95
|
+
[1m[35mSQL (0.1ms)[0m SELECT version FROM "schema_migrations"
|
96
|
+
[1m[36mSQL (2.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110111090943')[0m
|
97
|
+
[1m[36mSQL (0.4ms)[0m [1m SELECT name
|
98
|
+
FROM sqlite_master
|
99
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
100
|
+
[0m
|
101
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
102
|
+
FROM sqlite_master
|
103
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
104
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations"[0m
|
105
|
+
[1m[35mSQL (0.1ms)[0m select sqlite_version(*)
|
106
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
107
|
+
FROM sqlite_master
|
108
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
109
|
+
[0m
|
110
|
+
[1m[35mSQL (4.0ms)[0m CREATE TABLE "comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "text" text, "user_id" integer)
|
111
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
112
|
+
FROM sqlite_master
|
113
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
114
|
+
[0m
|
115
|
+
[1m[35mSQL (2.0ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login_id" varchar(255), "display_name" varchar(255), "email" varchar(255))
|
116
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
117
|
+
FROM sqlite_master
|
118
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
119
|
+
[0m
|
120
|
+
[1m[35mSQL (2.2ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
121
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
122
|
+
[1m[35mSQL (1.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
123
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
124
|
+
FROM sqlite_master
|
125
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
126
|
+
[0m
|
127
|
+
[1m[35mSQL (0.1ms)[0m SELECT version FROM "schema_migrations"
|
128
|
+
[1m[36mSQL (2.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110111090943')[0m
|
129
|
+
[1m[36mSQL (0.5ms)[0m [1m SELECT name
|
130
|
+
FROM sqlite_master
|
131
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
132
|
+
[0m
|
133
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
134
|
+
FROM sqlite_master
|
135
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
136
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations"[0m
|
137
|
+
[1m[35mSQL (0.1ms)[0m select sqlite_version(*)
|
138
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
139
|
+
FROM sqlite_master
|
140
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
141
|
+
[0m
|
142
|
+
[1m[35mSQL (3.3ms)[0m CREATE TABLE "comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "text" text, "user_id" integer)
|
143
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
144
|
+
FROM sqlite_master
|
145
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
146
|
+
[0m
|
147
|
+
[1m[35mSQL (1.8ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login_id" varchar(255), "display_name" varchar(255), "email" varchar(255))
|
148
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
149
|
+
FROM sqlite_master
|
150
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
151
|
+
[0m
|
152
|
+
[1m[35mSQL (2.5ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
153
|
+
[1m[36mSQL (0.1ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
154
|
+
[1m[35mSQL (2.0ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
155
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
156
|
+
FROM sqlite_master
|
157
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
158
|
+
[0m
|
159
|
+
[1m[35mSQL (0.1ms)[0m SELECT version FROM "schema_migrations"
|
160
|
+
[1m[36mSQL (2.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110111090943')[0m
|
161
|
+
[1m[36mSQL (0.5ms)[0m [1m SELECT name
|
162
|
+
FROM sqlite_master
|
163
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
164
|
+
[0m
|
165
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
166
|
+
FROM sqlite_master
|
167
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
168
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations"[0m
|
169
|
+
[1m[35mSQL (0.1ms)[0m select sqlite_version(*)
|
170
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
171
|
+
FROM sqlite_master
|
172
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
173
|
+
[0m
|
174
|
+
[1m[35mSQL (3.1ms)[0m CREATE TABLE "comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "text" text, "user_id" integer)
|
175
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
176
|
+
FROM sqlite_master
|
177
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
178
|
+
[0m
|
179
|
+
[1m[35mSQL (1.9ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login_id" varchar(255), "display_name" varchar(255), "email" varchar(255))
|
180
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
181
|
+
FROM sqlite_master
|
182
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
183
|
+
[0m
|
184
|
+
[1m[35mSQL (2.4ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
185
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
186
|
+
[1m[35mSQL (1.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
187
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
188
|
+
FROM sqlite_master
|
189
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
190
|
+
[0m
|
191
|
+
[1m[35mSQL (0.1ms)[0m SELECT version FROM "schema_migrations"
|
192
|
+
[1m[36mSQL (2.3ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110111090943')[0m
|
193
|
+
[1m[36mSQL (0.4ms)[0m [1m SELECT name
|
194
|
+
FROM sqlite_master
|
195
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
196
|
+
[0m
|
197
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
198
|
+
FROM sqlite_master
|
199
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
200
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations"[0m
|
201
|
+
[1m[35mSQL (0.1ms)[0m select sqlite_version(*)
|
202
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
203
|
+
FROM sqlite_master
|
204
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
205
|
+
[0m
|
206
|
+
[1m[35mSQL (3.1ms)[0m CREATE TABLE "comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "text" text, "user_id" integer)
|
207
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
208
|
+
FROM sqlite_master
|
209
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
210
|
+
[0m
|
211
|
+
[1m[35mSQL (1.8ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login_id" varchar(255), "display_name" varchar(255), "email" varchar(255))
|
212
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
213
|
+
FROM sqlite_master
|
214
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
215
|
+
[0m
|
216
|
+
[1m[35mSQL (2.4ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
217
|
+
[1m[36mSQL (0.1ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
218
|
+
[1m[35mSQL (2.1ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
219
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
220
|
+
FROM sqlite_master
|
221
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
222
|
+
[0m
|
223
|
+
[1m[35mSQL (0.1ms)[0m SELECT version FROM "schema_migrations"
|
224
|
+
[1m[36mSQL (2.3ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110111090943')[0m
|
225
|
+
[1m[36mSQL (0.4ms)[0m [1m SELECT name
|
226
|
+
FROM sqlite_master
|
227
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
228
|
+
[0m
|
229
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
230
|
+
FROM sqlite_master
|
231
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
232
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations"[0m
|
233
|
+
[1m[35mSQL (0.1ms)[0m select sqlite_version(*)
|
234
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
235
|
+
FROM sqlite_master
|
236
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
237
|
+
[0m
|
238
|
+
[1m[35mSQL (3.2ms)[0m CREATE TABLE "comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "text" text, "user_id" integer)
|
239
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
240
|
+
FROM sqlite_master
|
241
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
242
|
+
[0m
|
243
|
+
[1m[35mSQL (1.9ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login_id" varchar(255), "display_name" varchar(255), "email" varchar(255))
|
244
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
245
|
+
FROM sqlite_master
|
246
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
247
|
+
[0m
|
248
|
+
[1m[35mSQL (2.2ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
249
|
+
[1m[36mSQL (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
250
|
+
[1m[35mSQL (1.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
251
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
252
|
+
FROM sqlite_master
|
253
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
254
|
+
[0m
|
255
|
+
[1m[35mSQL (0.1ms)[0m SELECT version FROM "schema_migrations"
|
256
|
+
[1m[36mSQL (2.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110111090943')[0m
|
257
|
+
[1m[36mSQL (0.4ms)[0m [1m SELECT name
|
258
|
+
FROM sqlite_master
|
259
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
260
|
+
[0m
|
261
|
+
[1m[35mSQL (0.1ms)[0m SELECT name
|
262
|
+
FROM sqlite_master
|
263
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
264
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations"[0m
|
265
|
+
[1m[35mSQL (0.1ms)[0m select sqlite_version(*)
|
266
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
267
|
+
FROM sqlite_master
|
268
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
269
|
+
[0m
|
270
|
+
[1m[35mSQL (4.0ms)[0m CREATE TABLE "comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "text" text, "user_id" integer)
|
271
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
272
|
+
FROM sqlite_master
|
273
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
274
|
+
[0m
|
275
|
+
[1m[35mSQL (1.8ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login_id" varchar(255), "display_name" varchar(255), "email" varchar(255))
|
276
|
+
[1m[36mSQL (0.1ms)[0m [1m SELECT name
|
277
|
+
FROM sqlite_master
|
278
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
279
|
+
[0m
|
280
|
+
[1m[35mSQL (2.2ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
281
|
+
[1m[36mSQL (0.1ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
282
|
+
[1m[35mSQL (3.3ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
283
|
+
[1m[36mSQL (0.4ms)[0m [1m SELECT name
|
284
|
+
FROM sqlite_master
|
285
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
286
|
+
[0m
|
287
|
+
[1m[35mSQL (0.2ms)[0m SELECT version FROM "schema_migrations"
|
288
|
+
[1m[36mSQL (3.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20110111090943')[0m
|
@@ -0,0 +1,90 @@
|
|
1
|
+
Processing by CommentsController#index as XML
|
2
|
+
Completed 200 OK in 23ms (Views: 17.6ms | ActiveRecord: 0.0ms)
|
3
|
+
Processing by CommentsController#index as JSON
|
4
|
+
Completed 200 OK in 59ms (Views: 55.8ms | ActiveRecord: 0.0ms)
|
5
|
+
Processing by CommentsController#show as XML
|
6
|
+
Parameters: {"id"=>"1"}
|
7
|
+
Completed 200 OK in 3ms (Views: 1.3ms | ActiveRecord: 0.0ms)
|
8
|
+
Processing by CommentsController#show as JSON
|
9
|
+
Parameters: {"id"=>"1"}
|
10
|
+
Completed 200 OK in 2ms (Views: 0.9ms | ActiveRecord: 0.0ms)
|
11
|
+
Processing by CommentsController#index as XML
|
12
|
+
Completed 200 OK in 22ms (Views: 17.4ms | ActiveRecord: 0.0ms)
|
13
|
+
Processing by CommentsController#index as JSON
|
14
|
+
Completed 200 OK in 4ms (Views: 0.9ms | ActiveRecord: 0.0ms)
|
15
|
+
Processing by CommentsController#show as XML
|
16
|
+
Parameters: {"id"=>"1"}
|
17
|
+
Completed 200 OK in 3ms (Views: 1.3ms | ActiveRecord: 0.0ms)
|
18
|
+
Processing by CommentsController#show as JSON
|
19
|
+
Parameters: {"id"=>"1"}
|
20
|
+
Completed 200 OK in 2ms (Views: 0.9ms | ActiveRecord: 0.0ms)
|
21
|
+
Processing by CommentsController#index as XML
|
22
|
+
Completed 200 OK in 22ms (Views: 17.4ms | ActiveRecord: 0.0ms)
|
23
|
+
Processing by CommentsController#index as JSON
|
24
|
+
Completed 200 OK in 4ms (Views: 0.9ms | ActiveRecord: 0.0ms)
|
25
|
+
Processing by CommentsController#show as XML
|
26
|
+
Parameters: {"id"=>"1"}
|
27
|
+
Completed 200 OK in 3ms (Views: 1.3ms | ActiveRecord: 0.0ms)
|
28
|
+
Processing by CommentsController#show as JSON
|
29
|
+
Parameters: {"id"=>"1"}
|
30
|
+
Completed 200 OK in 3ms (Views: 1.0ms | ActiveRecord: 0.0ms)
|
31
|
+
Processing by CommentsController#index as XML
|
32
|
+
Completed 200 OK in 22ms (Views: 17.5ms | ActiveRecord: 0.0ms)
|
33
|
+
Processing by CommentsController#index as JSON
|
34
|
+
Completed 200 OK in 4ms (Views: 0.9ms | ActiveRecord: 0.0ms)
|
35
|
+
Processing by CommentsController#show as XML
|
36
|
+
Parameters: {"id"=>"1"}
|
37
|
+
Completed 200 OK in 3ms (Views: 1.3ms | ActiveRecord: 0.0ms)
|
38
|
+
Processing by CommentsController#show as JSON
|
39
|
+
Parameters: {"id"=>"1"}
|
40
|
+
Completed 200 OK in 2ms (Views: 0.8ms | ActiveRecord: 0.0ms)
|
41
|
+
Processing by CommentsController#index as XML
|
42
|
+
Completed 200 OK in 22ms (Views: 17.2ms | ActiveRecord: 0.0ms)
|
43
|
+
Processing by CommentsController#index as JSON
|
44
|
+
Completed 200 OK in 4ms (Views: 0.9ms | ActiveRecord: 0.0ms)
|
45
|
+
Processing by CommentsController#show as XML
|
46
|
+
Parameters: {"id"=>"1"}
|
47
|
+
Completed 200 OK in 3ms (Views: 1.3ms | ActiveRecord: 0.0ms)
|
48
|
+
Processing by CommentsController#show as JSON
|
49
|
+
Parameters: {"id"=>"1"}
|
50
|
+
Completed 200 OK in 2ms (Views: 0.9ms | ActiveRecord: 0.0ms)
|
51
|
+
Processing by CommentsController#index as XML
|
52
|
+
Completed 200 OK in 21ms (Views: 15.8ms | ActiveRecord: 0.0ms)
|
53
|
+
Processing by CommentsController#index as JSON
|
54
|
+
Completed 200 OK in 4ms (Views: 0.9ms | ActiveRecord: 0.0ms)
|
55
|
+
Processing by CommentsController#show as XML
|
56
|
+
Parameters: {"id"=>"1"}
|
57
|
+
Completed 200 OK in 3ms (Views: 1.2ms | ActiveRecord: 0.0ms)
|
58
|
+
Processing by CommentsController#show as JSON
|
59
|
+
Parameters: {"id"=>"1"}
|
60
|
+
Completed 200 OK in 2ms (Views: 0.8ms | ActiveRecord: 0.0ms)
|
61
|
+
Processing by CommentsController#index as XML
|
62
|
+
Completed 200 OK in 21ms (Views: 16.0ms | ActiveRecord: 0.0ms)
|
63
|
+
Processing by CommentsController#index as JSON
|
64
|
+
Completed 200 OK in 4ms (Views: 0.9ms | ActiveRecord: 0.0ms)
|
65
|
+
Processing by CommentsController#show as XML
|
66
|
+
Parameters: {"id"=>"1"}
|
67
|
+
Completed 200 OK in 3ms (Views: 1.3ms | ActiveRecord: 0.0ms)
|
68
|
+
Processing by CommentsController#show as JSON
|
69
|
+
Parameters: {"id"=>"1"}
|
70
|
+
Completed 200 OK in 2ms (Views: 0.8ms | ActiveRecord: 0.0ms)
|
71
|
+
Processing by CommentsController#index as XML
|
72
|
+
Completed 200 OK in 21ms (Views: 16.3ms | ActiveRecord: 0.0ms)
|
73
|
+
Processing by CommentsController#index as JSON
|
74
|
+
Completed 200 OK in 4ms (Views: 0.9ms | ActiveRecord: 0.0ms)
|
75
|
+
Processing by CommentsController#show as XML
|
76
|
+
Parameters: {"id"=>"1"}
|
77
|
+
Completed 200 OK in 3ms (Views: 1.3ms | ActiveRecord: 0.0ms)
|
78
|
+
Processing by CommentsController#show as JSON
|
79
|
+
Parameters: {"id"=>"1"}
|
80
|
+
Completed 200 OK in 2ms (Views: 0.8ms | ActiveRecord: 0.0ms)
|
81
|
+
Processing by CommentsController#index as XML
|
82
|
+
Completed 200 OK in 21ms (Views: 15.9ms | ActiveRecord: 0.0ms)
|
83
|
+
Processing by CommentsController#index as JSON
|
84
|
+
Completed 200 OK in 4ms (Views: 0.9ms | ActiveRecord: 0.0ms)
|
85
|
+
Processing by CommentsController#show as XML
|
86
|
+
Parameters: {"id"=>"1"}
|
87
|
+
Completed 200 OK in 3ms (Views: 1.2ms | ActiveRecord: 0.0ms)
|
88
|
+
Processing by CommentsController#show as JSON
|
89
|
+
Parameters: {"id"=>"1"}
|
90
|
+
Completed 200 OK in 2ms (Views: 0.7ms | ActiveRecord: 0.0ms)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
describe CommentsController do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
|
7
|
+
@comment = Comment.new(
|
8
|
+
:text => 'my comment',
|
9
|
+
:user => User.new(
|
10
|
+
:login_id => 'ping',
|
11
|
+
:display_name => 'Ping the Duck',
|
12
|
+
:email => 'ping@yellow-river.tld'
|
13
|
+
))
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "GET index" do
|
18
|
+
|
19
|
+
before :each do
|
20
|
+
Comment.should_receive(:all).and_return( [@comment] )
|
21
|
+
end
|
22
|
+
|
23
|
+
it "includes user in the xml" do
|
24
|
+
get :index, :format => 'xml'
|
25
|
+
response.body.should have_xpath("/comments/comment/user/display-name")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "includes user in the json" do
|
29
|
+
get :index, :format => 'json'
|
30
|
+
response.body.should == [@comment].to_json(:include => :user )
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "GET show" do
|
35
|
+
|
36
|
+
before :each do
|
37
|
+
Comment.should_receive(:find).and_return( @comment )
|
38
|
+
end
|
39
|
+
|
40
|
+
it "includes user in the xml" do
|
41
|
+
get :show, {:id => '1', :format => 'xml'}
|
42
|
+
response.body.should have_xpath("/comment/user/display-name")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "includes user in the json" do
|
46
|
+
get :show, {:id => '1', :format => 'json'}
|
47
|
+
response.body.should == @comment.to_json( :include => :user )
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../../config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
|
6
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
7
|
+
# in spec/support/ and its subdirectories.
|
8
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
# == Mock Framework
|
12
|
+
#
|
13
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
14
|
+
#
|
15
|
+
# config.mock_with :mocha
|
16
|
+
# config.mock_with :flexmock
|
17
|
+
# config.mock_with :rr
|
18
|
+
config.mock_with :rspec
|
19
|
+
|
20
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
21
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
22
|
+
|
23
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
24
|
+
# examples within a transaction, remove the following line or assign false
|
25
|
+
# instead of true.
|
26
|
+
config.use_transactional_fixtures = true
|
27
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# Thanks to Jim Morris. http://blog.wolfman.com/articles/2008/1/2/xpath-matchers-for-rspec
|
2
|
+
require 'rexml/document'
|
3
|
+
require 'rexml/element'
|
4
|
+
|
5
|
+
module RSpec
|
6
|
+
module Matchers
|
7
|
+
# check if the xpath exists one or more times
|
8
|
+
class HaveXpath
|
9
|
+
def initialize(xpath)
|
10
|
+
@xpath = xpath
|
11
|
+
end
|
12
|
+
|
13
|
+
def matches?(response)
|
14
|
+
@response = response
|
15
|
+
doc = response.is_a?(REXML::Document) ? response : REXML::Document.new(@response)
|
16
|
+
match = REXML::XPath.match(doc, @xpath)
|
17
|
+
not match.empty?
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure_message
|
21
|
+
"Did not find expected xpath #{@xpath}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def negative_failure_message
|
25
|
+
"Did find unexpected xpath #{@xpath}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def description
|
29
|
+
"match the xpath expression #{@xpath}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def have_xpath(xpath)
|
34
|
+
HaveXpath.new(xpath)
|
35
|
+
end
|
36
|
+
|
37
|
+
# check if the xpath has the specified value
|
38
|
+
# value is a string and there must be a single result to match its
|
39
|
+
# equality against
|
40
|
+
class MatchXpath
|
41
|
+
def initialize(xpath, val)
|
42
|
+
@xpath = xpath
|
43
|
+
@val= val
|
44
|
+
end
|
45
|
+
|
46
|
+
def matches?(response)
|
47
|
+
@response = response
|
48
|
+
doc = response.is_a?(REXML::Document) ? response : REXML::Document.new(@response)
|
49
|
+
ok= true
|
50
|
+
REXML::XPath.each(doc, @xpath) do |e|
|
51
|
+
@actual_val= case e
|
52
|
+
when REXML::Attribute
|
53
|
+
e.to_s
|
54
|
+
when REXML::Element
|
55
|
+
e.text
|
56
|
+
else
|
57
|
+
e.to_s
|
58
|
+
end
|
59
|
+
return false unless @val == @actual_val
|
60
|
+
end
|
61
|
+
return ok
|
62
|
+
end
|
63
|
+
|
64
|
+
def failure_message
|
65
|
+
"The xpath #{@xpath} did not have the value '#{@val}'
|
66
|
+
It was '#{@actual_val}'"
|
67
|
+
end
|
68
|
+
|
69
|
+
def description
|
70
|
+
"match the xpath expression #{@xpath} with #{@val}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def match_xpath(xpath, val)
|
75
|
+
MatchXpath.new(xpath, val)
|
76
|
+
end
|
77
|
+
|
78
|
+
# checks if the given xpath occurs num times
|
79
|
+
class HaveNodes #:nodoc:
|
80
|
+
def initialize(xpath, num)
|
81
|
+
@xpath= xpath
|
82
|
+
@num = num
|
83
|
+
end
|
84
|
+
|
85
|
+
def matches?(response)
|
86
|
+
@response = response
|
87
|
+
doc = response.is_a?(REXML::Document) ? response : REXML::Document.new(@response)
|
88
|
+
match = REXML::XPath.match(doc, @xpath)
|
89
|
+
@num_found= match.size
|
90
|
+
@num_found == @num
|
91
|
+
end
|
92
|
+
|
93
|
+
def failure_message
|
94
|
+
"Did not find expected number of nodes #{@num} in xpath #{@xpath}
|
95
|
+
Found #{@num_found}"
|
96
|
+
end
|
97
|
+
|
98
|
+
def description
|
99
|
+
"match the number of nodes #{@num}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def have_nodes(xpath, num)
|
104
|
+
HaveNodes.new(xpath, num)
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|