spontaneous 0.2.0.beta1 → 0.2.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (335) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.locat +42 -0
  4. data/.travis/gemfiles/Gemfile.empty +7 -0
  5. data/.travis.yml +18 -0
  6. data/Gemfile +12 -8
  7. data/LICENSE +1 -1
  8. data/Rakefile +15 -157
  9. data/Readme.markdown +1 -1
  10. data/application/css/core.css.scss +22 -146
  11. data/application/css/definitions.css.scss +7 -3
  12. data/application/css/dialogue.css.scss +26 -1
  13. data/application/css/editing.css.scss +70 -28
  14. data/application/css/font.css.scss +1 -1
  15. data/application/css/popover.css.scss +2 -0
  16. data/application/css/top.css.scss +231 -0
  17. data/application/js/add_alias_dialogue.js +1 -1
  18. data/application/js/add_home_dialogue.js +1 -1
  19. data/application/js/ajax.js +61 -31
  20. data/application/js/box.js +4 -4
  21. data/application/js/conflicted_field_dialogue.js +1 -1
  22. data/application/js/content.js +5 -5
  23. data/application/js/dom.js +5 -0
  24. data/application/js/edit_panel.js +1 -0
  25. data/application/js/editing.js +1 -1
  26. data/application/js/extensions.js +8 -0
  27. data/application/js/field/boolean.js +31 -0
  28. data/application/js/field/file.js +32 -4
  29. data/application/js/field/image.js +24 -9
  30. data/application/js/field/markdown.js +87 -59
  31. data/application/js/field/select.js +1 -1
  32. data/application/js/field/webvideo.js +6 -1
  33. data/application/js/init.js +2 -2
  34. data/application/js/jquery-selection-position.js +130 -0
  35. data/application/js/location.js +4 -25
  36. data/application/js/meta_view/user_admin.js +2 -2
  37. data/application/js/metadata.js +2 -2
  38. data/application/js/page_browser.js +1 -1
  39. data/application/js/panel/root_menu.js +0 -1
  40. data/application/js/popover.js +27 -12
  41. data/application/js/popover_view.js +20 -4
  42. data/application/js/preview.js +31 -16
  43. data/application/js/progress.js +22 -21
  44. data/application/js/publish.js +18 -7
  45. data/application/js/sharded_upload.js +9 -6
  46. data/application/js/spontaneous.js +3 -1
  47. data/application/js/top_bar.js +264 -173
  48. data/application/js/upload.js +12 -5
  49. data/application/js/upload_manager.js +4 -3
  50. data/application/js/user.js +1 -2
  51. data/application/js/views/box_view.js +1 -1
  52. data/application/js/views/page_view.js +16 -5
  53. data/application/js/views/piece_view.js +5 -4
  54. data/application/static/font/fontawesome-webfont-1c66a4738b40ef0f6b1abca0ba9a796d.ttf +0 -0
  55. data/application/views/index.erb +6 -14
  56. data/application/views/login.erb +6 -25
  57. data/application/views/schema_modification_error.html.erb +3 -7
  58. data/db/migrations/20130114120000_create_revision_tables.rb +2 -2
  59. data/db/migrations/20130813111009_increase_path_length.rb +14 -0
  60. data/gem-public_cert.pem +20 -0
  61. data/lib/spontaneous/asset/app_compiler.rb +44 -0
  62. data/lib/spontaneous/asset/environment.rb +225 -0
  63. data/lib/spontaneous/asset.rb +2 -67
  64. data/lib/spontaneous/box.rb +0 -1
  65. data/lib/spontaneous/capistrano/deploy.rb +2 -2
  66. data/lib/spontaneous/capistrano/sync.rb +1 -1
  67. data/lib/spontaneous/cli/init.rb +36 -13
  68. data/lib/spontaneous/cli/server.rb +0 -1
  69. data/lib/spontaneous/cli/site.rb +2 -1
  70. data/lib/spontaneous/cli.rb +3 -1
  71. data/lib/spontaneous/collections/entry_set.rb +4 -12
  72. data/lib/spontaneous/collections/hash_with_fallback.rb +20 -0
  73. data/lib/spontaneous/collections/prototype_set.rb +6 -5
  74. data/lib/spontaneous/crypt.rb +2 -2
  75. data/lib/spontaneous/data_mapper/content_model/associations.rb +115 -63
  76. data/lib/spontaneous/data_mapper.rb +1 -1
  77. data/lib/spontaneous/errors.rb +6 -0
  78. data/lib/spontaneous/extensions/object_space.rb +6 -0
  79. data/lib/spontaneous/facet.rb +1 -0
  80. data/lib/spontaneous/field/base.rb +86 -13
  81. data/lib/spontaneous/field/boolean.rb +65 -0
  82. data/lib/spontaneous/field/file.rb +17 -6
  83. data/lib/spontaneous/field/html.rb +13 -0
  84. data/lib/spontaneous/field/image/size.rb +76 -0
  85. data/lib/spontaneous/field/image.rb +99 -414
  86. data/lib/spontaneous/field/tags.rb +36 -0
  87. data/lib/spontaneous/field/update.rb +1 -1
  88. data/lib/spontaneous/field/webvideo/fallback.rb +41 -0
  89. data/lib/spontaneous/field/webvideo/vimeo.rb +113 -0
  90. data/lib/spontaneous/field/webvideo/vine.rb +94 -0
  91. data/lib/spontaneous/field/webvideo/youtube.rb +133 -0
  92. data/lib/spontaneous/field/webvideo.rb +100 -250
  93. data/lib/spontaneous/field.rb +1 -1
  94. data/lib/spontaneous/generators/site/Gemfile.tt +5 -14
  95. data/lib/spontaneous/generators/site/assets/README.md +20 -0
  96. data/lib/spontaneous/generators/site/assets/css/site.scss +8 -0
  97. data/lib/spontaneous/generators/site/assets/js/site.js +6 -0
  98. data/lib/spontaneous/generators/site/config/deploy.rb.tt +9 -0
  99. data/lib/spontaneous/generators/site/config/user_levels.yml +14 -3
  100. data/lib/spontaneous/generators/site/public/README.md +12 -0
  101. data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +2 -2
  102. data/lib/spontaneous/generators/site.rb +77 -35
  103. data/lib/spontaneous/layout.rb +6 -7
  104. data/lib/spontaneous/loader.rb +21 -13
  105. data/lib/spontaneous/media/file.rb +22 -9
  106. data/lib/spontaneous/media/image/attributes.rb +33 -0
  107. data/lib/spontaneous/media/image/format/gif.rb +4 -0
  108. data/lib/spontaneous/media/image/format/jpg.rb +17 -0
  109. data/lib/spontaneous/media/image/format/png.rb +4 -0
  110. data/lib/spontaneous/media/image/format/webp.rb +26 -0
  111. data/lib/spontaneous/media/image/format.rb +79 -0
  112. data/lib/spontaneous/media/image/optimizer.rb +69 -0
  113. data/lib/spontaneous/media/image/processor.rb +17 -0
  114. data/lib/spontaneous/media/image/renderable.rb +52 -0
  115. data/lib/spontaneous/media/image/skeptick.rb +70 -0
  116. data/lib/spontaneous/media/image.rb +50 -0
  117. data/lib/spontaneous/media/temp_file.rb +4 -0
  118. data/lib/spontaneous/media.rb +1 -0
  119. data/lib/spontaneous/model/core/aliases.rb +14 -8
  120. data/lib/spontaneous/model/core/boxes.rb +5 -2
  121. data/lib/spontaneous/model/core/entries.rb +4 -0
  122. data/lib/spontaneous/model/core/entry.rb +1 -0
  123. data/lib/spontaneous/model/core/fields.rb +5 -2
  124. data/lib/spontaneous/model/core/locks.rb +16 -0
  125. data/lib/spontaneous/model/core/media.rb +1 -15
  126. data/lib/spontaneous/model/core.rb +31 -1
  127. data/lib/spontaneous/model/page/controllers.rb +2 -2
  128. data/lib/spontaneous/model/page/formats.rb +1 -4
  129. data/lib/spontaneous/model/page/layouts.rb +6 -2
  130. data/lib/spontaneous/model/page/locks.rb +8 -2
  131. data/lib/spontaneous/model/page/page_tree.rb +2 -2
  132. data/lib/spontaneous/model/page/paths.rb +74 -9
  133. data/lib/spontaneous/model/page.rb +11 -3
  134. data/lib/spontaneous/model.rb +6 -6
  135. data/lib/spontaneous/output/context/render_cache.rb +23 -0
  136. data/lib/spontaneous/output/context.rb +56 -30
  137. data/lib/spontaneous/output/helpers/script_helper.rb +9 -53
  138. data/lib/spontaneous/output/helpers/stylesheet_helper.rb +8 -40
  139. data/lib/spontaneous/output/template/renderer.rb +17 -5
  140. data/lib/spontaneous/output.rb +0 -1
  141. data/lib/spontaneous/paths.rb +6 -2
  142. data/lib/spontaneous/permissions/access_key.rb +18 -0
  143. data/lib/spontaneous/permissions/user.rb +1 -1
  144. data/lib/spontaneous/permissions.rb +4 -1
  145. data/lib/spontaneous/plugins/application/state.rb +19 -12
  146. data/lib/spontaneous/prototypes/field_prototype.rb +14 -8
  147. data/lib/spontaneous/published_revision.rb +7 -0
  148. data/lib/spontaneous/publishing/immediate.rb +43 -34
  149. data/lib/spontaneous/publishing/revision.rb +9 -6
  150. data/lib/spontaneous/rack/asset_server.rb +20 -0
  151. data/lib/spontaneous/rack/back/alias.rb +46 -0
  152. data/lib/spontaneous/rack/back/application_assets.rb +28 -0
  153. data/lib/spontaneous/rack/back/base.rb +34 -0
  154. data/lib/spontaneous/rack/back/changes.rb +19 -0
  155. data/lib/spontaneous/rack/back/content.rb +54 -0
  156. data/lib/spontaneous/rack/back/events.rb +38 -0
  157. data/lib/spontaneous/rack/back/field.rb +37 -0
  158. data/lib/spontaneous/rack/back/file.rb +118 -0
  159. data/lib/spontaneous/rack/back/helpers.rb +71 -0
  160. data/lib/spontaneous/rack/back/index.rb +16 -0
  161. data/lib/spontaneous/rack/back/login.rb +47 -0
  162. data/lib/spontaneous/rack/back/map.rb +24 -0
  163. data/lib/spontaneous/rack/back/page.rb +46 -0
  164. data/lib/spontaneous/rack/back/preview.rb +43 -0
  165. data/lib/spontaneous/rack/back/schema.rb +30 -0
  166. data/lib/spontaneous/rack/back/site.rb +25 -0
  167. data/lib/spontaneous/rack/back/site_assets.rb +13 -0
  168. data/lib/spontaneous/rack/back/unsupported_browser.rb +7 -0
  169. data/lib/spontaneous/rack/{user_admin.rb → back/user_admin.rb} +2 -5
  170. data/lib/spontaneous/rack/back.rb +85 -764
  171. data/lib/spontaneous/rack/cacheable_file.rb +3 -3
  172. data/lib/spontaneous/rack/front.rb +16 -9
  173. data/lib/spontaneous/rack/middleware/authenticate.rb +65 -0
  174. data/lib/spontaneous/rack/middleware/csrf.rb +66 -0
  175. data/lib/spontaneous/rack/middleware/reloader.rb +52 -0
  176. data/lib/spontaneous/rack/middleware/scope.rb +60 -0
  177. data/lib/spontaneous/rack/middleware.rb +6 -0
  178. data/lib/spontaneous/rack/page_controller.rb +18 -5
  179. data/lib/spontaneous/rack/public.rb +17 -11
  180. data/lib/spontaneous/rack.rb +34 -24
  181. data/lib/spontaneous/revision.rb +29 -2
  182. data/lib/spontaneous/schema/uid.rb +4 -3
  183. data/lib/spontaneous/schema/uid_map.rb +5 -24
  184. data/lib/spontaneous/schema.rb +1 -0
  185. data/lib/spontaneous/search/database.rb +8 -0
  186. data/lib/spontaneous/search/field.rb +1 -1
  187. data/lib/spontaneous/search/index.rb +3 -5
  188. data/lib/spontaneous/server.rb +1 -1
  189. data/lib/spontaneous/simultaneous.rb +1 -1
  190. data/lib/spontaneous/site/features.rb +4 -5
  191. data/lib/spontaneous/site/helpers.rb +22 -5
  192. data/lib/spontaneous/site/instance.rb +2 -2
  193. data/lib/spontaneous/site/selectors.rb +22 -3
  194. data/lib/spontaneous/storage/cloud.rb +13 -9
  195. data/lib/spontaneous/storage/local.rb +11 -6
  196. data/lib/spontaneous/style.rb +40 -23
  197. data/lib/spontaneous/utils/database/mysql_dumper.rb +1 -1
  198. data/lib/spontaneous/utils/smush_it.rb +1 -1
  199. data/lib/spontaneous/version.rb +1 -1
  200. data/lib/spontaneous.rb +35 -33
  201. data/spontaneous.gemspec +53 -787
  202. data/test/experimental/test_crypt.rb +56 -56
  203. data/test/experimental/test_features.rb +16 -27
  204. data/test/fixtures/assets/public1/css/data.css.scss +3 -0
  205. data/test/fixtures/assets/public1/css/image1.css.scss +4 -0
  206. data/test/fixtures/assets/public1/css/import.css.scss +1 -0
  207. data/test/fixtures/assets/public1/css/urlhash.css.scss +3 -0
  208. data/test/fixtures/assets/public1/js/a.js +1 -1
  209. data/test/fixtures/assets/public1/js/all.js +4 -0
  210. data/test/fixtures/assets/public1/js/{m.coffee → m.js.coffee} +1 -0
  211. data/test/fixtures/assets/public1/x.js +1 -0
  212. data/test/fixtures/assets/public2/css/all.css +4 -0
  213. data/test/fixtures/assets/public2/css/missing.css.scss +3 -0
  214. data/test/fixtures/assets/public2/i/y.png +0 -0
  215. data/test/fixtures/assets/public2/js/b.js +1 -1
  216. data/test/fixtures/assets/public2/js/c.js +1 -1
  217. data/test/fixtures/images/size.extended.webp +0 -0
  218. data/test/fixtures/images/size.lossless.webp +0 -0
  219. data/test/fixtures/images/size.lossy.webp +0 -0
  220. data/test/fixtures/schema/before.yml +4 -4
  221. data/test/fixtures/schema/schema.yml +1 -1
  222. data/test/fixtures/templates/aliases/aaa.html.cut +0 -0
  223. data/test/fixtures/templates/extended/partial_with_renderer.html.cut +1 -0
  224. data/test/fixtures/templates/extended/with_includes_and_renderer.html.cut +2 -0
  225. data/test/functional/test_application.rb +108 -106
  226. data/test/functional/test_back.rb +924 -930
  227. data/test/functional/test_front.rb +285 -238
  228. data/test/functional/test_user_manager.rb +75 -100
  229. data/test/integration/test_installation.rb +1 -1
  230. data/test/support/matchers.rb +12 -0
  231. data/test/support/minitest.rb +121 -0
  232. data/test/support/rack.rb +45 -0
  233. data/test/support/test_start_finish.rb +103 -0
  234. data/test/test_helper.rb +21 -68
  235. data/test/test_integration_helper.rb +1 -3
  236. data/test/unit/test_alias.rb +432 -408
  237. data/test/unit/test_asset_bundler.rb +58 -58
  238. data/test/unit/test_assets.rb +485 -155
  239. data/test/unit/test_async.rb +16 -37
  240. data/test/unit/test_authentication.rb +425 -457
  241. data/test/unit/test_boxes.rb +191 -191
  242. data/test/unit/test_changesets.rb +244 -254
  243. data/test/unit/test_config.rb +128 -142
  244. data/test/unit/test_content.rb +313 -359
  245. data/test/unit/test_content_inheritance.rb +29 -30
  246. data/test/unit/test_datamapper.rb +1205 -1080
  247. data/test/unit/test_datamapper_content.rb +49 -51
  248. data/test/unit/test_extensions.rb +23 -23
  249. data/test/unit/test_fields.rb +1488 -1180
  250. data/test/unit/test_formats.rb +158 -158
  251. data/test/unit/test_generators.rb +98 -40
  252. data/test/unit/test_helpers.rb +73 -76
  253. data/test/unit/test_image_size.rb +53 -22
  254. data/test/unit/test_images.rb +164 -165
  255. data/test/unit/test_layouts.rb +133 -122
  256. data/test/unit/test_logger.rb +14 -17
  257. data/test/unit/test_media.rb +69 -84
  258. data/test/unit/test_modifications.rb +513 -525
  259. data/test/unit/test_page.rb +462 -361
  260. data/test/unit/test_permissions.rb +379 -364
  261. data/test/unit/test_piece.rb +67 -75
  262. data/test/unit/test_plugins.rb +82 -89
  263. data/test/unit/test_prototype_set.rb +215 -216
  264. data/test/unit/test_prototypes.rb +114 -124
  265. data/test/unit/test_publishing.rb +252 -289
  266. data/test/unit/test_render.rb +167 -115
  267. data/test/unit/test_revisions.rb +436 -444
  268. data/test/unit/test_schema.rb +339 -309
  269. data/test/unit/test_search.rb +577 -574
  270. data/test/unit/test_serialisation.rb +136 -147
  271. data/test/unit/test_site.rb +252 -227
  272. data/test/unit/test_skeptick.rb +130 -0
  273. data/test/unit/test_storage.rb +46 -40
  274. data/test/unit/test_structure.rb +57 -66
  275. data/test/unit/test_styles.rb +104 -104
  276. data/test/unit/test_templates.rb +72 -57
  277. data/test/unit/test_type_hierarchy.rb +15 -16
  278. data/test/unit/test_visibility.rb +239 -257
  279. metadata +455 -326
  280. data/application/js/vendor/JS.Class-2.1.5/CHANGELOG +0 -283
  281. data/application/js/vendor/JS.Class-2.1.5/MIT-LICENSE +0 -30
  282. data/application/js/vendor/JS.Class-2.1.5/README +0 -30
  283. data/application/js/vendor/JS.Class-2.1.5/min/command.js +0 -1
  284. data/application/js/vendor/JS.Class-2.1.5/min/comparable.js +0 -1
  285. data/application/js/vendor/JS.Class-2.1.5/min/constant_scope.js +0 -1
  286. data/application/js/vendor/JS.Class-2.1.5/min/decorator.js +0 -1
  287. data/application/js/vendor/JS.Class-2.1.5/min/enumerable.js +0 -1
  288. data/application/js/vendor/JS.Class-2.1.5/min/forwardable.js +0 -1
  289. data/application/js/vendor/JS.Class-2.1.5/min/hash.js +0 -1
  290. data/application/js/vendor/JS.Class-2.1.5/min/linked_list.js +0 -1
  291. data/application/js/vendor/JS.Class-2.1.5/min/loader.js +0 -1
  292. data/application/js/vendor/JS.Class-2.1.5/min/method_chain.js +0 -1
  293. data/application/js/vendor/JS.Class-2.1.5/min/observable.js +0 -1
  294. data/application/js/vendor/JS.Class-2.1.5/min/package.js +0 -1
  295. data/application/js/vendor/JS.Class-2.1.5/min/proxy.js +0 -1
  296. data/application/js/vendor/JS.Class-2.1.5/min/ruby.js +0 -1
  297. data/application/js/vendor/JS.Class-2.1.5/min/set.js +0 -1
  298. data/application/js/vendor/JS.Class-2.1.5/min/stack_trace.js +0 -1
  299. data/application/js/vendor/JS.Class-2.1.5/min/state.js +0 -1
  300. data/application/js/vendor/JS.Class-2.1.5/min/stdlib.js +0 -16
  301. data/application/js/vendor/jquery-1.6.2.min.js +0 -18
  302. data/application/js/vendor/jquery-ui-1.8.16.custom.min.js +0 -791
  303. data/application/js/vendor/jquery-ui-1.8.9.custom.min.js +0 -415
  304. data/application/static/font/fontawesome-webfont-5c5c21100a346972a82c34c5e96ffcfe.ttf +0 -0
  305. data/application/static/select-arrow-6e7dd3745b00e934b0d7a3250c46558b.png +0 -0
  306. data/bin/limit-upload +0 -5
  307. data/bin/unlimit-upload +0 -3
  308. data/lib/spontaneous/asset/file.rb +0 -25
  309. data/lib/spontaneous/asset/source.rb +0 -28
  310. data/lib/spontaneous/image_size.rb +0 -123
  311. data/lib/spontaneous/output/assets/compression.rb +0 -58
  312. data/lib/spontaneous/output/assets.rb +0 -32
  313. data/lib/spontaneous/rack/around_back.rb +0 -20
  314. data/lib/spontaneous/rack/around_front.rb +0 -27
  315. data/lib/spontaneous/rack/around_preview.rb +0 -22
  316. data/lib/spontaneous/rack/assets.rb +0 -126
  317. data/lib/spontaneous/rack/authentication.rb +0 -20
  318. data/lib/spontaneous/rack/cookie_authentication.rb +0 -38
  319. data/lib/spontaneous/rack/helpers.rb +0 -52
  320. data/lib/spontaneous/rack/http.rb +0 -18
  321. data/lib/spontaneous/rack/media.rb +0 -30
  322. data/lib/spontaneous/rack/query_authentication.rb +0 -35
  323. data/lib/spontaneous/rack/reloader.rb +0 -45
  324. data/lib/spontaneous/rack/user_helpers.rb +0 -28
  325. /data/{README → application/js/field/markdown/text_command.js} +0 -0
  326. /data/application/js/vendor/{JS.Class-2.1.5/min/core.js → js.class-2.1.5.min.js} +0 -0
  327. /data/test/fixtures/assets/public1/css/{a.scss → a.css.scss} +0 -0
  328. /data/{lib/spontaneous/generators/site/public/css/site.scss → test/fixtures/assets/public1/x.css} +0 -0
  329. /data/{lib/spontaneous/generators/site/public/js/.empty_directory → test/fixtures/assets/public1/x.png} +0 -0
  330. /data/test/fixtures/assets/public2/css/{b.scss → b.css.scss} +0 -0
  331. /data/test/fixtures/assets/public2/js/{n.coffee → n.js.coffee} +0 -0
  332. /data/test/fixtures/back/{public → assets}/css/sass_include.scss +0 -0
  333. /data/test/fixtures/back/{public → assets}/css/sass_template.scss +0 -0
  334. /data/test/fixtures/back/{public → assets}/js/coffeescript.coffee +0 -0
  335. /data/{lib/spontaneous/generators/site/public/js/site.js → test/fixtures/templates/aliases/aa_alias.html.cut} +0 -0
