acts_as_acts_as 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -1,3 +1,5 @@
1
+ require 'acts_as_acts_as/requirements'
2
+
1
3
  # Methods available _at the same level as_ examples, including methods that
2
4
  # themselves define examples, before, and after blocks
3
5
  module ActsAsActsAs::GroupMacros
@@ -22,17 +24,19 @@ module ActsAsActsAs::GroupMacros
22
24
  # end
23
25
  def acts_as(acts_as_method, &block)
24
26
  # Now use our new object to let the block build up requirements
25
- collector = ActsAsActsAs::RequirementsCollector.new
27
+ collector = ActsAsActsAs::Requirements::Collector.new
28
+ verifier = ActsAsActsAs::Requirements::Verifier.new(acts_as_method)
29
+
30
+ extend ActsAsActsAs::Requirements::Collector::Context
31
+
26
32
  yield collector
27
33
 
28
34
 
29
35
  describe "Acts As Plugin #{acts_as_method}" do
30
-
31
- verifier.verify_requirements(acts_as_method, collector)
36
+ verifier.verify_requirements(collector)
32
37
  end
33
38
 
34
39
  before(:all) do
35
-
36
40
  ActsAsBillable::BillableObjects.classes_using_billing = []
37
41
 
38
42
  @valid_model = tableless_model(
@@ -49,7 +53,6 @@ module ActsAsActsAs::GroupMacros
49
53
 
50
54
  @valid_model_with_table = temp_model(@model_opts)
51
55
  @valid_model_with_table.send(acts_as_method)
52
-
53
56
  end
54
57
 
55
58
  after(:all) do
@@ -37,9 +37,9 @@ class ActsAsActsAs::Requirements::Collector
37
37
  all.inject({}) { |h, c| h.merge(c.requirements) }
38
38
  end
39
39
 
40
- class Context
40
+ module Context
41
41
  [:require_methods, :require_columns, :define_methods, :define_class_methods].each do |x|
42
- define_method x { |*args| [x, args] }
42
+ define_method(x) { |*args| [x, args] }
43
43
  end
44
44
  end
45
45
 
@@ -1,26 +1,31 @@
1
1
  class ActsAsActsAs::Requirements::Verifier
2
2
 
3
3
  attr_accessor :acts_as_method
4
+ include ActsAsActsAs::Macros
4
5
 
5
6
  def initialize(acts_as_method)
6
7
  @acts_as_method = acts_as_method
7
8
  end
8
9
 
9
10
  def verify_requirements(collector)
11
+ verifier = self
12
+ acts_as_method = self.acts_as_method
10
13
  collector.all.each do |c|
11
14
  describe "with options: #{c.options.inspect}" do
12
15
  c.requirements.each_pair do |method, args|
13
- send(method, acts_as_method, c.options, c.requirements, *args)
16
+ verifier.send(method, c.options, c.requirements, *args)
14
17
  end
15
18
  end
16
19
  end
17
20
  end
18
21
 
19
22
  def require_methods(options, reqs, *methods)
23
+ verifier = self
24
+ acts_as_method = @acts_as_method
20
25
  describe 'required methods' do
21
26
  methods.each do |meth|
22
27
  it "#{meth} must be defined in caller" do
23
- mod = tableless_model(
28
+ mod = verifier.tableless_model(
24
29
  :columns => reqs[:require_methods],
25
30
  :methods => reqs[:require_methods].reject { |rm| rm == meth }
26
31
  )
@@ -31,10 +36,12 @@ class ActsAsActsAs::Requirements::Verifier
31
36
  end
32
37
 
33
38
  def require_columns(options, reqs, *columns)
39
+ verifier = self
40
+ acts_as_method = @acts_as_method
34
41
  describe 'required columns' do
35
42
  columns.each do |c|
36
43
  it "#{c[0]} must be defined as column in caller" do
37
- m = tableless_model(
44
+ m = verifier.tableless_model(
38
45
  :columns => reqs[:require_columns].reject { |rc| rc == c },
39
46
  :methods => reqs[:require_methods]
40
47
  )
@@ -42,11 +49,11 @@ class ActsAsActsAs::Requirements::Verifier
42
49
  end
43
50
 
44
51
  it "#{c[0]} must be of type #{c[1]}" do
45
- goodm = tableless_model(
52
+ goodm = verifier.tableless_model(
46
53
  :columns => reqs[:require_columns],
47
54
  :methods => reqs[:require_methods]
48
55
  )
49
- badm = tableless_model(
56
+ badm = verifier.tableless_model(
50
57
  :columns => reqs[:require_columns].map { |rc| (rc != c) ? rc : [rc[0], :badcoltype]},
51
58
  :methods => reqs[:require_methods]
52
59
  )
@@ -58,10 +65,12 @@ class ActsAsActsAs::Requirements::Verifier
58
65
  end
59
66
 
60
67
  def define_methods(options, reqs, *methods)
68
+ verifier = self
69
+ acts_as_method = @acts_as_method
61
70
  describe 'defined methods' do
62
71
  methods.each do |meth|
63
72
  it "#{meth} method is defined automatically" do
64
- mod = tableless_model(
73
+ mod = verifier.tableless_model(
65
74
  :columns => reqs[:require_columns],
66
75
  :methods => reqs[:require_methods]
67
76
  )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_acts_as
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - phinze
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-11 00:00:00 -06:00
12
+ date: 2010-02-03 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency