motion-support 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,93 @@
1
+ class ConcernTest
2
+ module Baz
3
+ extend MotionSupport::Concern
4
+
5
+ module ClassMethods
6
+ def baz
7
+ "baz"
8
+ end
9
+
10
+ def included_ran=(value)
11
+ @@included_ran = value
12
+ end
13
+
14
+ def included_ran
15
+ @@included_ran
16
+ end
17
+ end
18
+
19
+ included do
20
+ self.included_ran = true
21
+ end
22
+
23
+ def baz
24
+ "baz"
25
+ end
26
+ end
27
+
28
+ module Bar
29
+ extend MotionSupport::Concern
30
+
31
+ include Baz
32
+
33
+ def bar
34
+ "bar"
35
+ end
36
+
37
+ def baz
38
+ "bar+" + super
39
+ end
40
+ end
41
+
42
+ module Foo
43
+ extend MotionSupport::Concern
44
+
45
+ include Bar, Baz
46
+ end
47
+ end
48
+
49
+ describe "Concern" do
50
+ before do
51
+ @klass = Class.new
52
+ end
53
+
54
+ it "should be included normally" do
55
+ @klass.send(:include, ConcernTest::Baz)
56
+ @klass.new.baz.should == "baz"
57
+ @klass.included_modules.include?(ConcernTest::Baz).should.be.true
58
+
59
+ @klass.send(:include, ConcernTest::Baz)
60
+ @klass.new.baz.should == "baz"
61
+ @klass.included_modules.include?(ConcernTest::Baz).should.be.true
62
+ end
63
+
64
+ it "should extend class methods" do
65
+ @klass.send(:include, ConcernTest::Baz)
66
+ @klass.baz.should == "baz"
67
+ (class << @klass; self.included_modules; end)[0].should == ConcernTest::Baz::ClassMethods
68
+ end
69
+
70
+ it "should include instance methods" do
71
+ @klass.send(:include, ConcernTest::Baz)
72
+ @klass.new.baz.should == "baz"
73
+ @klass.included_modules.include?(ConcernTest::Baz).should.be.true
74
+ end
75
+
76
+ it "should run included block" do
77
+ @klass.send(:include, ConcernTest::Baz)
78
+ @klass.included_ran.should.be.true
79
+ end
80
+
81
+ it "should meet dependencies" do
82
+ @klass.send(:include, ConcernTest::Bar)
83
+ @klass.new.bar.should == "bar"
84
+ @klass.new.baz.should == "bar+baz"
85
+ @klass.baz.should == "baz"
86
+ @klass.included_modules.include?(ConcernTest::Bar).should.be.true
87
+ end
88
+
89
+ it "should meet dependencies with multiple modules" do
90
+ @klass.send(:include, ConcernTest::Foo)
91
+ @klass.included_modules[0..2].should == [ConcernTest::Foo, ConcernTest::Bar, ConcernTest::Baz]
92
+ end
93
+ end
@@ -0,0 +1,9 @@
1
+ describe "Kernel" do
2
+ describe "class_eval" do
3
+ it "should delegate to singleton class" do
4
+ o = Object.new
5
+ class << o; @x = 1; end
6
+ o.class_eval { @x }.should == 1
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-11 00:00:00.000000000 Z
12
+ date: 2013-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: motion-require
@@ -69,6 +69,8 @@ files:
69
69
  - examples/Inflector/resources/Default-568h@2x.png
70
70
  - examples/Inflector/spec/main_spec.rb
71
71
  - lib/motion-support.rb
72
+ - lib/motion-support/callbacks.rb
73
+ - lib/motion-support/concern.rb
72
74
  - lib/motion-support/core_ext.rb
73
75
  - lib/motion-support/core_ext/array.rb
74
76
  - lib/motion-support/core_ext/class.rb
@@ -82,9 +84,13 @@ files:
82
84
  - lib/motion-support/core_ext/time.rb
83
85
  - lib/motion-support/inflector.rb
84
86
  - motion-support.gemspec
