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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ff418f131c19ff9a7733f3a2df8102e9d3cf31c
4
- data.tar.gz: dd0a772bc326b195a4e682abe31ba0c4453ecb8a
3
+ metadata.gz: e966dabb162b838c6921e31ce9e2cbd44a72a4d0
4
+ data.tar.gz: daac80eadaead1f814f3dcda8819edc92df9f995
5
5
  SHA512:
6
- metadata.gz: f905aa87bfe132182d771b3cc18df1b0acc048482c732503739e3a8a2807d7a024ac51b45dd85cd2c59393813188129981f694e08a1170b03ad51b117102d722
7
- data.tar.gz: fefe5550e4455f1d44ee0a79cb0808c1d4fb0cd68c49a49566aea49b8f3e6fc77b93fa3f05892f57b3af085d0c76de87344a1d08dcf40c75361f80b61dde65bb
6
+ metadata.gz: 29c9e8766c758e4766e86b7f484ce0bddabe0b23ab89eccb19b139b240dc1fe83df652e5895032df9bb57867066955a578ae1992092efe2248c949ec83f37b9f
7
+ data.tar.gz: d4f385816b1a78247af796816d8db90894294eabc8faae071d631a3edba78fc0a785b7f4c9721f487616c489139d660a59d04445af15dec70b6ad00b385eb251
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ require: rubocop-rspec
2
+
3
+ Metrics/LineLength:
4
+ Max: 95
5
+
6
+ Style/Documentation:
7
+ Enabled: false
8
+
9
+ Style/SpaceInsideHashLiteralBraces:
10
+ EnforcedStyle: no_space
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 have_attributes(:first_name, Types::Strict::String) }
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
  ```
@@ -1,12 +1,12 @@
1
1
  require 'rspec/core'
2
- require 'dry/types'
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
- @actual_attribute == @attr_type
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
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Dry
3
3
  module Struct
4
- VERSION = '0.1.1'.freeze
4
+ VERSION = '0.2.1'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -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-types', '~> 0.8'
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.1.1
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: 2016-08-09 00:00:00.000000000 Z
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-types
28
+ name: dry-struct
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.8'
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: '0.8'
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