rock_motive 1.0.0.beta2 → 1.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46b1ff2834674f5f77f2369fa56a304ba0773f62
4
- data.tar.gz: 2dd15660e48457ed98ce78ec92f769c00b8b4332
3
+ metadata.gz: 4b543ff62271096cca68859c3078476e6d258a88
4
+ data.tar.gz: 49daeb058eaa556f659afcaefd673f29115a2044
5
5
  SHA512:
6
- metadata.gz: c0ef47e53df9e2d22c62a2e7150606534e51ce5fc911891f249311333eff005b011df668f1a809963183aaf84c5d6d75ba70e5f91d67c47a22b5954c1a18804c
7
- data.tar.gz: 29d883f5063f637959e0902059eafa15bab6636a588e6bd7c095bff12b2a6a6e852d1e43bc64a3c477fdbb61e211d2ff74e383ef52d8da8e87abdace08b9c182
6
+ metadata.gz: b0b41603b71be41d8bf227ce390ff128a3e8456d1fe1129cc7278e27c2b0f773eba3a3399706c35b135c266faf2026fd343ac94e634cfa29769fb63ffbcaf475
7
+ data.tar.gz: 93b6b53633ce71cf438b469755b2f2ff3ee918612e5d0fe6283d74939941e7cf2f9ee0528e1fb0c61d7b27889995ad206e96ec91cd52fd67604569fdc159d4c5
@@ -9,6 +9,33 @@ class RockMotive::Context
9
9
  new.execute(*args)
10
10
  end
11
11
 
12
+ def scopes
13
+ @scopes ||= name.to_s.split('::').inject(['']) do |scopes, ns|
14
+ scopes + ["#{scopes.last}::#{ns}"]
15
+ end
16
+ end
17
+
18
+ def scope(*nss)
19
+ nss.each do |ns|
20
+ scopes.push(ns.to_s.classify)
21
+ end
22
+ end
23
+
24
+ def actors
25
+ @actors ||= []
26
+ end
27
+
28
+ def get_role_by_name(name)
29
+ role_name = name.to_s.classify
30
+
31
+ const = scopes.inject(nil) do |c, ns|
32
+ name = "#{ns}::#{role_name}"
33
+ (name.safe_constantize || "#{name}Role".safe_constantize) || c
34
+ end
35
+
36
+ (const.is_a?(Module) && !const.is_a?(Class)) ? const : nil
37
+ end
38
+
12
39
  private
13
40
 
14
41
  def method_added(method_name)
@@ -29,11 +56,16 @@ class RockMotive::Context
29
56
  end
30
57
 
31
58
  def roles_by_execute_method
59
+ @actors = []
60
+
32
61
  for_args = []
33
62
  for_keywords = {}
34
63
 
35
64
  execute_method.parameters.each do |param|
36
65
  type, name = *param
66
+
67
+ @actors << name.to_s.to_sym
68
+
37
69
  case type
38
70
  when :req, :opt
39
71
  for_args << get_role_by_name(name)
@@ -45,14 +77,6 @@ class RockMotive::Context
45
77
  [for_args, for_keywords]
46
78
  end
47
79
 
48
- def get_role_by_name(name)
49
- role_name = name.to_s.classify
50
-
51
- const = role_name.safe_constantize || "#{role_name}Role".safe_constantize
52
-
53
- (const.is_a?(Module) && !const.is_a?(Class)) ? const : nil
54
- end
55
-
56
80
  def override_execute_method(for_args, for_keywords)
57
81
  method_definition = ['def execute_with_roles(*args, &block)']
58
82
  method_definition << 'kv = args.last'
@@ -1,3 +1,3 @@
1
1
  module RockMotive
2
- VERSION = '1.0.0.beta2'
2
+ VERSION = '1.0.0.beta3'
3
3
  end
@@ -0,0 +1,5 @@
1
+ module Fake::PigeonRole
2
+ def fly
3
+ true
4
+ end
5
+ end
@@ -2081,5 +2081,800 @@ RockMotive::ContextTest: test_#execute_with_extend
2081
2081
   (0.0ms) begin transaction
2082
2082
  --------------------------
2083
2083
  RockMotiveTest: test_truth