87
+ - motion/_stdlib/array.rb
85
88
  - motion/_stdlib/cgi.rb
86
89
  - motion/_stdlib/date.rb
90
+ - motion/_stdlib/enumerable.rb
87
91
  - motion/_stdlib/time.rb
92
+ - motion/callbacks.rb
93
+ - motion/concern.rb
88
94
  - motion/core_ext/array.rb
89
95
  - motion/core_ext/array/access.rb
90
96
  - motion/core_ext/array/conversions.rb
@@ -108,6 +114,7 @@ files:
108
114
  - motion/core_ext/integer/inflections.rb
109
115
  - motion/core_ext/integer/multiple.rb
110
116
  - motion/core_ext/integer/time.rb
117
+ - motion/core_ext/kernel/singleton_class.rb
111
118
  - motion/core_ext/metaclass.rb
112
119
  - motion/core_ext/module/aliasing.rb
113
120
  - motion/core_ext/module/anonymous.rb
@@ -155,6 +162,8 @@ files:
155
162
  - motion/version.rb
156
163
  - spec/motion-support/_helpers/constantize_test_cases.rb
157
164
  - spec/motion-support/_helpers/inflector_test_cases.rb
165
+ - spec/motion-support/callback_spec.rb
166
+ - spec/motion-support/concern_spec.rb
158
167
  - spec/motion-support/core_ext/array/access_spec.rb
159
168
  - spec/motion-support/core_ext/array/conversion_spec.rb
160
169
  - spec/motion-support/core_ext/array/extract_options_spec.rb
@@ -176,6 +185,7 @@ files:
176
185
  - spec/motion-support/core_ext/hash/slice_spec.rb
177
186
  - spec/motion-support/core_ext/integer/inflection_spec.rb
178
187
  - spec/motion-support/core_ext/integer/multiple_spec.rb
188
+ - spec/motion-support/core_ext/kernel/singleton_class_spec.rb
179
189
  - spec/motion-support/core_ext/metaclass_spec.rb
180
190
  - spec/motion-support/core_ext/module/aliasing_spec.rb
181
191
  - spec/motion-support/core_ext/module/anonymous_spec.rb
@@ -230,7 +240,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
230
240
  version: '0'
231
241
  segments:
232
242
  - 0
233
- hash: -3381102909433523794
243
+ hash: 1534794484317908353
234
244
  required_rubygems_version: !ruby/object:Gem::Requirement
235
245
  none: false
236
246
  requirements:
@@ -239,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
249
  version: '0'
240
250
  segments:
241
251
  - 0
242
- hash: -3381102909433523794
252
+ hash: 1534794484317908353
243
253
  requirements: []
244
254
  rubyforge_project:
245
255
  rubygems_version: 1.8.25
@@ -249,6 +259,8 @@ summary: Commonly useful extensions to the standard library for RubyMotion
249
259
  test_files:
250
260
  - spec/motion-support/_helpers/constantize_test_cases.rb
251
261
  - spec/motion-support/_helpers/inflector_test_cases.rb
262
+ - spec/motion-support/callback_spec.rb
263
+ - spec/motion-support/concern_spec.rb
252
264
  - spec/motion-support/core_ext/array/access_spec.rb
253
265
  - spec/motion-support/core_ext/array/conversion_spec.rb
254
266
  - spec/motion-support/core_ext/array/extract_options_spec.rb
@@ -270,6 +282,7 @@ test_files:
270
282
  - spec/motion-support/core_ext/hash/slice_spec.rb
271
283
  - spec/motion-support/core_ext/integer/inflection_spec.rb
272
284
  - spec/motion-support/core_ext/integer/multiple_spec.rb
285
+ - spec/motion-support/core_ext/kernel/singleton_class_spec.rb
273
286
  - spec/motion-support/core_ext/metaclass_spec.rb
274
287
  - spec/motion-support/core_ext/module/aliasing_spec.rb
275
288
  - spec/motion-support/core_ext/module/anonymous_spec.rb