factory_girl-remote_api 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +168 -0
  3. data/Rakefile +58 -0
  4. data/app/assets/javascripts/factory_girl-remote_api/application.js +13 -0
  5. data/app/assets/stylesheets/factory_girl-remote_api/application.css +13 -0
  6. data/app/controllers/factory_girl/remote_api/application_controller.rb +6 -0
  7. data/app/controllers/factory_girl/remote_api/factories_controller.rb +24 -0
  8. data/app/helpers/factory_girl/remote_api/application_helper.rb +4 -0
  9. data/app/views/layouts/factory_girl/remote_api/application.html.erb +14 -0
  10. data/config/routes.rb +4 -0
  11. data/lib/factory_girl/remote_api/configuration.rb +21 -0
  12. data/lib/factory_girl/remote_api/engine.rb +14 -0
  13. data/lib/factory_girl/remote_api/remote_factory.rb +31 -0
  14. data/lib/factory_girl/remote_api/request.rb +40 -0
  15. data/lib/factory_girl/remote_api/version.rb +5 -0
  16. data/lib/factory_girl/remote_api.rb +35 -0
  17. data/spec/dummy_31/Rakefile +7 -0
  18. data/spec/dummy_31/app/assets/javascripts/application.js +9 -0
  19. data/spec/dummy_31/app/assets/stylesheets/application.css +7 -0
  20. data/spec/dummy_31/app/controllers/application_controller.rb +3 -0
  21. data/spec/dummy_31/app/helpers/application_helper.rb +2 -0
  22. data/spec/dummy_31/app/models/user.rb +3 -0
  23. data/spec/dummy_31/app/views/layouts/application.html.erb +14 -0
  24. data/spec/dummy_31/config/application.rb +45 -0
  25. data/spec/dummy_31/config/boot.rb +10 -0
  26. data/spec/dummy_31/config/database.yml +25 -0
  27. data/spec/dummy_31/config/environment.rb +5 -0
  28. data/spec/dummy_31/config/environments/development.rb +30 -0
  29. data/spec/dummy_31/config/environments/production.rb +60 -0
  30. data/spec/dummy_31/config/environments/test.rb +39 -0
  31. data/spec/dummy_31/config/initializers/backtrace_silencers.rb +7 -0
  32. data/spec/dummy_31/config/initializers/inflections.rb +10 -0
  33. data/spec/dummy_31/config/initializers/mime_types.rb +5 -0
  34. data/spec/dummy_31/config/initializers/secret_token.rb +7 -0
  35. data/spec/dummy_31/config/initializers/session_store.rb +8 -0
  36. data/spec/dummy_31/config/initializers/wrap_parameters.rb +14 -0
  37. data/spec/dummy_31/config/locales/en.yml +5 -0
  38. data/spec/dummy_31/config/routes.rb +3 -0
  39. data/spec/dummy_31/config.ru +4 -0
  40. data/spec/dummy_31/db/development.sqlite3 +0 -0
  41. data/spec/dummy_31/db/migrate/20130607202020_create_users.rb +10 -0
  42. data/spec/dummy_31/db/schema.rb +23 -0
  43. data/spec/dummy_31/db/test.sqlite3 +0 -0
  44. data/spec/dummy_31/log/test.log +130 -0
  45. data/spec/dummy_31/public/404.html +26 -0
  46. data/spec/dummy_31/public/422.html +26 -0
  47. data/spec/dummy_31/public/500.html +26 -0
  48. data/spec/dummy_31/public/favicon.ico +0 -0
  49. data/spec/dummy_31/script/rails +6 -0
  50. data/spec/dummy_31/spec/factories/users.rb +13 -0
  51. data/spec/dummy_32/README.rdoc +261 -0
  52. data/spec/dummy_32/Rakefile +7 -0
  53. data/spec/dummy_32/app/assets/javascripts/application.js +15 -0
  54. data/spec/dummy_32/app/assets/stylesheets/application.css +13 -0
  55. data/spec/dummy_32/app/controllers/application_controller.rb +3 -0
  56. data/spec/dummy_32/app/helpers/application_helper.rb +2 -0
  57. data/spec/dummy_32/app/models/user.rb +3 -0
  58. data/spec/dummy_32/app/views/layouts/application.html.erb +14 -0
  59. data/spec/dummy_32/config/application.rb +65 -0
  60. data/spec/dummy_32/config/boot.rb +10 -0
  61. data/spec/dummy_32/config/database.yml +25 -0
  62. data/spec/dummy_32/config/environment.rb +5 -0
  63. data/spec/dummy_32/config/environments/development.rb +37 -0
  64. data/spec/dummy_32/config/environments/production.rb +67 -0
  65. data/spec/dummy_32/config/environments/test.rb +37 -0
  66. data/spec/dummy_32/config/initializers/backtrace_silencers.rb +7 -0
  67. data/spec/dummy_32/config/initializers/inflections.rb +15 -0
  68. data/spec/dummy_32/config/initializers/mime_types.rb +5 -0
  69. data/spec/dummy_32/config/initializers/secret_token.rb +7 -0
  70. data/spec/dummy_32/config/initializers/session_store.rb +8 -0
  71. data/spec/dummy_32/config/initializers/wrap_parameters.rb +14 -0
  72. data/spec/dummy_32/config/locales/en.yml +5 -0
  73. data/spec/dummy_32/config/routes.rb +3 -0
  74. data/spec/dummy_32/config.ru +4 -0
  75. data/spec/dummy_32/db/development.sqlite3 +0 -0
  76. data/spec/dummy_32/db/migrate/20130607202020_create_users.rb +10 -0
  77. data/spec/dummy_32/db/schema.rb +23 -0
  78. data/spec/dummy_32/db/test.sqlite3 +0 -0
  79. data/spec/dummy_32/log/test.log +1520 -0
  80. data/spec/dummy_32/public/404.html +26 -0
  81. data/spec/dummy_32/public/422.html +26 -0
  82. data/spec/dummy_32/public/500.html +25 -0
  83. data/spec/dummy_32/public/favicon.ico +0 -0
  84. data/spec/dummy_32/script/rails +6 -0
  85. data/spec/dummy_32/spec/factories/users.rb +13 -0
  86. data/spec/dummy_40/README.rdoc +28 -0
  87. data/spec/dummy_40/Rakefile +6 -0
  88. data/spec/dummy_40/app/assets/javascripts/application.js +13 -0
  89. data/spec/dummy_40/app/assets/stylesheets/application.css +13 -0
  90. data/spec/dummy_40/app/controllers/application_controller.rb +5 -0
  91. data/spec/dummy_40/app/helpers/application_helper.rb +2 -0
  92. data/spec/dummy_40/app/models/user.rb +2 -0
  93. data/spec/dummy_40/app/views/layouts/application.html.erb +14 -0
  94. data/spec/dummy_40/bin/bundle +3 -0
  95. data/spec/dummy_40/bin/rails +4 -0
  96. data/spec/dummy_40/bin/rake +4 -0
  97. data/spec/dummy_40/config/application.rb +23 -0
  98. data/spec/dummy_40/config/boot.rb +5 -0
  99. data/spec/dummy_40/config/database.yml +25 -0
  100. data/spec/dummy_40/config/environment.rb +5 -0
  101. data/spec/dummy_40/config/environments/development.rb +29 -0
  102. data/spec/dummy_40/config/environments/production.rb +80 -0
  103. data/spec/dummy_40/config/environments/test.rb +36 -0
  104. data/spec/dummy_40/config/initializers/backtrace_silencers.rb +7 -0
  105. data/spec/dummy_40/config/initializers/filter_parameter_logging.rb +4 -0
  106. data/spec/dummy_40/config/initializers/inflections.rb +16 -0
  107. data/spec/dummy_40/config/initializers/mime_types.rb +5 -0
  108. data/spec/dummy_40/config/initializers/secret_token.rb +12 -0
  109. data/spec/dummy_40/config/initializers/session_store.rb +3 -0
  110. data/spec/dummy_40/config/initializers/wrap_parameters.rb +14 -0
  111. data/spec/dummy_40/config/locales/en.yml +23 -0
  112. data/spec/dummy_40/config/routes.rb +4 -0
  113. data/spec/dummy_40/config.ru +4 -0
  114. data/spec/dummy_40/db/migrate/20130607202020_create_users.rb +10 -0
  115. data/spec/dummy_40/db/schema.rb +23 -0
  116. data/spec/dummy_40/db/test.sqlite3 +0 -0
  117. data/spec/dummy_40/log/test.log +175 -0
  118. data/spec/dummy_40/public/404.html +58 -0
  119. data/spec/dummy_40/public/422.html +58 -0
  120. data/spec/dummy_40/public/500.html +57 -0
  121. data/spec/dummy_40/public/favicon.ico +0 -0
  122. data/spec/dummy_40/spec/factories/users.rb +13 -0
  123. data/spec/factory_girl/remote_api/configuration_spec.rb +24 -0
  124. data/spec/factory_girl/remote_api/request_spec.rb +34 -0
  125. data/spec/factory_girl/remote_api_spec.rb +21 -0
  126. data/spec/features/client_factory_requests_spec.rb +59 -0
  127. data/spec/features/server_factory_requests_spec.rb +50 -0
  128. data/spec/spec_helper.rb +37 -0
  129. data/spec/support/database_cleaner.rb +11 -0
  130. data/spec/support/require_dummy_factories.rb +2 -0
  131. data/spec/support/stub_with_real_response.rb +12 -0
  132. data.tar.gz.sig +0 -0
  133. metadata +485 -0
  134. metadata.gz.sig +0 -0