@@ -3,20 +3,21 @@
3
3
  require File.expand_path('../../test_helper', __FILE__)
4
4
 
5
5
 
6
- class SchemaTest < MiniTest::Spec
7
- def setup
6
+ describe "Schema" do
7
+ before do
8
8
  @site = setup_site
9
9
  @site.schema_loader_class = Spontaneous::Schema::PersistentMap
10
+ @user_levels_file = File.expand_path('../../fixtures/permissions', __FILE__) / 'config/user_levels.yml'
10
11
  S::Permissions::UserLevel.reset!
11
- S::Permissions::UserLevel.stubs(:level_file).returns(File.expand_path('../../fixtures/permissions', __FILE__) / 'config/user_levels.yml')
12
+ S::Permissions::UserLevel.stubs(:level_file).returns(@user_levels_file)
12
13
  end
13
14
 
14
- def teardown
15
+ after do
15
16
  teardown_site
16
17
  end
17
18
 
18
- context "Configurable names" do
19
- setup do
19
+ describe "Configurable names" do
20
+ before do
20
21
  class ::FunkyContent < Piece; end
21
22
  class ::MoreFunkyContent < FunkyContent; end
22
23
  class ::ABCDifficultName < Piece; end
@@ -26,40 +27,40 @@ class SchemaTest < MiniTest::Spec
26
27
  end
