rspec-dry-struct 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2204be691bba0119560391dbda536e133682f330
4
- data.tar.gz: 2f36a683797f2a995ab1ab3da2c4d6533e16703c
3
+ metadata.gz: 1ff418f131c19ff9a7733f3a2df8102e9d3cf31c
4
+ data.tar.gz: dd0a772bc326b195a4e682abe31ba0c4453ecb8a
5
5
  SHA512:
6
- metadata.gz: 11d8781c607b31cfe06c8a9c22133ece6035ee2d4be79963dc3d78fbfc2d54d90ba2fb92b6e8fde2d78166be3462066f739f79eb600f9a58f4c7b6dc1d95030f
7
- data.tar.gz: 1c61dd71108a9b98553159552b68f92afce0c8508af7c8821c7404988c1a3fd322fb93898d96275ce08b6d9370aa5a0180e334348ba0758ee0bd4b8872158dba
6
+ metadata.gz: f905aa87bfe132182d771b3cc18df1b0acc048482c732503739e3a8a2807d7a024ac51b45dd85cd2c59393813188129981f694e08a1170b03ad51b117102d722
7
+ data.tar.gz: fefe5550e4455f1d44ee0a79cb0808c1d4fb0cd68c49a49566aea49b8f3e6fc77b93fa3f05892f57b3af085d0c76de87344a1d08dcf40c75361f80b61dde65bb
data/README.md CHANGED
@@ -28,6 +28,10 @@ Or install it yourself as:
28
28
 
29
29
  $ gem install rspec-dry-struct
30
30
 
31
+ If you don't have gem autoload, require matcher in your `spec_helper.rb`:
32
+
33
+ require 'rspec/dry/struct'
34
+
31
35
  ## Usage
32
36
 
33
37
  Let's assume you have such struct:
@@ -10,7 +10,32 @@ module RSpec
10
10
  end
11
11
 
12
12
  def matches?(actual)
13
- actual.schema[@attr_name] == @attr_type
13
+ @actual = actual
14
+ @actual_attribute = actual.schema[@attr_name]
15
+ @actual_attribute == @attr_type
16
+ end
17
+
18
+ def description
19
+ "have #{@attr_name.inspect} attribute"
20
+ end
21
+
22
+ def failure_message
23
+ return attr_not_found_message(@actual) if @actual_attribute.nil?
24
+ attr_type_mismatch_message(@actual)
25
+ end
26
+
27
+ private
28
+
29
+ def attr_not_found_message(actual)
30
+ "#{expected_message(actual)}, but it was not found"
31
+ end
32
+
33
+ def attr_type_mismatch_message(actual)
34
+ "#{expected_message(actual)}, but type is wrong"
35
+ end
36
+
37
+ def expected_message(actual)
38
+ "expected #{actual} to have #{@attr_name.inspect} attribute"
14
39
  end
15
40
  end
16
41
  end
@@ -1,7 +1,7 @@
1
- module Rspec
1
+ module RSpec
2
2
  module Dry
3
3
  module Struct
4
- VERSION = '0.1.0'.freeze
4
+ VERSION = '0.1.1'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -5,7 +5,7 @@ require 'rspec/dry/struct/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'rspec-dry-struct'
8
- spec.version = Rspec::Dry::Struct::VERSION
8
+ spec.version = RSpec::Dry::Struct::VERSION
9
9
  spec.authors = ['Sergey Kukunin']
10
10
  spec.email = ['sergey.kukunin@gmail.com']
11
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-dry-struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Kukunin