2084
+ --------------------------
2085
+  (0.0ms) rollback transaction
2086
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
2087
+  (0.1ms) begin transaction
2088
+ ------------------------------------------------------------
2089
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2090
+ ------------------------------------------------------------
2091
+  (0.1ms) rollback transaction
2092
+  (0.0ms) begin transaction
2093
+ --------------------------------------------------
2094
+ RockMotive::ContextTest: test_#execute_with_extend
2095
+ --------------------------------------------------
2096
+  (0.1ms) rollback transaction
2097
+  (0.0ms) begin transaction
2098
+ --------------------------------------
2099
+ RockMotive::ContextTest: test_.execute
2100
+ --------------------------------------
2101
+  (0.0ms) rollback transaction
2102
+  (0.1ms) begin transaction
2103
+ ----------------------------------------------------
2104
+ RockMotive::ContextTest: test_.execute_with_override
2105
+ ----------------------------------------------------
2106
+  (0.0ms) rollback transaction
2107
+  (0.0ms) begin transaction
2108
+ ------------------------------------------------------
2109
+ RockMotive::ContextTest: test_#execute_with_unextended
2110
+ ------------------------------------------------------
2111
+  (0.0ms) rollback transaction
2112
+  (0.0ms) begin transaction
2113
+ --------------------------
2114
+ RockMotiveTest: test_truth
2115
+ --------------------------
2116
+  (0.0ms) rollback transaction
2117
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2118
+  (0.1ms) begin transaction
2119
+ ----------------------------------------------------
2120
+ RockMotive::ContextTest: test_.execute_with_override
2121
+ ----------------------------------------------------
2122
+  (0.1ms) rollback transaction
2123
+  (0.0ms) begin transaction
2124
+ ------------------------------------------------------------
2125
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2126
+ ------------------------------------------------------------
2127
+  (0.1ms) rollback transaction
2128
+  (0.0ms) begin transaction
2129
+ --------------------------------------
2130
+ RockMotive::ContextTest: test_.execute
2131
+ --------------------------------------
2132
+  (0.0ms) rollback transaction
2133
+  (0.1ms) begin transaction
2134
+ ------------------------------------------------------
2135
+ RockMotive::ContextTest: test_#execute_with_unextended
2136
+ ------------------------------------------------------
2137
+  (0.1ms) rollback transaction
2138
+  (0.0ms) begin transaction
2139
+ --------------------------------------------------
2140
+ RockMotive::ContextTest: test_#execute_with_extend
2141
+ --------------------------------------------------
2142
+  (0.1ms) rollback transaction
2143
+  (0.0ms) begin transaction
2144
+ --------------------------
2145
+ RockMotiveTest: test_truth
2146
+ --------------------------
2147
+  (0.0ms) rollback transaction
2148
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2149
+  (0.1ms) begin transaction
2150
+ ------------------------------------------------------
2151
+ RockMotive::ContextTest: test_#execute_with_unextended
2152
+ ------------------------------------------------------
2153
+  (0.1ms) rollback transaction
2154
+  (0.1ms) begin transaction
2155
+ --------------------------------------
2156
+ RockMotive::ContextTest: test_.execute
2157
+ --------------------------------------
2158
+  (0.0ms) rollback transaction
2159
+  (0.1ms) begin transaction
2160
+ ----------------------------------------------------
2161
+ RockMotive::ContextTest: test_.execute_with_override
2162
+ ----------------------------------------------------
2163
+  (0.1ms) rollback transaction
2164
+  (0.0ms) begin transaction
2165
+ --------------------------------------------------
2166
+ RockMotive::ContextTest: test_#execute_with_extend
2167
+ --------------------------------------------------
2168
+  (0.1ms) rollback transaction
2169
+  (0.1ms) begin transaction
2170
+ ------------------------------------------------------------
2171
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2172
+ ------------------------------------------------------------
2173
+  (0.1ms) rollback transaction
2174
+  (0.0ms) begin transaction
2175
+ --------------------------
2176
+ RockMotiveTest: test_truth
2177
+ --------------------------
2178
+  (0.0ms) rollback transaction
2179
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2180
+  (0.1ms) begin transaction
2181
+ --------------------------
2182
+ RockMotiveTest: test_truth
2183
+ --------------------------
2184
+  (0.0ms) rollback transaction
2185
+  (0.0ms) begin transaction
2186
+ --------------------------------------
2187
+ RockMotive::ContextTest: test_.execute
2188
+ --------------------------------------
2189
+  (0.0ms) rollback transaction
2190
+  (0.0ms) begin transaction
2191
+ ------------------------------------------------------------
2192
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2193
+ ------------------------------------------------------------
2194
+  (0.1ms) rollback transaction
2195
+  (0.0ms) begin transaction
2196
+ ------------------------------------------------------
2197
+ RockMotive::ContextTest: test_#execute_with_unextended
2198
+ ------------------------------------------------------
2199
+  (0.1ms) rollback transaction
2200
+  (0.0ms) begin transaction
2201
+ ----------------------------------------------------
2202
+ RockMotive::ContextTest: test_.execute_with_override
2203
+ ----------------------------------------------------
2204
+  (0.0ms) rollback transaction
2205
+  (0.0ms) begin transaction
2206
+ --------------------------------------------------
2207
+ RockMotive::ContextTest: test_#execute_with_extend
2208
+ --------------------------------------------------
2209
+  (0.1ms) rollback transaction
2210
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2211
+  (0.1ms) begin transaction
2212
+ --------------------------
2213
+ RockMotiveTest: test_truth
2214
+ --------------------------
2215
+  (0.1ms) rollback transaction
2216
+  (0.0ms) begin transaction
2217
+ ------------------------------------------------------------
2218
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2219
+ ------------------------------------------------------------
2220
+  (0.1ms) rollback transaction
2221
+  (0.1ms) begin transaction
2222
+ -------------------------------------
2223
+ RockMotive::ContextTest: test_.scopes
2224
+ -------------------------------------
2225
+  (0.0ms) rollback transaction
2226
+  (0.1ms) begin transaction
2227
+ --------------------------------------
2228
+ RockMotive::ContextTest: test_.execute
2229
+ --------------------------------------
2230
+  (0.1ms) rollback transaction
2231
+  (0.0ms) begin transaction
2232
+ --------------------------------------------------
2233
+ RockMotive::ContextTest: test_#execute_with_extend
2234
+ --------------------------------------------------
2235
+  (0.1ms) rollback transaction
2236
+  (0.1ms) begin transaction
2237
+ ----------------------------------------------------
2238
+ RockMotive::ContextTest: test_.execute_with_override
2239
+ ----------------------------------------------------
2240
+  (0.0ms) rollback transaction
2241
+  (0.1ms) begin transaction
2242
+ ------------------------------------------------------
2243
+ RockMotive::ContextTest: test_#execute_with_unextended
2244
+ ------------------------------------------------------
2245
+  (0.1ms) rollback transaction
2246
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2247
+  (0.1ms) begin transaction
2248
+ --------------------------------------------------
2249
+ RockMotive::ContextTest: test_#execute_with_extend
2250
+ --------------------------------------------------
2251
+  (0.1ms) rollback transaction
2252
+  (0.1ms) begin transaction
2253
+ ------------------------------------------------------------
2254
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2255
+ ------------------------------------------------------------
2256
+  (0.2ms) rollback transaction
2257
+  (0.1ms) begin transaction
2258
+ -------------------------------------
2259
+ RockMotive::ContextTest: test_.scopes
2260
+ -------------------------------------
2261
+  (0.1ms) rollback transaction
2262
+  (0.0ms) begin transaction
2263
+ ------------------------------------------------------
2264
+ RockMotive::ContextTest: test_#execute_with_unextended
2265
+ ------------------------------------------------------
2266
+  (0.0ms) rollback transaction
2267
+  (0.1ms) begin transaction
2268
+ ----------------------------------------------------
2269
+ RockMotive::ContextTest: test_.execute_with_override
2270
+ ----------------------------------------------------
2271
+  (0.0ms) rollback transaction
2272
+  (0.0ms) begin transaction
2273
+ --------------------------------------
2274
+ RockMotive::ContextTest: test_.execute
2275
+ --------------------------------------
2276
+  (0.1ms) rollback transaction
2277
+  (0.0ms) begin transaction
2278
+ --------------------------
2279
+ RockMotiveTest: test_truth
2280
+ --------------------------
2281
+  (0.0ms) rollback transaction
2282
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2283
+  (0.1ms) begin transaction
2284
+ ------------------------------------------------------------
2285
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2286
+ ------------------------------------------------------------
2287
+  (0.1ms) rollback transaction
2288
+  (0.0ms) begin transaction
2289
+ --------------------------------------------------
2290
+ RockMotive::ContextTest: test_#execute_with_extend
2291
+ --------------------------------------------------
2292
+  (0.1ms) rollback transaction
2293
+  (0.0ms) begin transaction
2294
+ -------------------------------------
2295
+ RockMotive::ContextTest: test_.scopes
2296
+ -------------------------------------
2297
+  (0.1ms) rollback transaction
2298
+  (0.1ms) begin transaction
2299
+ -------------------------------------------------
2300
+ RockMotive::ContextTest: test_#execute_with_scope
2301
+ -------------------------------------------------
2302
+  (0.0ms) rollback transaction
2303
+  (0.0ms) begin transaction
2304
+ --------------------------------------
2305
+ RockMotive::ContextTest: test_.execute
2306
+ --------------------------------------
2307
+  (0.0ms) rollback transaction
2308
+  (0.0ms) begin transaction
2309
+ ----------------------------------------------------
2310
+ RockMotive::ContextTest: test_.execute_with_override
2311
+ ----------------------------------------------------
2312
+  (0.0ms) rollback transaction
2313
+  (0.0ms) begin transaction
2314
+ ------------------------------------------------------
2315
+ RockMotive::ContextTest: test_#execute_with_unextended
2316
+ ------------------------------------------------------
2317
+  (0.0ms) rollback transaction
2318
+  (0.0ms) begin transaction
2319
+ --------------------------
2320
+ RockMotiveTest: test_truth
2321
+ --------------------------
2322
+  (0.0ms) rollback transaction
2323
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2324
+  (0.1ms) begin transaction
2325
+ --------------------------
2326
+ RockMotiveTest: test_truth
2327
+ --------------------------
2328
+  (0.0ms) rollback transaction
2329
+  (0.0ms) begin transaction
2330
+ -------------------------------------------------
2331
+ RockMotive::ContextTest: test_#execute_with_scope
2332
+ -------------------------------------------------
2333
+  (0.0ms) rollback transaction
2334
+  (0.0ms) begin transaction
2335
+ ------------------------------------------------------------
2336
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2337
+ ------------------------------------------------------------
2338
+  (0.1ms) rollback transaction
2339
+  (0.0ms) begin transaction
2340
+ ------------------------------------------------------
2341
+ RockMotive::ContextTest: test_#execute_with_unextended
2342
+ ------------------------------------------------------
2343
+  (0.1ms) rollback transaction
2344
+  (0.0ms) begin transaction
2345
+ -------------------------------------
2346
+ RockMotive::ContextTest: test_.scopes
2347
+ -------------------------------------
2348
+  (0.1ms) rollback transaction
2349
+  (0.0ms) begin transaction
2350
+ --------------------------------------
2351
+ RockMotive::ContextTest: test_.execute
2352
+ --------------------------------------
2353
+  (0.0ms) rollback transaction
2354
+  (0.0ms) begin transaction
2355
+ ----------------------------------------------------
2356
+ RockMotive::ContextTest: test_.execute_with_override
2357
+ ----------------------------------------------------
2358
+  (0.1ms) rollback transaction
2359
+  (0.1ms) begin transaction
2360
+ --------------------------------------------------
2361
+ RockMotive::ContextTest: test_#execute_with_extend
2362
+ --------------------------------------------------
2363
+  (0.1ms) rollback transaction
2364
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2365
+  (0.1ms) begin transaction
2366
+ --------------------------
2367
+ RockMotiveTest: test_truth
2368
+ --------------------------
2369
+  (0.0ms) rollback transaction
2370
+  (0.0ms) begin transaction
2371
+ --------------------------------------------------
2372
+ RockMotive::ContextTest: test_#execute_with_extend
2373
+ --------------------------------------------------
2374
+  (0.1ms) rollback transaction
2375
+  (0.0ms) begin transaction
2376
+ ----------------------------------------------------
2377
+ RockMotive::ContextTest: test_.execute_with_override
2378
+ ----------------------------------------------------
2379
+  (0.1ms) rollback transaction
2380
+  (0.0ms) begin transaction
2381
+ -------------------------------------------------
2382
+ RockMotive::ContextTest: test_#execute_with_scope
2383
+ -------------------------------------------------
2384
+  (0.1ms) rollback transaction
2385
+  (0.0ms) begin transaction
2386
+ -------------------------------------
2387
+ RockMotive::ContextTest: test_.scopes
2388
+ -------------------------------------
2389
+  (0.0ms) rollback transaction
2390
+  (0.0ms) begin transaction
2391
+ ------------------------------------------------------
2392
+ RockMotive::ContextTest: test_#execute_with_unextended
2393
+ ------------------------------------------------------
2394
+  (0.1ms) rollback transaction
2395
+  (0.0ms) begin transaction
2396
+ ------------------------------------------------------------
2397
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2398
+ ------------------------------------------------------------
2399
+  (0.1ms) rollback transaction
2400
+  (0.0ms) begin transaction
2401
+ --------------------------------------
2402
+ RockMotive::ContextTest: test_.execute
2403
+ --------------------------------------
2404
+  (0.0ms) rollback transaction
2405
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2406
+  (0.1ms) begin transaction
2407
+ ----------------------------------------------------
2408
+ RockMotive::ContextTest: test_.execute_with_override
2409
+ ----------------------------------------------------
2410
+  (0.1ms) rollback transaction
2411
+  (0.0ms) begin transaction
2412
+ ------------------------------------------------------------
2413
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2414
+ ------------------------------------------------------------
2415
+  (0.1ms) rollback transaction
2416
+  (0.1ms) begin transaction
2417
+ --------------------------------------
2418
+ RockMotive::ContextTest: test_.execute
2419
+ --------------------------------------
2420
+  (0.1ms) rollback transaction
2421
+  (0.1ms) begin transaction
2422
+ -------------------------------------------------
2423
+ RockMotive::ContextTest: test_#execute_with_scope
2424
+ -------------------------------------------------
2425
+  (0.0ms) rollback transaction
2426
+  (0.0ms) begin transaction
2427
+ ------------------------------------------------------
2428
+ RockMotive::ContextTest: test_#execute_with_unextended
2429
+ ------------------------------------------------------
2430
+  (0.0ms) rollback transaction
2431
+  (0.0ms) begin transaction
2432
+ --------------------------------------------------
2433
+ RockMotive::ContextTest: test_#execute_with_extend
2434
+ --------------------------------------------------
2435
+  (0.1ms) rollback transaction
2436
+  (0.0ms) begin transaction
2437
+ -------------------------------------
2438
+ RockMotive::ContextTest: test_.scopes
2439
+ -------------------------------------
2440
+  (0.1ms) rollback transaction
2441
+  (0.0ms) begin transaction
2442
+ --------------------------
2443
+ RockMotiveTest: test_truth
2444
+ --------------------------
2445
+  (0.0ms) rollback transaction
2446
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2447
+  (0.1ms) begin transaction
2448
+ --------------------------
2449
+ RockMotiveTest: test_truth
2450
+ --------------------------
2451
+  (0.0ms) rollback transaction
2452
+  (0.0ms) begin transaction
2453
+ --------------------------------------------------
2454
+ RockMotive::ContextTest: test_#execute_with_extend
2455
+ --------------------------------------------------
2456
+  (0.1ms) rollback transaction
2457
+  (0.0ms) begin transaction
2458
+ ------------------------------------------------------------
2459
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2460
+ ------------------------------------------------------------
2461
+  (0.1ms) rollback transaction
2462
+  (0.0ms) begin transaction
2463
+ -------------------------------------------------
2464
+ RockMotive::ContextTest: test_#execute_with_scope
2465
+ -------------------------------------------------
2466
+  (0.0ms) rollback transaction
2467
+  (0.0ms) begin transaction
2468
+ -------------------------------------
2469
+ RockMotive::ContextTest: test_.scopes
2470
+ -------------------------------------
2471
+  (0.0ms) rollback transaction
2472
+  (0.0ms) begin transaction
2473
+ ------------------------------------------------------
2474
+ RockMotive::ContextTest: test_#execute_with_unextended
2475
+ ------------------------------------------------------
2476
+  (0.0ms) rollback transaction
2477
+  (0.0ms) begin transaction
2478
+ ----------------------------------------------------
2479
+ RockMotive::ContextTest: test_.execute_with_override
2480
+ ----------------------------------------------------
2481
+  (0.0ms) rollback transaction
2482
+  (0.0ms) begin transaction
2483
+ --------------------------------------
2484
+ RockMotive::ContextTest: test_.execute
2485
+ --------------------------------------
2486
+  (0.0ms) rollback transaction
2487
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2488
+  (0.1ms) begin transaction
2489
+ ----------------------------------------------------
2490
+ RockMotive::ContextTest: test_.execute_with_override
2491
+ ----------------------------------------------------
2492
+  (0.1ms) rollback transaction
2493
+  (0.0ms) begin transaction
2494
+ --------------------------------------------------
2495
+ RockMotive::ContextTest: test_#execute_with_extend
2496
+ --------------------------------------------------
2497
+  (0.1ms) rollback transaction
2498
+  (0.0ms) begin transaction
2499
+ --------------------------------------
2500
+ RockMotive::ContextTest: test_.execute
2501
+ --------------------------------------
2502
+  (0.1ms) rollback transaction
2503
+  (0.0ms) begin transaction
2504
+ ------------------------------------------------------
2505
+ RockMotive::ContextTest: test_#execute_with_unextended
2506
+ ------------------------------------------------------
2507
+  (0.1ms) rollback transaction
2508
+  (0.1ms) begin transaction
2509
+ -------------------------------------
2510
+ RockMotive::ContextTest: test_.scopes
2511
+ -------------------------------------
2512
+  (0.1ms) rollback transaction
2513
+  (0.0ms) begin transaction
2514
+ ------------------------------------------------------------
2515
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2516
+ ------------------------------------------------------------
2517
+  (0.1ms) rollback transaction
2518
+  (0.0ms) begin transaction
2519
+ -------------------------------------------------
2520
+ RockMotive::ContextTest: test_#execute_with_scope
2521
+ -------------------------------------------------
2522
+  (0.0ms) rollback transaction
2523
+  (0.1ms) begin transaction
2524
+ --------------------------
2525
+ RockMotiveTest: test_truth
2526
+ --------------------------
2527
+  (0.0ms) rollback transaction
2528
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2529
+  (0.1ms) begin transaction
2530
+ --------------------------
2531
+ RockMotiveTest: test_truth
2532
+ --------------------------
2533
+  (0.1ms) rollback transaction
2534
+  (0.0ms) begin transaction
2535
+ -------------------------------------
2536
+ RockMotive::ContextTest: test_.scopes
2537
+ -------------------------------------
2538
+  (0.1ms) rollback transaction
2539
+  (0.0ms) begin transaction
2540
+ ------------------------------------------------------
2541
+ RockMotive::ContextTest: test_#execute_with_unextended
2542
+ ------------------------------------------------------
2543
+  (0.1ms) rollback transaction
2544
+  (0.0ms) begin transaction
2545
+ --------------------------------------------------
2546
+ RockMotive::ContextTest: test_#execute_with_extend
2547
+ --------------------------------------------------
2548
+  (0.1ms) rollback transaction
2549
+  (0.0ms) begin transaction
2550
+ --------------------------------------
2551
+ RockMotive::ContextTest: test_.execute
2552
+ --------------------------------------
2553
+  (0.1ms) rollback transaction
2554
+  (0.1ms) begin transaction
2555
+ ------------------------------------------------------------
2556
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2557
+ ------------------------------------------------------------
2558
+  (0.1ms) rollback transaction
2559
+  (0.0ms) begin transaction
2560
+ -------------------------------------------------
2561
+ RockMotive::ContextTest: test_#execute_with_scope
2562
+ -------------------------------------------------
2563
+  (0.1ms) rollback transaction
2564
+  (0.0ms) begin transaction
2565
+ ----------------------------------------------------
2566
+ RockMotive::ContextTest: test_.execute_with_override
2567
+ ----------------------------------------------------
2568
+  (0.0ms) rollback transaction
2569
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2570
+  (0.1ms) begin transaction
2571
+ --------------------------
2572
+ RockMotiveTest: test_truth
2573
+ --------------------------
2574
+  (0.0ms) rollback transaction
2575
+  (0.0ms) begin transaction
2576
+ --------------------------------------
2577
+ RockMotive::ContextTest: test_.execute
2578
+ --------------------------------------
2579
+  (0.0ms) rollback transaction
2580
+  (0.0ms) begin transaction
2581
+ ------------------------------------------------------------
2582
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2583
+ ------------------------------------------------------------
2584
+  (0.1ms) rollback transaction
2585
+  (0.0ms) begin transaction
2586
+ --------------------------------------------------
2587
+ RockMotive::ContextTest: test_#execute_with_extend
2588
+ --------------------------------------------------
2589
+  (0.1ms) rollback transaction
2590
+  (0.0ms) begin transaction
2591
+ -------------------------------------
2592
+ RockMotive::ContextTest: test_.scopes
2593
+ -------------------------------------
2594
+  (0.0ms) rollback transaction
2595
+  (0.1ms) begin transaction
2596
+ -------------------------------------------------
2597
+ RockMotive::ContextTest: test_#execute_with_scope
2598
+ -------------------------------------------------
2599
+  (0.1ms) rollback transaction
2600
+  (0.1ms) begin transaction
2601
+ ----------------------------------------------------
2602
+ RockMotive::ContextTest: test_.execute_with_override
2603
+ ----------------------------------------------------
2604
+  (0.0ms) rollback transaction
2605
+  (0.1ms) begin transaction
2606
+ ------------------------------------------------------
2607
+ RockMotive::ContextTest: test_#execute_with_unextended
2608
+ ------------------------------------------------------
2609
+  (0.1ms) rollback transaction
2610
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
2611
+  (0.1ms) begin transaction
2612
+ --------------------------
2613
+ RockMotiveTest: test_truth
2614
+ --------------------------
2615
+  (0.0ms) rollback transaction
2616
+  (0.0ms) begin transaction
2617
+ -------------------------------------------------
2618
+ RockMotive::ContextTest: test_#execute_with_scope
2619
+ -------------------------------------------------
2620
+  (0.1ms) rollback transaction
2621
+  (0.0ms) begin transaction
2622
+ ------------------------------------------------------
2623
+ RockMotive::ContextTest: test_#execute_with_unextended
2624
+ ------------------------------------------------------
2625
+  (0.1ms) rollback transaction
2626
+  (0.0ms) begin transaction
2627
+ ----------------------------------------------------
2628
+ RockMotive::ContextTest: test_.execute_with_override
2629
+ ----------------------------------------------------
2630
+  (0.0ms) rollback transaction
2631
+  (0.0ms) begin transaction
2632
+ ------------------------------------------------------------
2633
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2634
+ ------------------------------------------------------------
2635
+  (0.1ms) rollback transaction
2636
+  (0.0ms) begin transaction
2637
+ -------------------------------------
2638
+ RockMotive::ContextTest: test_.scopes
2639
+ -------------------------------------
2640
+  (0.0ms) rollback transaction
2641
+  (0.0ms) begin transaction
2642
+ --------------------------------------------------
2643
+ RockMotive::ContextTest: test_#execute_with_extend
2644
+ --------------------------------------------------
2645
+  (0.1ms) rollback transaction
2646
+  (0.1ms) begin transaction
2647
+ --------------------------------------
2648
+ RockMotive::ContextTest: test_.execute
2649
+ --------------------------------------
2650
+  (0.1ms) rollback transaction
2651
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2652
+  (0.1ms) begin transaction
2653
+ -------------------------------------
2654
+ RockMotive::ContextTest: test_.actors
2655
+ -------------------------------------
2656
+  (0.1ms) rollback transaction
2657
+  (0.0ms) begin transaction
2658
+ ----------------------------------------------------
2659
+ RockMotive::ContextTest: test_.execute_with_override
2660
+ ----------------------------------------------------
2661
+  (0.1ms) rollback transaction
2662
+  (0.0ms) begin transaction
2663
+ ------------------------------------------------------
2664
+ RockMotive::ContextTest: test_#execute_with_unextended
2665
+ ------------------------------------------------------
2666
+  (0.1ms) rollback transaction
2667
+  (0.0ms) begin transaction
2668
+ -------------------------------------
2669
+ RockMotive::ContextTest: test_.scopes
2670
+ -------------------------------------
2671
+  (0.1ms) rollback transaction
2672
+  (0.0ms) begin transaction
2673
+ ------------------------------------------------------------
2674
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2675
+ ------------------------------------------------------------
2676
+  (0.1ms) rollback transaction
2677
+  (0.0ms) begin transaction
2678
+ -------------------------------------------------
2679
+ RockMotive::ContextTest: test_#execute_with_scope
2680
+ -------------------------------------------------
2681
+  (0.1ms) rollback transaction
2682
+  (0.0ms) begin transaction
2683
+ --------------------------------------
2684
+ RockMotive::ContextTest: test_.execute
2685
+ --------------------------------------
2686
+  (0.1ms) rollback transaction
2687
+  (0.0ms) begin transaction
2688
+ --------------------------------------------------
2689
+ RockMotive::ContextTest: test_#execute_with_extend
2690
+ --------------------------------------------------
2691
+  (0.1ms) rollback transaction
2692
+  (0.0ms) begin transaction
2693
+ --------------------------
2694
+ RockMotiveTest: test_truth
2695
+ --------------------------
2696
+  (0.0ms) rollback transaction
2697
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2698
+  (0.1ms) begin transaction
2699
+ -------------------------------------------------
2700
+ RockMotive::ContextTest: test_#execute_with_scope
2701
+ -------------------------------------------------
2702
+  (0.1ms) rollback transaction
2703
+  (0.0ms) begin transaction
2704
+ ----------------------------------------------------
2705
+ RockMotive::ContextTest: test_.execute_with_override
2706
+ ----------------------------------------------------
2707
+  (0.0ms) rollback transaction
2708
+  (0.0ms) begin transaction
2709
+ --------------------------------------------------
2710
+ RockMotive::ContextTest: test_#execute_with_extend
2711
+ --------------------------------------------------
2712
+  (0.1ms) rollback transaction
2713
+  (0.0ms) begin transaction
2714
+ ------------------------------------------------------
2715
+ RockMotive::ContextTest: test_#execute_with_unextended
2716
+ ------------------------------------------------------
2717
+  (0.1ms) rollback transaction
2718
+  (0.0ms) begin transaction
2719
+ -------------------------------------
2720
+ RockMotive::ContextTest: test_.scopes
2721
+ -------------------------------------
2722
+  (0.0ms) rollback transaction
2723
+  (0.0ms) begin transaction
2724
+ ------------------------------------------------------------
2725
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2726
+ ------------------------------------------------------------
2727
+  (0.1ms) rollback transaction
2728
+  (0.0ms) begin transaction
2729
+ --------------------------------------
2730
+ RockMotive::ContextTest: test_.execute
2731
+ --------------------------------------
2732
+  (0.0ms) rollback transaction
2733
+  (0.0ms) begin transaction
2734
+ -------------------------------------
2735
+ RockMotive::ContextTest: test_.actors
2736
+ -------------------------------------
2737
+  (0.1ms) rollback transaction
2738
+  (0.1ms) begin transaction
2739
+ --------------------------
2740
+ RockMotiveTest: test_truth
2741
+ --------------------------
2742
+  (0.1ms) rollback transaction
2743
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2744
+  (0.1ms) begin transaction
2745
+ -------------------------------------------------
2746
+ RockMotive::ContextTest: test_#execute_with_scope
2747
+ -------------------------------------------------
2748
+  (0.1ms) rollback transaction
2749
+  (0.1ms) begin transaction
2750
+ ------------------------------------------------------------
2751
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2752
+ ------------------------------------------------------------
2753
+  (0.1ms) rollback transaction
2754
+  (0.1ms) begin transaction
2755
+ --------------------------------------------------
2756
+ RockMotive::ContextTest: test_#execute_with_extend
2757
+ --------------------------------------------------
2758
+  (0.1ms) rollback transaction
2759
+  (0.1ms) begin transaction
2760
+ -------------------------------------
2761
+ RockMotive::ContextTest: test_.scopes
2762
+ -------------------------------------
2763
+  (0.0ms) rollback transaction
2764
+  (0.1ms) begin transaction
2765
+ -------------------------------------
2766
+ RockMotive::ContextTest: test_.actors
2767
+ -------------------------------------
2768
+  (0.1ms) rollback transaction
2769
+  (0.1ms) begin transaction
2770
+ --------------------------------------
2771
+ RockMotive::ContextTest: test_.execute
2772
+ --------------------------------------
2773
+  (0.1ms) rollback transaction
2774
+  (0.0ms) begin transaction
2775
+ ------------------------------------------------------
2776
+ RockMotive::ContextTest: test_#execute_with_unextended
2777
+ ------------------------------------------------------
2778
+  (0.1ms) rollback transaction
2779
+  (0.1ms) begin transaction
2780
+ ----------------------------------------------------
2781
+ RockMotive::ContextTest: test_.execute_with_override
2782
+ ----------------------------------------------------
2783
+  (0.0ms) rollback transaction
2784
+  (0.0ms) begin transaction
2785
+ --------------------------
2786
+ RockMotiveTest: test_truth
2787
+ --------------------------
2788
+  (0.0ms) rollback transaction
2789
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2790
+  (0.1ms) begin transaction
2791
+ --------------------------
2792
+ RockMotiveTest: test_truth
2793
+ --------------------------
2794
+  (0.0ms) rollback transaction
2795
+  (0.0ms) begin transaction
2796
+ --------------------------------------------------
2797
+ RockMotive::ContextTest: test_#execute_with_extend
2798
+ --------------------------------------------------
2799
+  (0.1ms) rollback transaction
2800
+  (0.1ms) begin transaction
2801
+ ----------------------------------------------------
2802
+ RockMotive::ContextTest: test_.execute_with_override
2803
+ ----------------------------------------------------
2804
+  (0.1ms) rollback transaction
2805
+  (0.0ms) begin transaction
2806
+ ------------------------------------------------------------
2807
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2808
+ ------------------------------------------------------------
2809
+  (0.1ms) rollback transaction
2810
+  (0.0ms) begin transaction
2811
+ -------------------------------------------------
2812
+ RockMotive::ContextTest: test_#execute_with_scope
2813
+ -------------------------------------------------
2814
+  (0.1ms) rollback transaction
2815
+  (0.1ms) begin transaction
2816
+ ------------------------------------------------------
2817
+ RockMotive::ContextTest: test_#execute_with_unextended
2818
+ ------------------------------------------------------
2819
+  (0.1ms) rollback transaction
2820
+  (0.0ms) begin transaction
2821
+ --------------------------------------
2822
+ RockMotive::ContextTest: test_.execute
2823
+ --------------------------------------
2824
+  (0.0ms) rollback transaction
2825
+  (0.1ms) begin transaction
2826
+ -------------------------------------
2827
+ RockMotive::ContextTest: test_.actors
2828
+ -------------------------------------
2829
+  (0.1ms) rollback transaction
2830
+  (0.0ms) begin transaction
2831
+ -------------------------------------
2832
+ RockMotive::ContextTest: test_.scopes
2833
+ -------------------------------------
2834
+  (0.1ms) rollback transaction
2835
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
2836
+  (0.1ms) begin transaction
2837
+ --------------------------------------
2838
+ RockMotive::ContextTest: test_.execute
2839
+ --------------------------------------
2840
+  (0.1ms) rollback transaction
2841
+  (0.0ms) begin transaction
2842
+ -------------------------------------------------
2843
+ RockMotive::ContextTest: test_#execute_with_scope
2844
+ -------------------------------------------------
2845
+  (0.1ms) rollback transaction
2846
+  (0.1ms) begin transaction
2847
+ ----------------------------------------------------
2848
+ RockMotive::ContextTest: test_.execute_with_override
2849
+ ----------------------------------------------------
2850
+  (0.0ms) rollback transaction
2851
+  (0.1ms) begin transaction
2852
+ -------------------------------------
2853
+ RockMotive::ContextTest: test_.scopes
2854
+ -------------------------------------
2855
+  (0.0ms) rollback transaction
2856
+  (0.1ms) begin transaction
2857
+ -------------------------------------
2858
+ RockMotive::ContextTest: test_.actors
2859
+ -------------------------------------
2860
+  (0.1ms) rollback transaction
2861
+  (0.0ms) begin transaction
2862
+ --------------------------------------------------
2863
+ RockMotive::ContextTest: test_#execute_with_extend
2864
+ --------------------------------------------------
2865
+  (0.1ms) rollback transaction
2866
+  (0.0ms) begin transaction
2867
+ ------------------------------------------------------------
2868
+ RockMotive::ContextTest: test_#execute_with_keyword_argument
2869
+ ------------------------------------------------------------
2870
+  (0.1ms) rollback transaction
2871
+  (0.0ms) begin transaction
2872
+ ------------------------------------------------------
2873
+ RockMotive::ContextTest: test_#execute_with_unextended
2874
+ ------------------------------------------------------
2875
+  (0.0ms) rollback transaction
2876
+  (0.1ms) begin transaction
2877
+ --------------------------
2878
+ RockMotiveTest: test_truth
2084
2879
  --------------------------
