spec_cat 3.1.2 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -4
- data/lib/spec_cat/matchers/validate_with.rb +42 -0
- data/lib/spec_cat.rb +2 -4
- metadata +17 -3
- data/lib/spec_cat/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f39b86a596e4d375238f09202811d33f74e292ba
|
4
|
+
data.tar.gz: 21040578db305d8fc22ed531eefd24f8f4f17464
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7486a32be7d8991138eaced1679223b7f70352dcbd27f32c98a6b2ea4c0a56ae4c43814c19f062f9cf89357e35eddad4a902c269ce6f889e2dc94943aef576f1
|
7
|
+
data.tar.gz: 8798f747ae652eb7f1e4f73e2de5f1e00e2c7e52e6b1d23625492117f467d36b5d8b97813cff37ad0996285020ddf4d40a7950a28b5625cf7b3d75fae820d1bb
|
data/README.md
CHANGED
@@ -51,7 +51,7 @@ It also writes a .tmp file to replace the old ground truth if it's gone stale.
|
|
51
51
|
|
52
52
|
e.g. #foo produces a gnarly string too nasty to copy and paste into spec code.
|
53
53
|
|
54
|
-
expect(
|
54
|
+
expect(foo).to eql_file('spec/truth/foo.json')
|
55
55
|
|
56
56
|
... if it fails for a valid change, you can just....
|
57
57
|
|
@@ -68,7 +68,7 @@ If you use this, you should add `*.tmp` to your .gitignore.
|
|
68
68
|
`have_a_spec` will ensure that any given path has a corresponding spec file to
|
69
69
|
help ensure that you have good coverage.
|
70
70
|
|
71
|
-
expect(
|
71
|
+
expect('app/controllers/application_controller.rb').to have_a_spec
|
72
72
|
|
73
73
|
... is a good thing to write right after you integrate RSpec.
|
74
74
|
|
@@ -80,14 +80,14 @@ Here's an example coverage spec...
|
|
80
80
|
|
81
81
|
`include_module` makes it easy to spec concern inclusion.
|
82
82
|
|
83
|
-
it(
|
83
|
+
it('is taggable') { is_expected.to include_module(Taggable) }
|
84
84
|
|
85
85
|
### pass_rubocop
|
86
86
|
|
87
87
|
`pass_rubcop` just executes [Rubocop](http://batsov.com/rubocop/) and passes or fails
|
88
88
|
based on it's exit status.
|
89
89
|
|
90
|
-
it(
|
90
|
+
it('passes Rubocop') { is_expected.to pass_rubocop }
|
91
91
|
|
92
92
|
## Rake Tasks
|
93
93
|
|
@@ -116,9 +116,15 @@ specs pass.
|
|
116
116
|
|
117
117
|
## Version History
|
118
118
|
|
119
|
+
* 3.1.3 - Adding `validate_with` matcher from https://gist.github.com/Bartuz/98abc9301adbc883b510
|
119
120
|
* 3.1.0 - Rubocop integration
|
120
121
|
* 3.0.0 - RSpec 3 supported
|
121
122
|
* 1.0.3 - Last version with RSpec 2.x support
|
123
|
+
|
124
|
+
# Credits
|
125
|
+
|
126
|
+
Thanks to [Filip Bartuzi](https://github.com/Bartuz) and [Otavio Medeiros](https://github.com/otaviomedeiros)
|
127
|
+
for publishing their gists of the `validate_with` matcher!
|
122
128
|
|
123
129
|
|
124
130
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# From https://gist.github.com/Bartuz/98abc9301adbc883b510
|
2
|
+
#
|
3
|
+
# RSpec matcher for validates_with.
|
4
|
+
# https://gist.github.com/2032846
|
5
|
+
# Usage:
|
6
|
+
#
|
7
|
+
# describe User do
|
8
|
+
# it { should validate_with CustomValidator }
|
9
|
+
# end
|
10
|
+
|
11
|
+
RSpec::Matchers.define :validate_with do |expected_validator|
|
12
|
+
match do |subject|
|
13
|
+
@validator = subject.class.validators.find do |validator|
|
14
|
+
validator.class == expected_validator
|
15
|
+
end
|
16
|
+
@validator.present? && options_matching?
|
17
|
+
end
|
18
|
+
|
19
|
+
def options_matching?
|
20
|
+
if @options.present?
|
21
|
+
@options.all? { |option| @validator.options[option] == @options[option] }
|
22
|
+
else
|
23
|
+
true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
chain :with_options do |options|
|
28
|
+
@options = options
|
29
|
+
end
|
30
|
+
|
31
|
+
description do
|
32
|
+
'RSpec matcher for validates_with'
|
33
|
+
end
|
34
|
+
|
35
|
+
failure_message do
|
36
|
+
"expected to validate with #{validator}#{@options.present? ? (' with options ' + @options) : ''}"
|
37
|
+
end
|
38
|
+
|
39
|
+
failure_message_when_negated do
|
40
|
+
"do not expected to validate with #{validator}#{@options.present? ? (' with options ' + @options) : ''}"
|
41
|
+
end
|
42
|
+
end
|
data/lib/spec_cat.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
|
3
|
-
require '
|
4
|
-
|
5
|
-
require 'spec_cat/matchers/include_module'
|
6
|
-
require 'spec_cat/matchers/pass_rubocop'
|
3
|
+
require 'require_all'
|
4
|
+
require_rel 'spec_cat/matchers'
|
7
5
|
|
8
6
|
require 'spec_cat/railtie' if defined?(Rails)
|
9
7
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spec_cat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich Humphrey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: require_all
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: rails
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,8 +120,8 @@ files:
|
|
106
120
|
- lib/spec_cat/matchers/have_a_spec.rb
|
107
121
|
- lib/spec_cat/matchers/include_module.rb
|
108
122
|
- lib/spec_cat/matchers/pass_rubocop.rb
|
123
|
+
- lib/spec_cat/matchers/validate_with.rb
|
109
124
|
- lib/spec_cat/railtie.rb
|
110
|
-
- lib/spec_cat/version.rb
|
111
125
|
- lib/tasks/spec_cat.rake
|
112
126
|
homepage: https://github.com/schrodingersbox/spec_cat
|
113
127
|
licenses:
|
data/lib/spec_cat/version.rb
DELETED