27
28
  end
28
29
 
29
- teardown do
30
+ after do
30
31
  [:FunkyContent, :MoreFunkyContent, :ABCDifficultName, :CustomName].each do |klass|
31
32
  Object.send(:remove_const, klass)
32
33
  end
33
34
  end
34
35
 
35
- should "default to generated version" do
36
- FunkyContent.default_title.should == "Funky Content"
37
- FunkyContent.title.should == "Funky Content"
38
- MoreFunkyContent.title.should == "More Funky Content"
39
- ABCDifficultName.default_title.should == "ABC Difficult Name"
40
- ABCDifficultName.title.should == "ABC Difficult Name"
36
+ it "default to generated version" do
37
+ FunkyContent.default_title.must_equal "Funky Content"
38
+ FunkyContent.title.must_equal "Funky Content"
39
+ MoreFunkyContent.title.must_equal "More Funky Content"
40
+ ABCDifficultName.default_title.must_equal "ABC Difficult Name"
41
+ ABCDifficultName.title.must_equal "ABC Difficult Name"
41
42
  end
42
43
 
43
- should "be settable" do
44
- CustomName.title.should == "Some Name"
44
+ it "be settable" do
45
+ CustomName.title.must_equal "Some Name"
45
46
  FunkyContent.title "Content Class"
46
- FunkyContent.title.should == "Content Class"
47
+ FunkyContent.title.must_equal "Content Class"
47
48
  end
48
49
 
49
- should "be settable using =" do
50
+ it "be settable using =" do
50
51
  FunkyContent.title = "Content Class"
51
- FunkyContent.title.should == "Content Class"
52
+ FunkyContent.title.must_equal "Content Class"
52
53
  end
53
54
 
54
- should "not inherit from superclass" do
55
+ it "not inherit from superclass" do
55
56
  FunkyContent.title = "Custom Name"
56
- MoreFunkyContent.title.should == "More Funky Content"
57
+ MoreFunkyContent.title.must_equal "More Funky Content"
57
58
  end
58
59
  end
59
60
 
60
- context "Persistent maps" do
61
- context "Schema UIDs" do
62
- setup do
61
+ describe "Persistent maps" do
62
+ describe "Schema UIDs" do
63
+ before do
63
64
  @site.schema.schema_map_file = File.expand_path('../../fixtures/schema/schema.yml', __FILE__)
64
65
  class SchemaClass < Page
65
66
  field :description
@@ -73,103 +74,101 @@ class SchemaTest < MiniTest::Spec
73
74
  @uids = @site.schema.uids
74
75
  end
75
76
 
76
- teardown do
77
- SchemaTest.send(:remove_const, :SchemaClass) rescue nil
77
+ after do
78
+ Object.send(:remove_const, :SchemaClass) rescue nil
78
79
  end
79
80
 
80
- # should "be 12 characters long" do
81
- # Schema::UID.generate.to_s.length.should == 12
82
- # end
83
-
84
- should "be unique" do
81
+ it "be unique" do
85
82
  ids = (0..10000).map { S::Schema::UIDMap.generate }
86
- ids.uniq.length.should == ids.length
83
+ ids.uniq.length.must_equal ids.length
87
84
  end
88
85
 
89
86
 
90
- should "be singletons" do
87
+ it "be singletons" do
91
88
  a = @uids["xxxxxxxxxxxx"]
92
89
  b = @uids["xxxxxxxxxxxx"]
93
90
  c = @uids["ffffffffffff"]
94
- a.object_id.should == b.object_id
95
- a.should == b
96
- c.object_id.should_not == b.object_id
97
- c.should_not == b
91
+ a.object_id.must_equal b.object_id
92
+ a.must_equal b
93
+ c.object_id.wont_equal b.object_id
94
+ c.wont_equal b
98
95
  end
99
96
 
100
- # should "not be creatable" do
101
- # lambda { UID.new('sadf') }.must_raise(NoMethodError)
102
- # end
103
-
104
- should "return nil if passed nil" do
105
- @uids[nil].should be_nil
97
+ it "return nil if passed nil" do
98
+ @uids[nil].must_be_nil
106
99
  end
107
100
 
108
- should "return nil if passed an empty string" do
109
- @uids[""].should be_nil
101
+ it "return nil if passed an empty string" do
102
+ @uids[""].must_be_nil
110
103
  end
111
104
 
112
- should "return the same UID if passed one" do
105
+ it "return the same UID if passed one" do
113
106
  a = @uids["xxxxxxxxxxxx"]
114
- @uids[a].should == a
107
+ @uids[a].must_be_same_as a
115
108
  end
116
109
 
117
- should "test as equal to its string representation" do
118
- @uids["llllllllllll"].should == "llllllllllll"
110
+ it "test as equal to its string representation" do
111
+ "llllllllllll".must_equal @uids["llllllllllll"]
119
112
  end
120
113
 
121
- should "test as eql? if they have the same id" do
114
+ it "test as eql? if they have the same id" do
122
115
  a = @uids["llllllllllll"]
123
116
  b = a.dup
124
117
  assert a.eql?(b), "Identical IDs should pass eql? test"
125
118
  end
126
119
 
127
- should "be readable by content classes" do
128
- SchemaClass.schema_id.should == @uids["xxxxxxxxxxxx"]
120
+ it "should be serializable to JSON" do
121
+ a = SchemaClass.schema_id
122
+ json = Spontaneous::JSON.encode a
123
+ json.must_equal '"xxxxxxxxxxxx"'
129
124
  end
130
125
 
131
- should "be readable by fields" do
132
- @instance.fields[:description].schema_id.should == @uids["ffffffffffff"]
126
+ it "be readable by content classes" do
127
+ SchemaClass.schema_id.must_equal @uids["xxxxxxxxxxxx"]
133
128
  end
134
129
 
135
- should "be readable by boxes" do
136
- @instance.boxes[:posts].schema_id.should == @uids["bbbbbbbbbbbb"]
130
+ it "be readable by fields" do
131
+ @instance.fields[:description].schema_id.must_equal @uids["ffffffffffff"]
137
132
  end
138
133
 
139
- should "be readable by styles" do
140
- @instance.styles[:simple].schema_id.should == @uids["ssssssssssss"]
134
+ it "be readable by boxes" do
135
+ @instance.boxes[:posts].schema_id.must_equal @uids["bbbbbbbbbbbb"]
141
136
  end
