rspec-dry-struct 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -0
- data/README.md +14 -1
- data/lib/rspec/dry/struct.rb +2 -2
- data/lib/rspec/dry/struct/matcher.rb +10 -2
- data/lib/rspec/dry/struct/version.rb +1 -1
- data/rspec-dry-struct.gemspec +2 -1
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e966dabb162b838c6921e31ce9e2cbd44a72a4d0
|
4
|
+
data.tar.gz: daac80eadaead1f814f3dcda8819edc92df9f995
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29c9e8766c758e4766e86b7f484ce0bddabe0b23ab89eccb19b139b240dc1fe83df652e5895032df9bb57867066955a578ae1992092efe2248c949ec83f37b9f
|
7
|
+
data.tar.gz: d4f385816b1a78247af796816d8db90894294eabc8faae071d631a3edba78fc0a785b7f4c9721f487616c489139d660a59d04445af15dec70b6ad00b385eb251
|
data/.rubocop.yml
ADDED
data/README.md
CHANGED
@@ -50,7 +50,20 @@ require 'spec_helper'
|
|
50
50
|
RSpec.describe PersonName do
|
51
51
|
describe 'attributes' do
|
52
52
|
subject { described_class }
|
53
|
-
it { is_expected.to
|
53
|
+
it { is_expected.to have_attribute(:first_name) }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
or with specific attribute type
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
require 'spec_helper'
|
62
|
+
|
63
|
+
RSpec.describe PersonName do
|
64
|
+
describe 'attributes' do
|
65
|
+
subject { described_class }
|
66
|
+
it { is_expected.to have_attribute(:first_name, Types::Strict::String) }
|
54
67
|
end
|
55
68
|
end
|
56
69
|
```
|
data/lib/rspec/dry/struct.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'rspec/core'
|
2
|
-
require 'dry/
|
2
|
+
require 'dry/struct'
|
3
3
|
require 'rspec/dry/struct/version'
|
4
4
|
require 'rspec/dry/struct/matcher'
|
5
5
|
|
6
6
|
module RSpec
|
7
7
|
module Dry
|
8
8
|
module Struct
|
9
|
-
def have_attribute(name, type)
|
9
|
+
def have_attribute(name, type = nil) # rubocop:disable Style/PredicateName
|
10
10
|
Matcher.new(name, type)
|
11
11
|
end
|
12
12
|
end
|
@@ -4,7 +4,7 @@ module RSpec
|
|
4
4
|
class Matcher
|
5
5
|
attr_reader :attr_name, :attr_type
|
6
6
|
|
7
|
-
def initialize(attr_name, attr_type)
|
7
|
+
def initialize(attr_name, attr_type = nil)
|
8
8
|
@attr_name = attr_name
|
9
9
|
@attr_type = attr_type
|
10
10
|
end
|
@@ -12,7 +12,7 @@ module RSpec
|
|
12
12
|
def matches?(actual)
|
13
13
|
@actual = actual
|
14
14
|
@actual_attribute = actual.schema[@attr_name]
|
15
|
-
|
15
|
+
attr_present? && correct_attr_type?
|
16
16
|
end
|
17
17
|
|
18
18
|
def description
|
@@ -26,6 +26,14 @@ module RSpec
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
+
def attr_present?
|
30
|
+
!@actual_attribute.nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
def correct_attr_type?
|
34
|
+
@attr_type.nil? || @actual_attribute == @attr_type
|
35
|
+
end
|
36
|
+
|
29
37
|
def attr_not_found_message(actual)
|
30
38
|
"#{expected_message(actual)}, but it was not found"
|
31
39
|
end
|
data/rspec-dry-struct.gemspec
CHANGED
@@ -21,8 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
23
|
spec.add_runtime_dependency 'rspec', '>= 3.0'
|
24
|
-
spec.add_runtime_dependency 'dry-
|
24
|
+
spec.add_runtime_dependency 'dry-struct', '~> 0.1.1'
|
25
25
|
|
26
26
|
spec.add_development_dependency 'bundler', '~> 1.11'
|
27
|
+
spec.add_development_dependency 'rspec-its', '~> 1.2'
|
27
28
|
spec.add_development_dependency 'rake', '~> 10.0'
|
28
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-dry-struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Kukunin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: dry-
|
28
|
+
name: dry-struct
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.1.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.1.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-its
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.2'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,6 +89,7 @@ extra_rdoc_files: []
|
|
75
89
|
files:
|
76
90
|
- ".gitignore"
|
77
91
|
- ".rspec"
|
92
|
+
- ".rubocop.yml"
|
78
93
|
- ".travis.yml"
|
79
94
|
- Gemfile
|
80
95
|
- LICENSE
|