2085
2880
   (0.0ms) rollback transaction
@@ -10,6 +10,18 @@ class RockMotive::ContextTest < ActiveSupport::TestCase
10
10
  assert { context_class_with_override_execute.execute }
11
11
  end
12
12
 
13
+ test '.scopes' do
14
+ context_class.scope 'hoge'
15
+
16
+ assert { RockMotive::Context.scopes.length == 3 }
17
+ assert { context_class.scopes.length == 2 }
18
+ end
19
+
20
+ test '.actors' do
21
+ assert { context_class.actors == [] }
22
+ assert { context_class_with_role.actors == [:pigeon] }
23
+ end
24
+
13
25
  test '#execute with extend' do
14
26
  bird = Bird.new(name: 'hato')
15
27
 
@@ -34,6 +46,14 @@ class RockMotive::ContextTest < ActiveSupport::TestCase
34
46
  assert { bird.singleton_class.ancestors.exclude?(PigeonRole) }
35
47
  end
36
48
 
49
+ test '#execute with scope' do
50
+ bird = Bird.new(name: 'hato')
51
+
52
+ context_class_with_scope.execute(bird)
53
+
54
+ assert { bird.singleton_class.ancestors.exclude?(Fake::PigeonRole) }
55
+ end
56
+
37
57
  private