142
137
 
143
- should "be readable by layouts" do
144
- @instance.layout.name.should == :clean
145
- @instance.layout.schema_id.should == @uids["llllllllllll"]
138
+ it "be readable by styles" do
139
+ @instance.styles[:simple].schema_id.must_equal @uids["ssssssssssss"]
146
140
  end
147
141
 
148
- context "lookups" do
149
- should "return classes" do
150
- Site.schema.to_class("xxxxxxxxxxxx").should == SchemaClass
142
+ it "be readable by layouts" do
143
+ @instance.layout.name.must_equal :clean
144
+ @instance.layout.schema_id.must_equal @uids["llllllllllll"]
145
+ end
146
+
147
+ describe "lookups" do
148
+ it "return classes" do
149
+ Site.schema.to_class("xxxxxxxxxxxx").must_equal SchemaClass
151
150
  end
152
- should "return fields" do
153
- Site.schema.to_class("ffffffffffff").should == SchemaClass.field_prototypes[:description]
151
+ it "return fields" do
152
+ Site.schema.to_class("ffffffffffff").must_equal SchemaClass.field_prototypes[:description]
154
153
  end
155
- should "return boxes" do
156
- Site.schema.to_class("bbbbbbbbbbbb").should == SchemaClass.box_prototypes[:posts]
154
+ it "return boxes" do
155
+ Site.schema.to_class("bbbbbbbbbbbb").must_equal SchemaClass.box_prototypes[:posts]
157
156
  end
158
- should "return styles" do
159
- Site.schema.to_class("ssssssssssss").should == SchemaClass.style_prototypes[:simple]
157
+ it "return styles" do
158
+ Site.schema.to_class("ssssssssssss").must_equal SchemaClass.style_prototypes[:simple]
160
159
  end
161
- should "return layouts" do
162
- Site.schema.to_class("llllllllllll").should == SchemaClass.layout_prototypes[:clean]
160
+ it "return layouts" do
161
+ Site.schema.to_class("llllllllllll").must_equal SchemaClass.layout_prototypes[:clean]
163
162
  end
164
163
  end
165
164
 
166
165
  end
167
166
 
168
- context "schema verification" do
169
- setup do
167
+ describe "schema verification" do
168
+ before do
170
169
  @site.schema.schema_map_file = File.expand_path('../../fixtures/schema/before.yml', __FILE__)
171
170
  Page.field :title
172
- class B < ::Page; end
171
+ class B < Page; end
173
172
  class C < Piece; end
174
173
  class D < Piece; end
175
174
  class O < Box; end
@@ -192,38 +191,31 @@ class SchemaTest < MiniTest::Spec
192
191
  O.style :ostyle1
193
192
  O.style :ostyle2
194
193
 
195
- # have to use mocking because schema class list is totally fecked up
196
- # after running other tests
197
- # TODO: look into reliable, non-harmful way of clearing out the schema state
198
- # between tests
199
- # Schema.stubs(:classes).returns([B, C, D, O])
200
- # Schema.classes.should == [B, C, D, O]
201
194
  @site.schema.map
202
195
  @uids = @site.schema.uids
203
- ::Page.schema_id.should == @uids["tttttttttttt"]
204
- B.schema_id.should == @uids["bbbbbbbbbbbb"]
205
- C.schema_id.should == @uids["cccccccccccc"]
206
- D.schema_id.should == @uids["dddddddddddd"]
207
- O.schema_id.should == @uids["oooooooooooo"]
196
+ ::Page.schema_id.must_equal @uids["tttttttttttt"]
197
+ B.schema_id.must_equal @uids["bbbbbbbbbbbb"]
198
+ C.schema_id.must_equal @uids["cccccccccccc"]
199
+ D.schema_id.must_equal @uids["dddddddddddd"]
200
+ O.schema_id.must_equal @uids["oooooooooooo"]
208
201
  end
209
202
 
210
- teardown do
211
- Object.send(:remove_const, :Page) rescue nil
212
- SchemaTest.send(:remove_const, :B) rescue nil
213
- SchemaTest.send(:remove_const, :C) rescue nil
214
- SchemaTest.send(:remove_const, :D) rescue nil
215
- SchemaTest.send(:remove_const, :E) rescue nil
216
- SchemaTest.send(:remove_const, :F) rescue nil
217
- SchemaTest.send(:remove_const, :O) rescue nil
203
+ after do
204
+ Object.send(:remove_const, :B) rescue nil
205
+ Object.send(:remove_const, :C) rescue nil
206
+ Object.send(:remove_const, :D) rescue nil
207
+ Object.send(:remove_const, :E) rescue nil
208
+ Object.send(:remove_const, :F) rescue nil
209
+ Object.send(:remove_const, :O) rescue nil
218
210
  end
219
211
 
220
- should "return the right schema anme for inherited box fields" do
212
+ it "return the right schema anme for inherited box fields" do
221
213
  f = B.boxes[:publishers].instance_class.field :newfield
222
- B.boxes[:publishers].instance_class.fields.first.schema_name.should == "field/oooooooooooo/ofield1"
223
- f.schema_name.should == "field/publishers00/newfield"
214
+ B.boxes[:publishers].instance_class.fields.first.schema_name.must_equal "field/oooooooooooo/ofield1"
215
+ f.schema_name.must_equal "field/publishers00/newfield"
224
216
  end
225
217
 
226
- should "detect addition of classes" do
218
+ it "detect addition of classes" do
227
219
  class E < ::Piece; end
228
220
  @site.schema.stubs(:classes).returns([B, C, D, E])
229
221
  exception = nil
@@ -233,15 +225,15 @@ class SchemaTest < MiniTest::Spec
233
225
  rescue Spontaneous::SchemaModificationError => e
234
226
  exception = e
235
227
  end
236
- exception.added_classes.should == [E]
228
+ exception.added_classes.must_equal [E]
237
229
  # need to explicitly define solution to validation error
238
230
  # Schema.expects(:generate).returns('dddddddddddd')
239
- # D.schema_id.should == 'dddddddddddd'
231
+ # D.schema_id.must_equal 'dddddddddddd'
240
232
  end
241
233
 
242
- should "detect removal of classes" do
243
- SchemaTest.send(:remove_const, :C) rescue nil
244
- SchemaTest.send(:remove_const, :D) rescue nil
234
+ it "detect removal of classes" do
235
+ Object.send(:remove_const, :C) rescue nil
236
+ Object.send(:remove_const, :D) rescue nil
245
237
  @site.schema.stubs(:classes).returns([::Page, B, O])
246
238
  begin
247
239
  @site.schema.validate_schema
@@ -249,12 +241,12 @@ class SchemaTest < MiniTest::Spec
249
241
  rescue Spontaneous::SchemaModificationError => e
250
242
  exception = e
251
243
  end
252
- exception.removed_classes.map { |c| c.name }.sort.should == ["SchemaTest::C", "SchemaTest::D"]
244
+ exception.removed_classes.map { |c| c.name }.sort.must_equal ["C", "D"]
253
245
  end
254
246
 
255
- should "detect multiple removals & additions of classes" do
256
- SchemaTest.send(:remove_const, :C) rescue nil
257
- SchemaTest.send(:remove_const, :D) rescue nil
247
+ it "detect multiple removals & additions of classes" do
248
+ Object.send(:remove_const, :C) rescue nil
249
+ Object.send(:remove_const, :D) rescue nil
258
250
  class E < Content; end
259
251
  class F < Content; end
260
252
  @site.schema.stubs(:classes).returns([::Page, B, E, F, O])
@@ -264,11 +256,11 @@ class SchemaTest < MiniTest::Spec
264
256
  rescue Spontaneous::SchemaModificationError => e
265
257
  exception = e
266
258
  end
267
- exception.added_classes.should == [E, F]
268
- exception.removed_classes.map {|c| c.name}.sort.should == ["SchemaTest::C", "SchemaTest::D"]
259
+ exception.added_classes.must_equal [E, F]
260
+ exception.removed_classes.map {|c| c.name}.sort.must_equal ["C", "D"]
269
261
  end
270
262
 
271
- should "detect addition of fields" do
263
+ it "detect addition of fields" do
272
264
  B.field :name
273
265
  C.field :location
274
266
  C.field :description
@@ -278,10 +270,10 @@ class SchemaTest < MiniTest::Spec
278
270
  rescue Spontaneous::SchemaModificationError => e
279
271
  exception = e
280
272
  end
281
- exception.added_fields.should == [B.field_prototypes[:name], C.field_prototypes[:location], C.field_prototypes[:description]]
273
+ exception.added_fields.must_equal [B.field_prototypes[:name], C.field_prototypes[:location], C.field_prototypes[:description]]
282
274
  end
283
275
 
284
- should "detect removal of fields" do
276
+ it "detect removal of fields" do
285
277
  field = B.field_prototypes[:author]
286
278
  B.stubs(:field_prototypes).returns({:author => field})
287
279
  B.stubs(:fields).returns([field])
@@ -292,12 +284,12 @@ class SchemaTest < MiniTest::Spec
292
284
  exception = e
293
285
  end
294
286
  exception.removed_fields.length == 1
295
- exception.removed_fields[0].name.should == "description"
296
- exception.removed_fields[0].owner.should == SchemaTest::B
297
- exception.removed_fields[0].category.should == :field
287
+ exception.removed_fields[0].name.must_equal "description"
288
+ exception.removed_fields[0].owner.must_equal B
289
+ exception.removed_fields[0].category.must_equal :field
298
290
  end
299
291
 
300
- should "detect addition of boxes" do
292
+ it "detect addition of boxes" do
301
293
  B.box :changes
302
294
  B.box :updates
303
295
  begin
@@ -306,10 +298,10 @@ class SchemaTest < MiniTest::Spec
306
298
  rescue Spontaneous::SchemaModificationError => e
307
299
  exception = e
308
300
  end
309
- exception.added_boxes.should == [B.boxes[:changes], B.boxes[:updates]]
301
+ exception.added_boxes.must_equal [B.boxes[:changes], B.boxes[:updates]]
310
302
  end
311
303
 
312
- should "detect removal of boxes" do
304
+ it "detect removal of boxes" do
313
305
  boxes = S::Collections::PrototypeSet.new
