abstracts 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/abstracts.rb +1 -1
- data/spec/abstract_builder_spec.rb +31 -0
- data/spec/abstract_extensions_object_spec.rb +55 -0
- data/spec/abstract_object_spec.rb +29 -0
- data/spec/spec_helper.rb +1 -1
- metadata +4 -2
- data/spec/abstracts_spec.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa7626c8683ac3d16a8fd9b7709b190a108b112e
|
4
|
+
data.tar.gz: bb43ec11b68629f04646d03145d238a4004640bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00e2809977bfc04ce83143ace6724c7249ceb2c4c5103d5947ecfb455d14aa697646f5babddd43a3744214e1242a57f6da58bd768ac4d8546f118f66bd288fd6
|
7
|
+
data.tar.gz: d151b438f7352f56d5e0005cc48c28bdfa6ad8bb45210ffde36c96cc68626166974c64c03fd909d85050cd8e927f2f715f9e6b69b49633f12058cd8876d32c9f
|
data/lib/abstracts.rb
CHANGED
@@ -44,7 +44,7 @@ module Abstract
|
|
44
44
|
|
45
45
|
# Define attribute writers to Abstract::Builder instance according to
|
46
46
|
# existing accessors of Abstract::Object instance
|
47
|
-
# @param object [
|
47
|
+
# @param object [String] - Abstract::Object.class.name
|
48
48
|
# @return [Abstract::Builder] - builder object
|
49
49
|
def initialize(object)
|
50
50
|
@object = Class.const_get(object).new
|
@@ -0,0 +1,31 @@
|
|
1
|
+
describe 'Abstract::Builder class' do
|
2
|
+
before do
|
3
|
+
class FooObject < Abstract::Object
|
4
|
+
@attrs = %i[foo bar]
|
5
|
+
end
|
6
|
+
|
7
|
+
class FooBuilder < Abstract::Builder
|
8
|
+
@build_class = 'FooObject'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context '.build' do
|
13
|
+
it 'expected to respond to build' do
|
14
|
+
expect(FooBuilder.respond_to?(:build)).to eq true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'subclass.build' do
|
19
|
+
it 'expected to return an instance of a class defined by @build_class' do
|
20
|
+
expect(FooBuilder.build).to be_an_instance_of FooObject
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'subclass.new' do
|
25
|
+
it 'expected to return object which responds to attr_writers defined by @attrs' do
|
26
|
+
FooObject.new.attrs.each do |attr|
|
27
|
+
expect(FooBuilder.new('FooObject').respond_to?("#{attr}=")).to eq true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
describe 'Abstract::Extensions::Object module' do
|
2
|
+
before do
|
3
|
+
Object.include Abstract::Extensions::Object
|
4
|
+
end
|
5
|
+
|
6
|
+
context '.blank?' do
|
7
|
+
context 'when self = String.new' do
|
8
|
+
it 'String.new.blank? expected to be true' do
|
9
|
+
expect(''.blank?).to eq true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when self = Hash.new' do
|
14
|
+
it 'Hash.new.blank? expected to be true' do
|
15
|
+
expect({}.blank?).to eq true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when self = Array.new' do
|
20
|
+
it 'Array.new.blank? expected to be true' do
|
21
|
+
expect([].blank?).to eq true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when self = "foo"' do
|
26
|
+
it 'foo.blank? expected to be false' do
|
27
|
+
expect('foo'.blank?).to eq false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "when self = {qwe: 'rty'}" do
|
32
|
+
it "{foo: 'bar'}.blank? expected to be false" do
|
33
|
+
expect({ foo: 'bar' }.blank?).to eq false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when self = ['foo', 'bar']" do
|
38
|
+
it "['foo', 'bar'].blank? expected to be false" do
|
39
|
+
expect(%w[foo bar].blank?).to eq false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when self = Hash' do
|
44
|
+
it 'Hash.blank? expected to be false' do
|
45
|
+
expect(Hash.blank?).to eq false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when self = String' do
|
50
|
+
it 'String.blank? expected to be false' do
|
51
|
+
expect(String.blank?).to eq false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
describe 'Abstract::Object class' do
|
2
|
+
before do
|
3
|
+
class Foo < Abstract::Object
|
4
|
+
@attrs = %i[foo bar]
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'instance' do
|
9
|
+
it 'expected to respond to :attrs' do
|
10
|
+
expect(Abstract::Object.new.respond_to?(:attrs)).to eq true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'subclass' do
|
15
|
+
it 'expected to respond to :attrs and return list of attrs preset via @attrs' do
|
16
|
+
expect(Foo.new.respond_to?(:attrs)).to eq true
|
17
|
+
expect(Foo.new.attrs).to eq %i[foo bar]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'subclass' do
|
22
|
+
it 'expected to respond to each of attr_accessors preset via @attrs' do
|
23
|
+
Foo.new.attrs.each do |attr_accessor|
|
24
|
+
expect(Foo.new.respond_to?(attr_accessor)).to eq true
|
25
|
+
expect(Foo.new.respond_to?("#{attr_accessor}=")).to eq true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require_relative '../lib/abstracts.rb'
|
1
|
+
require_relative File.expand_path('../abstracts/lib/abstracts.rb')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abstracts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vsevolod Suzdaltsev
|
@@ -17,7 +17,9 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/abstracts.rb
|
20
|
-
- spec/
|
20
|
+
- spec/abstract_builder_spec.rb
|
21
|
+
- spec/abstract_extensions_object_spec.rb
|
22
|
+
- spec/abstract_object_spec.rb
|
21
23
|
- spec/spec_helper.rb
|
22
24
|
homepage: http://rubygems.org/gems/abstracts
|
23
25
|
licenses:
|
data/spec/abstracts_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
describe '.blank?' do
|
2
|
-
before do
|
3
|
-
Object.include Abstract::Extensions::Object
|
4
|
-
end
|
5
|
-
|
6
|
-
context 'when self = String.new' do
|
7
|
-
it 'String.new.blank? expected to be true' do
|
8
|
-
expect(''.blank?).to eq true
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'when self = Hash.new' do
|
13
|
-
it 'Hash.new.blank? expected to be true' do
|
14
|
-
expect({}.blank?).to eq true
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'when self = Array.new' do
|
19
|
-
it 'Array.new.blank? expected to be true' do
|
20
|
-
expect([].blank?).to eq true
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'when self = "foo"' do
|
25
|
-
it 'foo.blank? expected to be false' do
|
26
|
-
expect('foo'.blank?).to eq false
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "when self = {qwe: 'rty'}" do
|
31
|
-
it "{foo: 'bar'}.blank? expected to be false" do
|
32
|
-
expect({ foo: 'bar' }.blank?).to eq false
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "when self = ['foo', 'bar']" do
|
37
|
-
it "['foo', 'bar'].blank? expected to be false" do
|
38
|
-
expect(%w[foo bar].blank?).to eq false
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'when self = Hash' do
|
43
|
-
it 'Hash.blank? expected to be false' do
|
44
|
-
expect(Hash.blank?).to eq false
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'when self = String' do
|
49
|
-
it 'String.blank? expected to be false' do
|
50
|
-
expect(String.blank?).to eq false
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|