38
58
 
39
59
  def context_class
@@ -60,6 +80,16 @@ class RockMotive::ContextTest < ActiveSupport::TestCase
60
80
  end
61
81
  end
62
82
 
83
+ def context_class_with_scope
84
+ @context_class_with_scope ||= Class.new(RockMotive::Context) do
85
+ scope 'fake'
86
+
87
+ def execute(pigeon)
88
+ pigeon.fly
89
+ end
90
+ end
91
+ end
92
+
63
93
  # rubocop:disable all
64
94
  def context_class_with_keyword
65
95
  @context_class_with_keyword ||= Class.new(RockMotive::Context) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rock_motive
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Kusano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -171,6 +171,7 @@ files:
171
171
  - test/dummy/app/controllers/application_controller.rb
172
172
  - test/dummy/app/helpers/application_helper.rb
173
173
  - test/dummy/app/models/bird.rb
174
+ - test/dummy/app/roles/fake/pigeon_role.rb
174
175
  - test/dummy/app/roles/pigeon_role.rb
175
176
  - test/dummy/app/views/layouts/application.html.erb
176
177
  - test/dummy/bin/bundle
@@ -238,6 +239,7 @@ test_files:
238
239
  - test/dummy/app/controllers/application_controller.rb
239
240
  - test/dummy/app/helpers/application_helper.rb
240
241
  - test/dummy/app/models/bird.rb
242
+ - test/dummy/app/roles/fake/pigeon_role.rb
241
243
  - test/dummy/app/roles/pigeon_role.rb
242
244
  - test/dummy/app/views/layouts/application.html.erb
243
245
  - test/dummy/bin/bundle