314
306
  boxes[:promotions] = B.boxes[:promotions]
315
307
 
@@ -320,13 +312,13 @@ class SchemaTest < MiniTest::Spec
320
312
  rescue Spontaneous::SchemaModificationError => e
321
313
  exception = e
322
314
  end
323
- exception.removed_boxes.length.should == 1
324
- exception.removed_boxes[0].name.should == "publishers"
325
- exception.removed_boxes[0].owner.should == SchemaTest::B
326
- exception.removed_boxes[0].category.should == :box
315
+ exception.removed_boxes.length.must_equal 1
316
+ exception.removed_boxes[0].name.must_equal "publishers"
317
+ exception.removed_boxes[0].owner.must_equal B
318
+ exception.removed_boxes[0].category.must_equal :box
327
319
  end
328
320
 
329
- should "detect addition of styles" do
321
+ it "detect addition of styles" do
330
322
  B.style :fancy
331
323
  B.style :dirty
332
324
  begin
@@ -335,10 +327,10 @@ class SchemaTest < MiniTest::Spec
335
327
  rescue Spontaneous::SchemaModificationError => e
336
328
  exception = e
337
329
  end
338
- exception.added_styles.should == [B.styles.detect{ |s| s.name == :fancy }, B.styles.detect{ |s| s.name == :dirty }]
330
+ exception.added_styles.must_equal [B.styles.detect{ |s| s.name == :fancy }, B.styles.detect{ |s| s.name == :dirty }]
339
331
  end
340
332
 
341
- should "detect removal of styles" do
333
+ it "detect removal of styles" do
342
334
  style = B.styles[:inline]
343
335
  B.styles.expects(:order).returns([:inline])
344
336
  B.styles.stubs(:[]).with(:inline).returns(style)
@@ -349,13 +341,13 @@ class SchemaTest < MiniTest::Spec
349
341
  rescue Spontaneous::SchemaModificationError => e
350
342
  exception = e
351
343
  end
352
- exception.removed_styles.length.should == 1
353
- exception.removed_styles[0].name.should == "outline"
354
- exception.removed_styles[0].owner.should == SchemaTest::B
355
- exception.removed_styles[0].category.should == :style
344
+ exception.removed_styles.length.must_equal 1
345
+ exception.removed_styles[0].name.must_equal "outline"
346
+ exception.removed_styles[0].owner.must_equal B
347
+ exception.removed_styles[0].category.must_equal :style
356
348
  end
357
349
 
358
- should "detect addition of layouts" do
350
+ it "detect addition of layouts" do
359
351
  B.layout :fancy
360
352
  B.layout :dirty
361
353
  begin
@@ -364,10 +356,10 @@ class SchemaTest < MiniTest::Spec
364
356
  rescue Spontaneous::SchemaModificationError => e
365
357
  exception = e
366
358
  end
367
- exception.added_layouts.should == [B.layouts.detect{ |s| s.name == :fancy }, B.layouts.detect{ |s| s.name == :dirty }]
359
+ exception.added_layouts.must_equal [B.layouts.detect{ |s| s.name == :fancy }, B.layouts.detect{ |s| s.name == :dirty }]
368
360
  end
369
361
 
370
- should "detect removal of layouts" do
362
+ it "detect removal of layouts" do
371
363
  layout = B.layouts[:thin]
372
364
  B.layouts.expects(:order).returns([:thin])
373
365
  B.layouts.stubs(:[]).with(:thin).returns(layout)
@@ -378,13 +370,13 @@ class SchemaTest < MiniTest::Spec
378
370
  rescue Spontaneous::SchemaModificationError => e
379
371
  exception = e
380
372
  end
381
- exception.removed_layouts.length.should == 1
382
- exception.removed_layouts[0].name.should == "fat"
383
- exception.removed_layouts[0].owner.should == SchemaTest::B
384
- exception.removed_layouts[0].category.should == :layout
373
+ exception.removed_layouts.length.must_equal 1
374
+ exception.removed_layouts[0].name.must_equal "fat"
375
+ exception.removed_layouts[0].owner.must_equal B
376
+ exception.removed_layouts[0].category.must_equal :layout
385
377
  end
386
378
 
387
- should "detect addition of fields to anonymous boxes" do
379
+ it "detect addition of fields to anonymous boxes" do
388
380
  f1 = B.boxes[:publishers].instance_class.field :field3
389
381
  f2 = B.boxes[:promotions].instance_class.field :field3
390
382
  begin
@@ -393,10 +385,10 @@ class SchemaTest < MiniTest::Spec
393
385
  rescue Spontaneous::SchemaModificationError => e
394
386
  exception = e
395
387
  end
396
- assert_same_elements exception.added_fields, [f2, f1]
388
+ assert_has_elements exception.added_fields, [f2, f1]
397
389
  end
398
390
 
399
- should "detect removal of fields from anonymous boxes" do
391
+ it "detect removal of fields from anonymous boxes" do
400
392
  f2 = B.boxes[:promotions].instance_class.field_prototypes[:field2]
401
393
  B.boxes[:promotions].instance_class.stubs(:field_prototypes).returns({:field2 => f2})
402
394
  B.boxes[:promotions].instance_class.stubs(:fields).returns([f2])
@@ -406,13 +398,13 @@ class SchemaTest < MiniTest::Spec
406
398
  rescue Spontaneous::SchemaModificationError => e
407
399
  exception = e
408
400
  end
409
- exception.removed_fields.length.should == 1
410
- exception.removed_fields[0].name.should == "field1"
411
- exception.removed_fields[0].owner.instance_class.should == SchemaTest::B.boxes[:promotions].instance_class
412
- exception.removed_fields[0].category.should == :field
401
+ exception.removed_fields.length.must_equal 1
402
+ exception.removed_fields[0].name.must_equal "field1"
403
+ exception.removed_fields[0].owner.instance_class.must_equal B.boxes[:promotions].instance_class
404
+ exception.removed_fields[0].category.must_equal :field
413
405
  end
414
406
 
415
- should "detect addition of fields to box types" do
407
+ it "detect addition of fields to box types" do
416
408
  O.field :name
417
409
  begin
418
410
  @site.schema.validate_schema
@@ -420,10 +412,10 @@ class SchemaTest < MiniTest::Spec
420
412
  rescue Spontaneous::SchemaModificationError => e
421
413
  exception = e
422
414
  end
423
- exception.added_fields.should == [O.field_prototypes[:name]]
415
+ exception.added_fields.must_equal [O.field_prototypes[:name]]
424
416
  end
425
417
 
426
- # should "detect removal of fields from box types" do
418
+ # it "detect removal of fields from box types" do
427
419
  # skip "stubbing is messing up the field hierarchy in weird ways"
428
420
  # fields = [O.field_prototypes[:ofield1]]
429
421
  # O.stubs(:fields).returns(fields)
@@ -434,15 +426,15 @@ class SchemaTest < MiniTest::Spec
434
426
  # exception = e
435
427
  # end
436
428
  # exception.removed_fields.length == 1
437
- # exception.removed_fields[0].name.should == "ofield2"
438
- # exception.removed_fields[0].owner.should == SchemaTest::O
439
- # exception.removed_fields[0].category.should == :field
429
+ # exception.removed_fields[0].name.must_equal "ofield2"
430
+ # exception.removed_fields[0].owner.must_equal O
431
+ # exception.removed_fields[0].category.must_equal :field
440
432
  # end
441
433
 
442
- should "detect addition of styles to box types"
443
- should "detect removal of styles from box types"
434
+ it "detect addition of styles to box types"
435
+ it "detect removal of styles from box types"
444
436
 
445
- should "detect addition of styles to anonymous boxes" do
437
+ it "detect addition of styles to anonymous boxes" do
446
438
  s1 = B.boxes[:publishers].instance_class.style :style3
447
439
  s2 = B.boxes[:promotions].instance_class.style :style3
448
440
  begin
@@ -451,10 +443,10 @@ class SchemaTest < MiniTest::Spec
451
443
  rescue Spontaneous::SchemaModificationError => e
452
444
  exception = e
453
445
  end
454
- assert_same_elements exception.added_styles, [s2, s1]
446
+ assert_has_elements exception.added_styles, [s2, s1]
455
447
  end
456
448
 
457
- should "detect removal of styles from anonymous boxes" do
449
+ it "detect removal of styles from anonymous boxes" do
458
450
  klass = B.boxes[:promotions].instance_class
459
451
  style = klass.styles.first
460
452
  klass.styles.expects(:order).returns([style.name])
@@ -466,43 +458,43 @@ class SchemaTest < MiniTest::Spec
466
458
  rescue Spontaneous::SchemaModificationError => e
467
459
  exception = e
468
460
  end
469
- exception.removed_styles.length.should == 1
470
- exception.removed_styles[0].name.should == "style2"
471
- exception.removed_styles[0].owner.instance_class.should == SchemaTest::B.boxes[:promotions].instance_class
472
- exception.removed_styles[0].category.should == :style
461
+ exception.removed_styles.length.must_equal 1
462
+ exception.removed_styles[0].name.must_equal "style2"
463
+ exception.removed_styles[0].owner.instance_class.must_equal B.boxes[:promotions].instance_class
464
+ exception.removed_styles[0].category.must_equal :style
473
465
  end
474
466
  end
475
467
  end
476
468
 
477
- context "Transient (testing) maps" do
478
- setup do
469
+ describe "Transient (testing) maps" do
470
+ before do
479
471
  @site.schema.schema_loader_class = Spontaneous::Schema::TransientMap
480
472
  class V < ::Piece; end
481
473
  class W < ::Piece; end
482
474
  end
483
- teardown do
484
- self.class.send(:remove_const, :V)
485
- self.class.send(:remove_const, :W)
475
+ after do
476
+ Object.send(:remove_const, :V)
477
+ Object.send(:remove_const, :W)
486
478
  end
487
479
 
488
- should "create uids on demand" do
489
- V.schema_id.should_not be_nil
490
- W.schema_id.should_not be_nil
491
- V.schema_id.should_not == W.schema_id
480
+ it "create uids on demand" do
481
+ V.schema_id.wont_be_nil
482
+ W.schema_id.wont_be_nil
483
+ V.schema_id.wont_equal W.schema_id
492
484
  end
493
485
 
