descendants_describable 0.0.7 → 1.0.0

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: 75e1789e4082b1a6239f9bad3fb497729c83bc08
4
- data.tar.gz: c08b66a1c6d403021970aafc5ec179514b911582
3
+ metadata.gz: bc589770060e65c44af39c504e7ae4ce78a92eaa
4
+ data.tar.gz: 5c25a8058d40a279bdbafa4378a697f0a18ed4ef
5
5
  SHA512:
6
- metadata.gz: 8277354cf0644d64455e0ec8f8cee4ffb4194418c185bca4aa43d59382329357bf3f468ab6d95eca8e169665ea896cb9879c6ac1fff2d7132e7cd4859b9ac148
7
- data.tar.gz: 995a75860c2d8855682339b9b84d63acb3c55120642a2b8e45518b30f8da74d6701d42d69782a2a1b4f03bafb3087a173033403a1ab2af2cd35fb2c9014926cc
6
+ metadata.gz: d0943831d705e1e240e410c791a49ea32883f88387ca18279c4b3ea7512c81f83a73307d7fcc424495eb8ceabc251fedde35dcb01d98b052f6a93dc594e184be
7
+ data.tar.gz: 41e6fc75531d440ce5ee376815c432209fc01076f31c333665a295b9eadf2c5bf985d2abe0a8c010eed716edbb718470bf665862b2b02a9c102608125cdc9197
@@ -17,7 +17,7 @@ module DescendantsDescribable
17
17
 
18
18
  attr_accessor :new_class
19
19
 
20
- def initialize(parent, description_module, description_proc)
20
+ def initialize(parent, description_module, description_proc = -> {})
21
21
  @common_modules = []
22
22
  @descendant_names = []
23
23
  @parent = parent
@@ -1,3 +1,3 @@
1
1
  module DescendantsDescribable
2
- VERSION = "0.0.7"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -16,44 +16,45 @@ module Models
16
16
  end
17
17
  end
18
18
 
19
+ # in your model
19
20
  class Model < ActiveRecord::Base
20
21
  include DescendantsDescribable
22
+ end
21
23
 
22
- describe_descendants_with(Models::Descriptors) do
23
- walks_like_a_duck do
24
- type :badger
25
- type :hadger do
26
- is_a_witch
27
- end
24
+ # in config/initializers/#{name_of_model}}.rb
25
+ Model.describe_descendants_with(Models::Descriptors) do
26
+ walks_like_a_duck do
27
+ type :badger
28
+ type :hadger do
29
+ is_a_witch
30
+ end
28
31
 
29
- floats_like_a_duck do
30
- type :tadger
31
- end
32
+ floats_like_a_duck do
33
+ type :tadger
34
+ end
32
35
 
33
- is_a_witch do
34
- type :madger
35
- end
36
+ is_a_witch do
37
+ type :madger
36
38
  end
39
+ end
37
40
 
38
- talks_like_a_duck do
39
- type :fadger
41
+ talks_like_a_duck do
42
+ type :fadger
40
43
 
41
- floats_like_a_duck do
42
- type :ladger do
43
- is_a_witch
44
- end
45
- type :tadger
44
+ floats_like_a_duck do
45
+ type :ladger do
46
+ is_a_witch
46
47
  end
48
+ type :tadger
47
49
  end
48
50
  end
49
51
  end
50
52
 
51
53
  describe DescendantsDescribable do
52
-
53
54
  describe '.type - for subclass generation' do
54
55
  it 'creates new subclass of each type' do
55
56
  [Badger, Hadger, Fadger, Ladger, Tadger].each do |klass|
56
- expect(klass < Model).to be_true
57
+ expect(klass < Model).to be_truthy
57
58
  end
58
59
  end
59
60
  end
@@ -63,19 +64,19 @@ describe DescendantsDescribable do
63
64
  it { should respond_to(:is_a_witch) }
64
65
 
65
66
  it 'includes module into new class' do
66
- expect(Badger < Models::Descriptors::WalksLikeADuck).to be_true
67
- expect(Hadger < Models::Descriptors::IsAWitch).to be_true
68
- expect(Fadger < Models::Descriptors::TalksLikeADuck).to be_true
69
- expect(Ladger < Models::Descriptors::FloatsLikeADuck).to be_true
70
- expect(Ladger < Models::Descriptors::TalksLikeADuck).to be_true
71
- expect(Ladger < Models::Descriptors::IsAWitch).to be_true
72
-
73
- expect(Tadger < Models::Descriptors::FloatsLikeADuck).to be_true
74
- expect(Tadger < Models::Descriptors::WalksLikeADuck).to be_true
75
- expect(Tadger < Models::Descriptors::TalksLikeADuck).to be_true
76
-
77
- expect(Madger < Models::Descriptors::WalksLikeADuck).to be_true
78
- expect(Madger < Models::Descriptors::IsAWitch).to be_true
67
+ expect(Badger < Models::Descriptors::WalksLikeADuck).to be_truthy
68
+ expect(Hadger < Models::Descriptors::IsAWitch).to be_truthy
69
+ expect(Fadger < Models::Descriptors::TalksLikeADuck).to be_truthy
70
+ expect(Ladger < Models::Descriptors::FloatsLikeADuck).to be_truthy
71
+ expect(Ladger < Models::Descriptors::TalksLikeADuck).to be_truthy
72
+ expect(Ladger < Models::Descriptors::IsAWitch).to be_truthy
73
+
74
+ expect(Tadger < Models::Descriptors::FloatsLikeADuck).to be_truthy
75
+ expect(Tadger < Models::Descriptors::WalksLikeADuck).to be_truthy
76
+ expect(Tadger < Models::Descriptors::TalksLikeADuck).to be_truthy
77
+
78
+ expect(Madger < Models::Descriptors::WalksLikeADuck).to be_truthy
79
+ expect(Madger < Models::Descriptors::IsAWitch).to be_truthy
79
80
  end
80
81
  end
81
82
  end
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,4 @@ require 'descendants_describable'
7
7
 
8
8
  RSpec.configure do |config|
9
9
  # some (optional) config here
10
-
11
- config.treat_symbols_as_metadata_keys_with_true_values = true
12
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: descendants_describable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - winfred