@@ -0,0 +1,175 @@
1
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
3
+  (1.1ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "first_name" varchar(255), "last_name" varchar(255), "created_at" datetime, "updated_at" datetime) 
4
+  (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
5
+  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
6
+  (0.1ms) SELECT version FROM "schema_migrations"
7
+  (1.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20130607202020')
8
+  (0.4ms) begin transaction
9
+  (0.1ms) commit transaction
10
+  (0.0ms) begin transaction
11
+  (0.1ms) rollback transaction
12
+  (0.1ms) begin transaction
13
+  (0.0ms) commit transaction
14
+  (0.0ms) begin transaction
15
+  (0.0ms) rollback transaction
16
+  (0.1ms) begin transaction
17
+  (0.0ms) commit transaction
18
+  (0.0ms) begin transaction
19
+  (0.0ms) rollback transaction
20
+  (0.1ms) begin transaction
21
+  (0.0ms) commit transaction
22
+  (0.0ms) begin transaction
23
+  (0.1ms) rollback transaction
24
+  (0.1ms) begin transaction
25
+  (0.0ms) commit transaction
26
+  (0.0ms) begin transaction
27
+  (0.1ms) rollback transaction
28
+  (0.1ms) begin transaction
29
+  (0.0ms) commit transaction
30
+  (0.0ms) begin transaction
31
+  (0.0ms) rollback transaction
32
+  (0.1ms) begin transaction
33
+  (0.0ms) commit transaction
34
+  (0.0ms) begin transaction
35
+  (0.1ms) SELECT COUNT(*) FROM "users"
36
+ Started GET "/factories/user" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
37
+ Processing by FactoryGirl::RemoteApi::FactoriesController#create as JSON
38
+ Parameters: {"factory"=>"user"}
39
+ SQL (4.9ms) INSERT INTO "users" ("created_at", "first_name", "last_name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Tue, 18 Jun 2013 18:23:12 UTC +00:00], ["first_name", "John"], ["last_name", "Doe"], ["updated_at", Tue, 18 Jun 2013 18:23:12 UTC +00:00]]
40
+ Completed 200 OK in 32ms (Views: 0.4ms | ActiveRecord: 4.9ms)
41
+  (0.1ms) SELECT COUNT(*) FROM "users"
42
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
43
+  (0.4ms) rollback transaction
44
+  (0.1ms) begin transaction
45
+  (0.0ms) commit transaction
46
+  (0.0ms) begin transaction
47
+  (0.1ms) SELECT COUNT(*) FROM "users"
48
+ Started GET "/factories/user?user[first_name]=James" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
49
+ Processing by FactoryGirl::RemoteApi::FactoriesController#create as JSON
50
+ Parameters: {"user"=>{"first_name"=>"James"}, "factory"=>"user"}
51
+ SQL (0.6ms) INSERT INTO "users" ("created_at", "first_name", "last_name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Tue, 18 Jun 2013 18:23:12 UTC +00:00], ["first_name", "James"], ["last_name", "Doe"], ["updated_at", Tue, 18 Jun 2013 18:23:12 UTC +00:00]]
52
+ Completed 200 OK in 3ms (Views: 0.3ms | ActiveRecord: 0.6ms)
53
+  (0.1ms) SELECT COUNT(*) FROM "users"
54
+  (0.4ms) rollback transaction
55
+  (0.1ms) begin transaction
56
+  (0.0ms) commit transaction
57
+  (0.0ms) begin transaction
58
+ Started GET "/factories/attributes_for/user" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
59
+ Processing by FactoryGirl::RemoteApi::FactoriesController#show as JSON
60
+ Parameters: {"factory_method"=>"attributes_for", "factory"=>"user"}
61
+ Completed 200 OK in 26ms (Views: 0.2ms | ActiveRecord: 0.0ms)
62
+  (0.2ms) SELECT COUNT(*) FROM "users"
63
+  (0.1ms) rollback transaction
64
+  (0.1ms) begin transaction
65
+  (0.0ms) commit transaction
66
+  (0.0ms) begin transaction
67
+ Started GET "/factories/build/user?user[first_name]=James" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
68
+ Processing by FactoryGirl::RemoteApi::FactoriesController#show as JSON
69
+ Parameters: {"user"=>{"first_name"=>"James"}, "factory_method"=>"build", "factory"=>"user"}
70
+ Completed 200 OK in 2ms (Views: 0.1ms | ActiveRecord: 0.0ms)
71
+  (0.1ms) SELECT COUNT(*) FROM "users"
72
+  (0.1ms) rollback transaction
73
+  (0.1ms) begin transaction
74
+  (0.0ms) commit transaction
75
+  (0.0ms) begin transaction
76
+ Started GET "/factories/build/user" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
77
+ Processing by FactoryGirl::RemoteApi::FactoriesController#show as JSON
78
+ Parameters: {"factory_method"=>"build", "factory"=>"user"}
79
+ Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms)
80
+  (0.1ms) SELECT COUNT(*) FROM "users"
81
+  (0.1ms) rollback transaction
82
+  (0.1ms) begin transaction
83
+  (0.0ms) commit transaction
84
+  (0.0ms) begin transaction
85
+  (0.1ms) SELECT COUNT(*) FROM "users"
86
+ Started GET "/factories/authenticated_user?authenticated_user[first_name]=James&authenticated_user[parent_factory]=user" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
87
+ Processing by FactoryGirl::RemoteApi::FactoriesController#create as JSON
88
+ Parameters: {"authenticated_user"=>{"first_name"=>"James", "parent_factory"=>"user"}, "factory"=>"authenticated_user"}
89
+ SQL (0.5ms) INSERT INTO "users" ("created_at", "first_name", "last_name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Tue, 18 Jun 2013 18:23:12 UTC +00:00], ["first_name", "James"], ["last_name", "Doe"], ["updated_at", Tue, 18 Jun 2013 18:23:12 UTC +00:00]]
90
+ Completed 200 OK in 3ms (Views: 0.3ms | ActiveRecord: 0.5ms)
91
+  (0.1ms) SELECT COUNT(*) FROM "users"
92
+  (0.4ms) rollback transaction
93
+  (0.1ms) begin transaction
94
+  (0.0ms) commit transaction
95
+  (0.0ms) begin transaction
96
+ Started GET "/factories/attributes_for/user?user[first_name]=James" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
97
+ Processing by FactoryGirl::RemoteApi::FactoriesController#show as JSON
98
+ Parameters: {"user"=>{"first_name"=>"James"}, "factory_method"=>"attributes_for", "factory"=>"user"}
99
+ Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms)
100
+  (0.1ms) SELECT COUNT(*) FROM "users"
101
+  (0.1ms) rollback transaction
102
+  (0.1ms) begin transaction
103
+  (0.0ms) commit transaction
104
+  (0.1ms) begin transaction
105
+ Started GET "/factories/user" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
106
+ Processing by FactoryGirl::RemoteApi::FactoriesController#create as JSON
107
+ Parameters: {"factory"=>"user"}
108
+ SQL (0.5ms) INSERT INTO "users" ("created_at", "first_name", "last_name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Tue, 18 Jun 2013 18:23:12 UTC +00:00], ["first_name", "John"], ["last_name", "Doe"], ["updated_at", Tue, 18 Jun 2013 18:23:12 UTC +00:00]]
109
+ Completed 200 OK in 3ms (Views: 0.3ms | ActiveRecord: 0.5ms)
110
+  (0.1ms) SELECT COUNT(*) FROM "users"
111
+  (0.4ms) rollback transaction
112
+  (0.1ms) begin transaction
113
+  (0.0ms) commit transaction
114
+  (0.0ms) begin transaction
115
+ Started GET "/factories/user?user[first_name]=James" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
116
+ Processing by FactoryGirl::RemoteApi::FactoriesController#create as JSON
117
+ Parameters: {"user"=>{"first_name"=>"James"}, "factory"=>"user"}
118
+ SQL (0.5ms) INSERT INTO "users" ("created_at", "first_name", "last_name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Tue, 18 Jun 2013 18:23:12 UTC +00:00], ["first_name", "James"], ["last_name", "Doe"], ["updated_at", Tue, 18 Jun 2013 18:23:12 UTC +00:00]]
119
+ Completed 200 OK in 3ms (Views: 0.3ms | ActiveRecord: 0.5ms)
120
+  (0.1ms) SELECT COUNT(*) FROM "users"
121
+  (0.4ms) rollback transaction
122
+  (0.1ms) begin transaction
123
+  (0.1ms) commit transaction
124
+  (0.1ms) begin transaction
125
+ Started GET "/factories/attributes_for/user" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
126
+ Processing by FactoryGirl::RemoteApi::FactoriesController#show as JSON
127
+ Parameters: {"factory_method"=>"attributes_for", "factory"=>"user"}
128
+ Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms)
129
+  (0.1ms) SELECT COUNT(*) FROM "users"
130
+  (0.1ms) rollback transaction
131
+  (0.1ms) begin transaction
132
+  (0.0ms) commit transaction
133
+  (0.1ms) begin transaction
134
+ Started GET "/factories/build/user?user[first_name]=James" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
135
+ Processing by FactoryGirl::RemoteApi::FactoriesController#show as JSON
136
+ Parameters: {"user"=>{"first_name"=>"James"}, "factory_method"=>"build", "factory"=>"user"}
137
+ Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms)
138
+  (0.1ms) SELECT COUNT(*) FROM "users"
139
+  (0.1ms) rollback transaction
140
+  (0.1ms) begin transaction
141
+  (0.0ms) commit transaction
142
+  (0.0ms) begin transaction
143
+ Started GET "/factories/build/user" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
144
+ Processing by FactoryGirl::RemoteApi::FactoriesController#show as JSON
145
+ Parameters: {"factory_method"=>"build", "factory"=>"user"}
146
+ Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms)
147
+  (0.1ms) SELECT COUNT(*) FROM "users"
148
+  (0.1ms) rollback transaction
149
+  (0.1ms) begin transaction
150
+  (0.0ms) commit transaction
151
+  (0.0ms) begin transaction
152
+ Started GET "/factories/authenticated_user?authenticated_user[first_name]=James&authenticated_user[parent_factory]=user" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
153
+ Processing by FactoryGirl::RemoteApi::FactoriesController#create as JSON
154
+ Parameters: {"authenticated_user"=>{"first_name"=>"James", "parent_factory"=>"user"}, "factory"=>"authenticated_user"}
155
+ SQL (0.5ms) INSERT INTO "users" ("created_at", "first_name", "last_name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Tue, 18 Jun 2013 18:23:12 UTC +00:00], ["first_name", "James"], ["last_name", "Doe"], ["updated_at", Tue, 18 Jun 2013 18:23:12 UTC +00:00]]
156
+ Completed 200 OK in 3ms (Views: 0.3ms | ActiveRecord: 0.5ms)
157
+  (0.1ms) SELECT COUNT(*) FROM "users"
158
+  (0.5ms) rollback transaction
159
+  (0.1ms) begin transaction
160
+  (0.0ms) commit transaction
161
+  (0.0ms) begin transaction
162
+ Started GET "/factories/attributes_for/user?user[first_name]=James" for 127.0.0.1 at 2013-06-18 11:23:12 -0700
163
+ Processing by FactoryGirl::RemoteApi::FactoriesController#show as JSON
164
+ Parameters: {"user"=>{"first_name"=>"James"}, "factory_method"=>"attributes_for", "factory"=>"user"}
165
+ Completed 200 OK in 2ms (Views: 0.2ms | ActiveRecord: 0.0ms)
166
+  (0.1ms) SELECT COUNT(*) FROM "users"
167
+  (0.1ms) rollback transaction
168
+  (0.1ms) begin transaction
169
+  (0.0ms) commit transaction
170
+  (0.0ms) begin transaction
171
+  (0.0ms) rollback transaction
172
+  (0.1ms) begin transaction
173
+  (0.0ms) commit transaction
174
+  (0.0ms) begin transaction
175
+  (0.0ms) rollback transaction
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,13 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :user do
5
+ first_name 'John'
6
+ last_name 'Doe'
7
+ end
8
+
9
+ factory :authenticated_user, parent: :user do
10
+ first_name 'Jane'
11
+ last_name 'Doe'
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe FactoryGirl::RemoteApi::Configuration do
4
+ after(:each) { FactoryGirl::RemoteApi.reset_configuration }
5
+
6
+ describe '#server_url=' do
7
+ it 'removes trailing slashes' do
8
+ FactoryGirl::RemoteApi.configure { |config| config.server_url = 'http://localhost:1234/' }
9
+ expect(FactoryGirl::RemoteApi.configuration.server_url).to eq('http://localhost:1234')
10
+ end
11
+ end
12
+
13
+ describe '#server_mount_path=' do
14
+ it 'adds leading slash if absent' do
15
+ FactoryGirl::RemoteApi.configure { |config| config.server_mount_path = 'models' }
16
+ expect(FactoryGirl::RemoteApi.configuration.server_mount_path).to eq('/models')
17
+ end
18
+
19
+ it 'removes trailing slash if present' do
20
+ FactoryGirl::RemoteApi.configure { |config| config.server_mount_path = '/models/' }
21
+ expect(FactoryGirl::RemoteApi.configuration.server_mount_path).to eq('/models')
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe FactoryGirl::RemoteApi::Request do
4
+ describe '#get_response_for' do
5
+ let(:config) { FactoryGirl::RemoteApi.configuration }
6
+
7
+ it 'returns the parsed json if no root is set' do
8
+ uri = URI("#{config.server_url}#{config.server_mount_path}/attributes_for/user?user%5Bfirst_name%5D=James")
9
+ Net::HTTP.should_receive(:get_response).with(uri).and_return(stub(:response, body: '{ "first_name": "James"}'))
10
+ response = FactoryGirl::RemoteApi::Request.new.get_response_for(:attributes_for, :user, first_name: "James")
11
+ expect(response).to eq("first_name" => "James")
12
+ end
13
+
14
+ it 'returns the model inside the root json element if present' do
15
+ uri = URI("#{config.server_url}#{config.server_mount_path}/attributes_for/user?user%5Bfirst_name%5D=James")
16
+ stub_response = stub(:response, body: '{ "user": {"first_name": "James"}}')
17
+ Net::HTTP.should_receive(:get_response).with(uri).and_return(stub_response)
18
+ response = FactoryGirl::RemoteApi::Request.new.get_response_for(:attributes_for, :user, first_name: "James")
19
+ expect(response).to eq("first_name" => "James")
20
+ end
21
+
22
+ it 'returns the model inside the root json element if the parent factory is set' do
23
+ url = "#{config.server_url}#{config.server_mount_path}/authenticated_user"
24
+ params = '?authenticated_user%5Bfirst_name%5D=James&authenticated_user%5Bparent_factory%5D=user'
25
+ uri = URI(url + params)
26
+ stub_response = stub(:response, body: '{ "user": {"first_name": "James"}}')
27
+ Net::HTTP.should_receive(:get_response).with(uri).and_return(stub_response)
28
+ response = FactoryGirl::RemoteApi::Request.new.get_response_for(:create,
29
+ :authenticated_user,
30
+ first_name: 'James', parent_factory: 'user')
31
+ expect(response).to eq("first_name" => "James")
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe FactoryGirl::RemoteApi do
4
+ describe '.configuration' do
5
+ it 'accepts a server_url option' do
6
+ expect {
7
+ FactoryGirl::RemoteApi.configure { |config| config.server_url = 'http://localhost:3001' }
8
+ }.to change {
9
+ FactoryGirl::RemoteApi.configuration.server_url
10
+ }.from('http://localhost:3000').to('http://localhost:3001')
11
+ end
12
+
13
+ it 'accepts a server_mount_path option' do
14
+ expect {
15
+ FactoryGirl::RemoteApi.configure { |config| config.server_mount_path = '/models' }
16
+ }.to change {
17
+ FactoryGirl::RemoteApi.configuration.server_mount_path
18
+ }.from('/factories').to('/models')
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'Client factory requests' do
4
+ let(:config) { FactoryGirl::RemoteApi.configuration }
5
+
6
+ scenario 'create a user model from a remote factory' do
7
+ stub_with_real_response('/user?')
8
+ user = FactoryGirl::RemoteApi.create(:user)
9
+ expect(User.count).to eq(1)
10
+ expect(user.id).to_not be_nil
11
+ end
12
+
13
+ scenario 'create a user model from a remote factory with specific attributes' do
14
+ stub_with_real_response('/user?user%5Bfirst_name%5D=James')
15
+ user = FactoryGirl::RemoteApi.create(:user, first_name: 'James')
16
+ expect(User.count).to eq(1)
17
+ expect(user.id).to_not be_nil
18
+ expect(user.first_name).to eq('James')
19
+ end
20
+
21
+ scenario 'create user model with specific attributes from a child factory' do
22
+ stub_with_real_response('/authenticated_user?authenticated_user%5Bfirst_name%5D=James&authenticated_user%5Bparent_factory%5D=user')
23
+ user = FactoryGirl::RemoteApi.create(:authenticated_user, first_name: 'James', parent_factory: 'user')
24
+ expect(User.count).to eq(1)
25
+ expect(user.id).to_not be_nil
26
+ expect(user.first_name).to eq('James')
27
+ end
28
+
29
+ scenario 'build a user model from a remote factory' do
30
+ stub_with_real_response('/build/user?')
31
+ user = FactoryGirl::RemoteApi.build(:user)
32
+ expect(User.count).to eq(0)
33
+ expect(user.id).to be_nil
34
+ end
35
+
36
+ scenario 'build a user model from a remote factory with specific attributes' do
37
+ stub_with_real_response('/build/user?user%5Bfirst_name%5D=James')
38
+ user = FactoryGirl::RemoteApi.build(:user, first_name: 'James')
39
+ expect(User.count).to eq(0)
40
+ expect(user.id).to be_nil
41
+ expect(user.first_name).to eq('James')
42
+ end
43
+
44
+ scenario 'attributes for a user model from a remote factory' do
45
+ stub_with_real_response('/attributes_for/user?')
46
+ user_attributes = FactoryGirl::RemoteApi.attributes_for(:user)
47
+ expect(User.count).to eq(0)
48
+ expect(user_attributes[:id]).to be_nil
49
+ end
50
+
51
+ scenario 'attributes for a user model from a remote factory with specific attributes' do
52
+ stub_with_real_response('/attributes_for/user?user%5Bfirst_name%5D=James')
53
+ user_attributes = FactoryGirl::RemoteApi.attributes_for(:user, first_name: 'James')
54
+ expect(User.count).to eq(0)
55
+ expect(user_attributes[:id]).to be_nil
56
+ expect(user_attributes['first_name']).to eq('James')
57
+ expect(user_attributes[:first_name]).to eq('James')
58
+ end
59
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'Server factory requests' do
4
+ scenario 'create a user model' do
5
+ expect {
6
+ visit '/factories/user'
7
+ }.to change { User.count }.from(0).to(1)
8
+ expect(page.body).to eq(User.first.to_json)
9
+ end
10
+
11
+ scenario 'create a user model with specific attributes' do
12
+ expect {
13
+ visit '/factories/user?user[first_name]=James'
14
+ }.to change { User.count }.from(0).to(1)
15
+ expect(JSON.parse(page.body)['first_name']).to eq('James')
16
+ end
17
+
18
+ scenario 'create user model with specific attributes from a child factory' do
19
+ expect {
20
+ visit '/factories/authenticated_user?authenticated_user[first_name]=James&authenticated_user[parent_factory]=user'
21
+ }.to change { User.count }.from(0).to(1)
22
+ expect(JSON.parse(page.body)['first_name']).to eq('James')
23
+ end
24
+
25
+ scenario 'build a user model' do
26
+ visit '/factories/build/user'
27
+ expect(JSON.parse(page.body)['id']).to be_nil
28
+ expect(User.count).to eq(0)
29
+ end
30
+
31
+ scenario 'build a user model with specific attributes' do
32
+ visit '/factories/build/user?user[first_name]=James'
33
+ expect(JSON.parse(page.body)['id']).to be_nil
34
+ expect(JSON.parse(page.body)['first_name']).to eq('James')
35
+ expect(User.count).to eq(0)
36
+ end
37
+
38
+ scenario 'get attributes for a user' do
39
+ visit '/factories/attributes_for/user'
40
+ expect(JSON.parse(page.body)['id']).to be_nil
41
+ expect(User.count).to eq(0)
42
+ end
43
+
44
+ scenario 'get attributes for a user with specific attributes' do
45
+ visit '/factories/attributes_for/user?user[first_name]=James'
46
+ expect(JSON.parse(page.body)['id']).to be_nil
47
+ expect(JSON.parse(page.body)['first_name']).to eq('James')
48
+ expect(User.count).to eq(0)
49
+ end
50
+ end
@@ -0,0 +1,37 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
4
+ SimpleCov.start
5
+
6
+ ENV['RAILS_ENV'] ||= 'test'
7
+ RAILS_MINOR_VERSION = if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
8
+ ENV['BUNDLE_GEMFILE'].split('/').last.scan(/(\d).(\d)/).join
9
+ else
10
+ '32'
11
+ end
12
+
13
+ require File.expand_path("../dummy_#{RAILS_MINOR_VERSION}/config/environment", __FILE__)
14
+ require 'rspec/rails'
15
+ require 'rspec/autorun'
16
+
17
+ # Requires supporting ruby files with custom matchers and macros, etc,
18
+ # in spec/support/ and its subdirectories.
19
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each {|f| require f }
20
+
21
+ RSpec.configure do |config|
22
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
23
+ # examples within a transaction, remove the following line or assign false
24
+ # instead of true.
25
+ config.use_transactional_fixtures = false # Database Cleaner
26
+
27
+ # If true, the base class of anonymous controllers will be inferred
28
+ # automatically. This will be the default behavior in future versions of
29
+ # rspec-rails.
30
+ config.infer_base_class_for_anonymous_controllers = false
31
+
32
+ # Run specs in random order to surface order dependencies. If you find an
33
+ # order dependency and want to debug it, you can fix the order by providing
34
+ # the seed, which is printed after each run.
35
+ # --seed 1234
36
+ config.order = 'random'
37
+ end
@@ -0,0 +1,11 @@
1
+ require 'database_cleaner'
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:each) do
5
+ DatabaseCleaner.start
6
+ end
7
+
8
+ config.after(:each) do
9
+ DatabaseCleaner.clean
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ # Add dummy/spec/factories to definition_file_paths
2
+ FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), "../dummy_#{RAILS_MINOR_VERSION}/spec/factories")
@@ -0,0 +1,12 @@
1
+ module StubWithRealResponse
2
+ def stub_with_real_response(path)
3
+ FactoryGirl::RemoteApi.reset_configuration
4
+ visit [config.server_mount_path, path].join
5
+ uri = URI([config.server_url, config.server_mount_path, path].join)
6
+ Net::HTTP.should_receive(:get_response).with(uri).and_return(stub(:response, body: page.body))
7
+ end
8
+ end
9
+
10
+ RSpec.configure do |config|
11
+ config.include StubWithRealResponse
12
+ end
data.tar.gz.sig ADDED
Binary file