494
- should "return consistent ids within a session" do
486
+ it "return consistent ids within a session" do
495
487
  a = V.schema_id
496
488
  b = V.schema_id
497
- a.should equal?(b)
489
+ a.must_be_same_as(b)
498
490
  end
499
491
 
500
- should "return UID objects" do
492
+ it "return UID objects" do
501
493
  V.schema_id.must_be_instance_of(Spontaneous::Schema::UID)
502
494
  end
503
495
 
504
- context "for inherited boxes" do
505
- setup do
496
+ describe "for inherited boxes" do
497
+ before do
506
498
  class ::A < ::Piece
507
499
  box :a
508
500
  end
@@ -513,22 +505,22 @@ class SchemaTest < MiniTest::Spec
513
505
  box :a
514
506
  end
515
507
  end
516
- teardown do
508
+ after do
517
509
  Object.send(:remove_const, :A) rescue nil
518
510
  Object.send(:remove_const, :B) rescue nil
519
511
  Object.send(:remove_const, :C) rescue nil
520
512
  end
521
- should "be the same as the box in the supertype" do
522
- B.boxes[:a].schema_id.should == A.boxes[:a].schema_id
523
- C.boxes[:a].schema_id.should == A.boxes[:a].schema_id
524
- B.boxes[:a].instance_class.schema_id.should == A.boxes[:a].instance_class.schema_id
525
- C.boxes[:a].instance_class.schema_id.should == A.boxes[:a].instance_class.schema_id
513
+ it "be the same as the box in the supertype" do
514
+ B.boxes[:a].schema_id.must_equal A.boxes[:a].schema_id
515
+ C.boxes[:a].schema_id.must_equal A.boxes[:a].schema_id
516
+ B.boxes[:a].instance_class.schema_id.must_equal A.boxes[:a].instance_class.schema_id
517
+ C.boxes[:a].instance_class.schema_id.must_equal A.boxes[:a].instance_class.schema_id
526
518
  end
527
519
  end
528
520
  end
529
521
 
530
- context "Schema groups" do
531
- setup do
522
+ describe "Schema groups" do
523
+ before do
532
524
  class ::A < ::Page
533
525
  group :a, :b, :c
534
526
  box :cgroup do
@@ -556,39 +548,39 @@ class SchemaTest < MiniTest::Spec
556
548
  end
557
549
  end
558
550
 
559
- teardown do
551
+ after do
560
552
  Object.send(:remove_const, :A) rescue nil
561
553
  Object.send(:remove_const, :B) rescue nil
562
554
  Object.send(:remove_const, :C) rescue nil
563
555
  end
564
556
 
565
- should "let boxes allow a list of content types" do
566
- A.boxes.cgroup.allowed_types(nil).should == [A, B, C]
567
- C.boxes.bgroup.allowed_types(nil).should == [A, B]
568
- C.boxes.cgroup.allowed_types(nil).should == [A, B, C]
569
- B.boxes.agroup.allowed_types(nil).should == [A, B, C]
557
+ it "let boxes allow a list of content types" do
558
+ A.boxes.cgroup.allowed_types(nil).must_equal [A, B, C]
559
+ C.boxes.bgroup.allowed_types(nil).must_equal [A, B]
560
+ C.boxes.cgroup.allowed_types(nil).must_equal [A, B, C]
561
+ B.boxes.agroup.allowed_types(nil).must_equal [A, B, C]
570
562
  end
571
563
 
572
- should "apply the options to all the included classes" do
564
+ it "apply the options to all the included classes" do
573
565
  user = mock()
574
566
  S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.editor).returns(true)
575
567
  S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.root).returns(true)
576
- C.boxes.cgroup.allowed_types(user).should == [A, B, C]
568
+ C.boxes.cgroup.allowed_types(user).must_equal [A, B, C]
577
569
  S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.editor).returns(true)
578
570
  S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.root).returns(false)
579
- C.boxes.cgroup.allowed_types(user).should == []
580
- A.boxes.cgroup.allowed_types(user).should == [A, B, C]
571
+ C.boxes.cgroup.allowed_types(user).must_equal []
572
+ A.boxes.cgroup.allowed_types(user).must_equal [A, B, C]
581
573
  end
582
574
 
583
- should "allow for configuring styles" do
575
+ it "allow for configuring styles" do
584
576
  c = C.new
585
577
  b = B.new
586
578
  styles = c.bgroup.available_styles(b)
587
- styles.length.should == 1
588
- styles.first.name.should == :fish
579
+ styles.length.must_equal 1
580
+ styles.first.name.must_equal :fish
589
581
  end
590
582
 
591
- should "reload correctly" do
583
+ it "reload correctly" do
592
584
  FileUtils.mkdir(@site.root / "config")
593
585
  @site.schema.write_schema
594
586
  @site.schema.delete(::B)
@@ -606,14 +598,14 @@ class SchemaTest < MiniTest::Spec
606
598
 
607
599
  @site.schema.validate!
608
600
 
609
- A.boxes.cgroup.allowed_types(nil).should == [A, C]
610
- C.boxes.bgroup.allowed_types(nil).should == [A, B]
601
+ A.boxes.cgroup.allowed_types(nil).must_equal [A, C]
602
+ C.boxes.bgroup.allowed_types(nil).must_equal [A, B]
611
603
  end
612
604
  end
613
605
 
614
606
 
615
- context "Map writing" do
616
- context "Non-existant maps" do
607
+ describe "Map writing" do
608
+ describe "Non-existant maps" do
617
609
  def expected_schema
618
610
  classes = @site.schema.classes#[ Content::Page, Page, Content::Piece, Piece, ::A, ::B]
619
611
  expected = Hash[ classes.map { |klass| [ klass.schema_id.to_s, klass.schema_name ] } ]
@@ -629,7 +621,7 @@ class SchemaTest < MiniTest::Spec
629
621
  expected
630
622
  end
631
623
 
632
- setup do
624
+ before do
633
625
  @map_file = File.expand_path('../../../tmp/schema.yml', __FILE__)
634
626
 
635
627
  ::FileUtils.rm_f(@map_file) if ::File.exists?(@map_file)
@@ -649,34 +641,34 @@ class SchemaTest < MiniTest::Spec
649
641
  end
650
642
  end
651
643
 
652
- teardown do
644
+ after do
653
645
  Object.send(:remove_const, :A) rescue nil
654
646
  Object.send(:remove_const, :B) rescue nil
655
647
  FileUtils.rm(@map_file) if ::File.exists?(@map_file)
656
648
  end
657
649
 
658
- should "get created with verification" do
650
+ it "get created with verification" do
659
651
  S.schema.validate!
660
- File.exists?(@map_file).should be_true
661
- YAML.load_file(@map_file).should == expected_schema
652
+ assert File.exists?(@map_file)
653
+ YAML.load_file(@map_file).must_equal expected_schema
662
654
  end
663
655
 
664
656
  # Having the generator create an empty config/schema.yml is a useful way of
665
657
  # identifying a spontaneous site (for use by bin/spot)
666
- should "get overwritten if invalid or empty" do
658
+ it "get overwritten if invalid or empty" do
667
659
  File.open(@map_file, "w") do |f|
668
660
  f.write("# schema")
669
661
  end
670
- File.exists?(@map_file).should be_true
671
- S.schema.map.valid?.should be_false
662
+ assert File.exists?(@map_file)
663
+ refute S.schema.map.valid?
672
664
  S.schema.validate!
673
- S.schema.map.valid?.should be_true
674
- YAML.load_file(@map_file).should == expected_schema
665
+ assert S.schema.map.valid?
666
+ YAML.load_file(@map_file).must_equal expected_schema
675
667
  end
676
668
  end
677
669
 
678
- context "change resolution" do
679
- setup do
670
+ describe "change resolution" do
671
+ before do
680
672
  @map_file = File.expand_path('../../../tmp/schema.yml', __FILE__)
681
673
  FileUtils.mkdir_p(File.dirname(@map_file))
682
674
  FileUtils.cp(File.expand_path('../../fixtures/schema/resolvable.yml', __FILE__), @map_file)
@@ -695,10 +687,48 @@ class SchemaTest < MiniTest::Spec
695
687
  style :daring
696
688
  end
697
689
  @site.schema.validate!
698
- A.schema_id.should == S.schema.uids["qLcxinA008"]
690
+ A.schema_id.must_equal S.schema.uids["qLcxinA008"]
691
+ end
692
+
693
+ describe "renamed boxes" do
694
+ before do
695
+ S.schema.delete(::A)
696
+ Object.send :remove_const, :A
697
+ class ::A < ::Page
698
+ field :title
699
+ field :introduction
700
+ layout :sparse
701
+ box :renamed do
702
+ field :description
703
+ end
704
+ end
705
+ end
706
+ it "raise a validation exception" do
707
+ lambda { S.schema.validate! }.must_raise(Spontaneous::SchemaModificationError)
708
+ end
709
+ describe "modification exception" do
710
+ before do
711
+ begin
712
+ S.schema.validate!
713
+ rescue Spontaneous::SchemaModificationError => e
714
+ @exception = e
715
+ @modification = e.modification
716
+ end
717
+ end
718
+
719
+ it "not be resolvable" do
720
+ refute @modification.resolvable?
721
+ end
722
+ it "have one added & one removed box"do
723
+ @modification.added_boxes.length.must_equal 1
724
+ @modification.added_boxes.first.name.must_equal :renamed
725
+ @modification.removed_boxes.length.must_equal 1
726
+ @modification.removed_boxes.first.name.must_equal "posts"
727
+ end
728
+ end
699
729
  end
700
730
 
701
- teardown do
731
+ after do
702
732
  Object.send(:remove_const, :A) rescue nil
703
733
  Object.send(:remove_const, :B) rescue nil
704
734
  Object.send(:remove_const, :X) rescue nil
@@ -707,7 +737,7 @@ class SchemaTest < MiniTest::Spec
707
737
  FileUtils.rm(@map_file) if ::File.exists?(@map_file) rescue nil
708
738
  end
709
739
 
710
- should "be done automatically if only additions are found" do
740
+ it "be done automatically if only additions are found" do
711
741
  A.field :moose
712
742
  class ::X < ::A
713
743
  field :wild
@@ -720,32 +750,32 @@ class SchemaTest < MiniTest::Spec
720
750
  style :risky
721
751
  end
722
752
  S.schema.validate!
723
- ::X.schema_id.should_not be_nil
724
- ::Y.schema_id.should_not be_nil
725
- ::A.field_prototypes[:moose].schema_id.should_not be_nil
753
+ ::X.schema_id.wont_be_nil
754
+ ::Y.schema_id.wont_be_nil
755
+ ::A.field_prototypes[:moose].schema_id.wont_be_nil
726
756
 
727
757
  m = YAML.load_file(@map_file)
728
- m[::A.field_prototypes[:moose].schema_id.to_s].should == ::A.field_prototypes[:moose].schema_name
729
- m[::X.schema_id.to_s].should == ::X.schema_name
730
- m[::Y.schema_id.to_s].should == ::Y.schema_name
731
- m[::X.field_prototypes[:wild].schema_id.to_s].should == ::X.field_prototypes[:wild].schema_name
732
- m[::X.boxes[:monkeys].schema_id.to_s].should == ::X.boxes[:monkeys].schema_name
733
- m[::X.boxes[:monkeys].field_prototypes[:banana].schema_id.to_s].should == ::X.boxes[:monkeys].field_prototypes[:banana].schema_name
734
- m[::X.layout_prototypes[:rich].schema_id.to_s].should == ::X.layout_prototypes[:rich].schema_name
758
+ m[::A.field_prototypes[:moose].schema_id.to_s].must_equal ::A.field_prototypes[:moose].schema_name
759
+ m[::X.schema_id.to_s].must_equal ::X.schema_name
760
+ m[::Y.schema_id.to_s].must_equal ::Y.schema_name
761
+ m[::X.field_prototypes[:wild].schema_id.to_s].must_equal ::X.field_prototypes[:wild].schema_name
762
+ m[::X.boxes[:monkeys].schema_id.to_s].must_equal ::X.boxes[:monkeys].schema_name
763
+ m[::X.boxes[:monkeys].field_prototypes[:banana].schema_id.to_s].must_equal ::X.boxes[:monkeys].field_prototypes[:banana].schema_name
764
+ m[::X.layout_prototypes[:rich].schema_id.to_s].must_equal ::X.layout_prototypes[:rich].schema_name
735
765
  end
736
766
 
737
767
 
738
- should "be done automatically if only classes have been removed" do
768
+ it "be done automatically if only classes have been removed" do
739
769
  uid = B.schema_id.to_s
740
770
  Object.send(:remove_const, :B)
741
771
  S.schema.stubs(:classes).returns([::A])
742
772
  S.schema.reload!
743
773
  S.schema.validate!
744
774
  m = YAML.load_file(@map_file)
745
- m.key?(uid).should be_false
775
+ refute m.key?(uid)
746
776
  end
747
777
 
748
- should "be done automatically if only boxes have been removed" do
778
+ it "be done automatically if only boxes have been removed" do
749
779
  uid = A.boxes[:posts].schema_id.to_s
750
780
  Object.send :remove_const, :A
751
781
  class ::A < ::Page
@@ -757,10 +787,10 @@ class SchemaTest < MiniTest::Spec
757
787
  S.schema.reload!
758
788
  S.schema.validate!
759
789
  m = YAML.load_file(@map_file)
760
- m.key?(uid).should be_false
790
+ refute m.key?(uid)
761
791
  end
762
792
 
763
- should "be done automatically if only fields have been removed xxx" do
793
+ it "be done automatically if only fields have been removed" do
764
794
  uid = A.fields[:title].schema_id.to_s
765
795
  S.schema.delete(::A)
766
796
  Object.send :remove_const, :A
@@ -772,24 +802,24 @@ class SchemaTest < MiniTest::Spec
772
802
  S.schema.reload!
773
803
  S.schema.validate!
774
804
  m = YAML.load_file(@map_file)
775
- m.key?(uid).should be_false
805
+ refute m.key?(uid)
776
806
  end
777
807
 
778
- should "be done automatically in presence of independent addition inside type and of type" do
808
+ it "be done automatically in presence of independent addition inside type and of type" do
779
809
  A.field :moose
780
810
  uid = B.schema_id.to_s
781
811
  Object.send(:remove_const, :B)
782
812
  S.schema.stubs(:classes).returns([::A])
783
813
  S.schema.reload!
784
814
  S.schema.validate!
785
- ::A.field_prototypes[:moose].schema_id.should_not be_nil
815
+ ::A.field_prototypes[:moose].schema_id.wont_be_nil
786
816
 
787
817
  m = YAML.load_file(@map_file)
788
- m[::A.field_prototypes[:moose].schema_id.to_s].should == ::A.field_prototypes[:moose].schema_name
789
- m.key?(uid).should be_false
818
+ m[::A.field_prototypes[:moose].schema_id.to_s].must_equal ::A.field_prototypes[:moose].schema_name
819
+ refute m.key?(uid)
790
820
  end
791
821
 
792
- should "be done automatically in presence of independent addition & removal of fields" do
822
+ it "be done automatically in presence of independent addition & removal of fields" do
793
823
  A.field :moose
794
824
  f1 = B.field_prototypes[:location]
795
825
  uid = f1.schema_id.to_s
@@ -799,14 +829,14 @@ class SchemaTest < MiniTest::Spec
799
829
  S.schema.reload!
800
830
  S.schema.validate!
801
831
 
802
- ::A.field_prototypes[:moose].schema_id.should_not be_nil
832
+ ::A.field_prototypes[:moose].schema_id.wont_be_nil
803
833
 
804
834
  m = YAML.load_file(@map_file)
805
- m[::A.field_prototypes[:moose].schema_id.to_s].should == ::A.field_prototypes[:moose].schema_name
806
- m.key?(uid).should be_false
835
+ m[::A.field_prototypes[:moose].schema_id.to_s].must_equal ::A.field_prototypes[:moose].schema_name
836
+ refute m.key?(uid)
807
837
  end
808
838
 
809
- should "be done automatically in presence of independent changes to boxes & fields" do
839
+ it "be done automatically in presence of independent changes to boxes & fields" do
810
840
  B.field :crisis
811
841
  uid = A.boxes[:posts].schema_id.to_s
812
842
  A.stubs(:box_prototypes).returns(S::Collections::PrototypeSet.new)
@@ -814,12 +844,12 @@ class SchemaTest < MiniTest::Spec
814
844
  S.schema.reload!
815
845
  S.schema.validate!
816
846
 
817
- ::B.field_prototypes[:crisis].schema_id.should_not be_nil
847
+ ::B.field_prototypes[:crisis].schema_id.wont_be_nil
818
848
  m = YAML.load_file(@map_file)
819
- m.key?(uid).should be_false
849
+ refute m.key?(uid)
820
850
  end
821
851
 
822
- should "be done automatically in presence of independent changes to classes, boxes & fields" do
852
+ it "be done automatically in presence of independent changes to classes, boxes & fields" do
823
853
  class ::X < B; end
824
854
  uid = A.boxes[:posts].schema_id.to_s
825
855
  A.stubs(:box_prototypes).returns(S::Collections::PrototypeSet.new)
@@ -830,24 +860,24 @@ class SchemaTest < MiniTest::Spec
830
860
  S.schema.reload!
831
861
  S.schema.validate!
832
862
 
833
- ::A.field_prototypes[:crisis].schema_id.should_not be_nil
863
+ ::A.field_prototypes[:crisis].schema_id.wont_be_nil
834
864
  m = YAML.load_file(@map_file)
835
865
 
836
866
  box = ::B.boxes[:circus]
837
- m[box.schema_id.to_s].should == box.schema_name
867
+ m[box.schema_id.to_s].must_equal box.schema_name
838
868
 
839
869
  field = ::A.field_prototypes[:crisis]
840
- m[field.schema_id.to_s].should == field.schema_name
870
+ m[field.schema_id.to_s].must_equal field.schema_name
841
871
 
842
872
  field = ::B.field_prototypes[:crisis]
843
- m[field.schema_id.to_s].should == field.schema_name
873
+ m[field.schema_id.to_s].must_equal field.schema_name
844
874
 
845
- m.key?(uid).should be_false
875
+ refute m.key?(uid)
846
876
  end
847
877
 
848
878
 
849
879
  # sanity check
850
- should "still raise error in case of addition & deletion" do
880
+ it "still raise error in case of addition & deletion" do
851
881
  A.field :added
852
882
  f1 = A.field_prototypes[:title]
853
883
  f2 = A.field_prototypes[:added]
@@ -859,7 +889,7 @@ class SchemaTest < MiniTest::Spec
859
889
  lambda { S.schema.validate! }.must_raise(Spontaneous::SchemaModificationError)
860
890
  end
861
891
 
862
- should "still raise error in case of addition & deletion of classes" do
892
+ it "still raise error in case of addition & deletion of classes" do
863
893
  class ::X < A; end
864
894
  uid = B.schema_id.to_s
865
895
  Object.send(:remove_const, :B)
@@ -868,7 +898,7 @@ class SchemaTest < MiniTest::Spec
868
898
  lambda { S.schema.validate! }.must_raise(Spontaneous::SchemaModificationError)
869
899
  end
870
900
 
871
- should "delete box content when a box is removed" do
901
+ it "delete box content when a box is removed" do
872
902
  instance = A.new
873
903
  piece1 = B.new
874
904
  piece2 = B.new
@@ -876,20 +906,20 @@ class SchemaTest < MiniTest::Spec
876
906
  instance.posts << piece2
877
907
  instance.save
878
908
  instance = Content[instance.id]
879
- instance.posts.contents.length.should == 2
880
- Content.count.should == 3
909
+ instance.posts.contents.length.must_equal 2
910
+ Content.count.must_equal 3
881
911
  uid = A.boxes[:posts].schema_id.to_s
882
912
  A.stubs(:box_prototypes).returns(S::Collections::PrototypeSet.new)
883
913
  S.schema.stubs(:classes).returns([A, B])
884
914
  S.schema.reload!
885
915
  S.schema.validate!
886
- Content.count.should == 1
887
- Content[instance.id].should == instance
916
+ Content.count.must_equal 1
917
+ Content[instance.id].must_equal instance
888
918
  end
889
919
 
890
- context "which isn't automatically resolvable" do
891
- context "with one field removed" do
892
- setup do
920
+ describe "conflict" do
921
+ describe "-1 field" do
922
+ before do
893
923
  A.field :a
894
924
  A.field :b
895
925
  @df1 = A.field_prototypes[:title]
@@ -907,27 +937,27 @@ class SchemaTest < MiniTest::Spec
907
937
  @modification = e.modification
908
938
  end
909
939
  end
910
- should "return list of solutions for removal of one field" do
940
+ it "return list of solutions for removal of one field" do
911
941
  # add :a, :b, delete :title
912
942
  # add :b, rename :title => :a
913
943
  # add :a, rename :title => :b
914
- @modification.actions.description.should =~ /field 'title'/
915
- @modification.actions.length.should == 3
944
+ @modification.actions.description.must_match /field 'title'/
945
+ @modification.actions.length.must_equal 3
916
946
  action = @modification.actions[0]
917
- action.action.should == :delete
918
- action.source.should == @df1.schema_id
919
- action.description.should =~ /delete field 'title'/i
947
+ action.action.must_equal :delete
948
+ action.source.must_equal @df1.schema_id
949
+ action.description.must_match /delete field 'title'/i
920
950
  action = @modification.actions[1]
921
- action.action.should == :rename
922
- action.source.should == @df1.schema_id
923
- action.description.should =~ /rename field 'title' to 'a'/i
951
+ action.action.must_equal :rename
952
+ action.source.must_equal @df1.schema_id
953
+ action.description.must_match /rename field 'title' to 'a'/i
924
954
  action = @modification.actions[2]
925
- action.action.should == :rename
926
- action.source.should == @df1.schema_id
927
- action.description.should =~ /rename field 'title' to 'b'/i
955
+ action.action.must_equal :rename
956
+ action.source.must_equal @df1.schema_id
957
+ action.description.must_match /rename field 'title' to 'b'/i
928
958
  end
929
959
 
930
- should "enable fixing the problem by deleting field from schema" do
960
+ it "enable fixing the problem by deleting field from schema" do
931
961
  action = @modification.actions[0]
932
962
  begin
933
963
  S.schema.apply(action)
@@ -936,10 +966,10 @@ class SchemaTest < MiniTest::Spec
936
966
  end
937
967
 
938
968
  m = YAML.load_file(@map_file)
939
- m.key?(@uid).should be_false
969
+ refute m.key?(@uid)
940
970
  end
941
971
 
942
- should "enable fixing the problem by renaming field 'a'" do
972
+ it "enable fixing the problem by renaming field 'a'" do
943
973
  action = @modification.actions[1]
944
974
  begin
945
975
  S.schema.apply(action)
@@ -947,10 +977,10 @@ class SchemaTest < MiniTest::Spec
947
977
  flunk("Renaming of field should have resolved schema error")
948
978
  end
949
979
  m = YAML.load_file(@map_file)
950
- m[@uid].should == @af1.schema_name
980
+ m[@uid].must_equal @af1.schema_name
951
981
  end
952
982
 
953
- should "enable fixing the problem by renaming field 'b'" do
983
+ it "enable fixing the problem by renaming field 'b'" do
954
984
  action = @modification.actions[2]
955
985
  begin
956
986
  S.schema.apply(action)
@@ -958,12 +988,12 @@ class SchemaTest < MiniTest::Spec
958
988
  flunk("Renaming of field should have resolved schema error")
959
989
  end
960
990
  m = YAML.load_file(@map_file)
961
- m[@uid].should == @af2.schema_name
991
+ m[@uid].must_equal @af2.schema_name
962
992
  end
963
993
  end
964
994
 
965
- context "with two fields removed" do
966
- setup do
995
+ describe "-2 fields" do
996
+ before do
967
997
  A.field :a
968
998
  A.field :b
969
999
  A.field :c
@@ -984,7 +1014,7 @@ class SchemaTest < MiniTest::Spec
984
1014
  @modification = e.modification
985
1015
  end
986
1016
  end
987
- should "return list of solutions" do
1017
+ it "return list of solutions" do
988
1018
  # add :a, :b; delete :title, :introduction
989
1019
  # rename :title => :a, :introduction => :b
990
1020
  # rename :introduction => :a, :title => :b
@@ -992,27 +1022,27 @@ class SchemaTest < MiniTest::Spec
992
1022
  # add :a; delete :title; rename :introduction => :b
993
1023
  # add :b; delete :introduction; rename :title => :a
994
1024
  # add :b; delete :title; rename :introduction => :a
995
- @modification.actions.description.should =~ /field 'title'/
996
- @modification.actions.length.should == 4
1025
+ @modification.actions.description.must_match /field 'title'/
1026
+ @modification.actions.length.must_equal 4
997
1027
  action = @modification.actions[0]
998
- action.action.should == :delete
999
- action.source.should == @df1.schema_id
1000
- action.description.should =~ /delete field 'title'/i
1028
+ action.action.must_equal :delete
1029
+ action.source.must_equal @df1.schema_id
1030
+ action.description.must_match /delete field 'title'/i
1001
1031
  action = @modification.actions[1]
1002
- action.action.should == :rename
1003
- action.source.should == @df1.schema_id
1004
- action.description.should =~ /rename field 'title' to 'a'/i
1032
+ action.action.must_equal :rename
1033
+ action.source.must_equal @df1.schema_id
1034
+ action.description.must_match /rename field 'title' to 'a'/i
1005
1035
  action = @modification.actions[2]
1006
- action.action.should == :rename
1007
- action.source.should == @df1.schema_id
1008
- action.description.should =~ /rename field 'title' to 'b'/i
1036
+ action.action.must_equal :rename
1037
+ action.source.must_equal @df1.schema_id
1038
+ action.description.must_match /rename field 'title' to 'b'/i
1009
1039
  action = @modification.actions[3]
1010
- action.action.should == :rename
1011
- action.source.should == @df1.schema_id
1012
- action.description.should =~ /rename field 'title' to 'c'/i
1040
+ action.action.must_equal :rename
1041
+ action.source.must_equal @df1.schema_id
1042
+ action.description.must_match /rename field 'title' to 'c'/i
1013
1043
  end
1014
1044
 
1015
- should "enable fixing the problem by deleting both fields" do
1045
+ it "enable fixing the problem by deleting both fields" do
1016
1046
  action = @modification.actions[0]
1017
1047
  begin
1018
1048
  S.schema.apply(action)
@@ -1028,11 +1058,11 @@ class SchemaTest < MiniTest::Spec
1028
1058
  flunk("Deletion of field should have resolved schema error")
1029
1059
  end
1030
1060
  m = YAML.load_file(@map_file)
1031
- m.key?(@uid1).should be_false
1032
- m.key?(@uid2).should be_false
1061
+ refute m.key?(@uid1)
1062
+ refute m.key?(@uid2)
1033
1063
  end
1034
1064
 
1035
- should "enable fixing the problem by deleting one field and renaming other as 'a'" do
1065
+ it "enable fixing the problem by deleting one field and renaming other as 'a'" do
1036
1066
  action = @modification.actions[0]
1037
1067
  begin
1038
1068
  S.schema.apply(action)
@@ -1048,12 +1078,12 @@ class SchemaTest < MiniTest::Spec
1048
1078
  flunk("Deletion of field should have resolved schema error")
1049
1079
  end
1050
1080
  m = YAML.load_file(@map_file)
1051
- m.key?(@uid1).should be_false
1052
- m.key?(@uid2).should be_true
1053
- m[@uid2].should == @af1.schema_name
1081
+ refute m.key?(@uid1)
1082
+ assert m.key?(@uid2)
1083
+ m[@uid2].must_equal @af1.schema_name
1054
1084
  end
1055
1085
 
1056
- should "enable fixing the problem by renaming one field as 'c' and deleting other" do
1086
+ it "enable fixing the problem by renaming one field as 'c' and deleting other" do
1057
1087
  action = @modification.actions[3]
1058
1088
  begin
1059
1089
  S.schema.apply(action)
@@ -1069,12 +1099,12 @@ class SchemaTest < MiniTest::Spec
1069
1099
  flunk("Deletion of field should have resolved schema error")
1070
1100
  end
1071
1101
  m = YAML.load_file(@map_file)
1072
- m.key?(@uid1).should be_true
1073
- m.key?(@uid2).should be_false
1074
- m[@uid1].should == @af3.schema_name
1102
+ assert m.key?(@uid1)
1103
+ refute m.key?(@uid2)
1104
+ m[@uid1].must_equal @af3.schema_name
1075
1105
  end
1076
1106
 
1077
- should "enable fixing the problem by renaming one field as 'c' and renaming other as 'b'" do
1107
+ it "enable fixing the problem by renaming one field as 'c' and renaming other as 'b'" do
1078
1108
  action = @modification.actions[3]
1079
1109
  begin
1080
1110
  S.schema.apply(action)
@@ -1090,14 +1120,14 @@ class SchemaTest < MiniTest::Spec
1090
1120
  flunk("Deletion of field should have resolved schema error")
1091
1121
  end
1092
1122
  m = YAML.load_file(@map_file)
1093
- m.key?(@uid1).should be_true
1094
- m.key?(@uid2).should be_true
1095
- m[@uid1].should == @af3.schema_name
1096
- m[@uid2].should == @af2.schema_name
1123
+ assert m.key?(@uid1)
1124
+ assert m.key?(@uid2)
1125
+ m[@uid1].must_equal @af3.schema_name
1126
+ m[@uid2].must_equal @af2.schema_name
1097
1127
  end
1098
1128
 
1099
- context "and two boxes removed" do
1100
- setup do
1129
+ describe "-2 boxes" do
1130
+ before do
1101
1131
  @db1 = A.boxes[:posts]
1102
1132
  A.box :added1
1103
1133
  A.box :added2
@@ -1118,7 +1148,7 @@ class SchemaTest < MiniTest::Spec
1118
1148
  @modification = e.modification
1119
1149
  end
1120
1150
  end
1121
- should "enable fixing by deleting both fields and renaming a box" do
1151
+ it "enable fixing by deleting both fields and renaming a box" do
1122
1152
  action = @modification.actions[0]
1123
1153
  begin
1124
1154
  S.schema.apply(action)