validation_examples_matcher 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7883e01d96808f47da22c229ee42a0cf054bdbc2
4
+ data.tar.gz: edf4af4c65455002654798c338b2ffd811d706f6
5
+ SHA512:
6
+ metadata.gz: 4c90c3240a86fe87c46eb14f6d2af3b293f8d0542255e3c7851e55602af61b5abe92dd1b84a98b4ba729701ee54301f61db5d698ea2bf2a9b54de3f2fea20901
7
+ data.tar.gz: badbf6c6b8f23cad31e8e805b863bc9bc9610bfb26a4adc3cc413820898d693d5c03798eb80d7cf6521ef53202e790083d60d594983120533dbc9326ea74dc12
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,61 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - bin/**
6
+ DisplayCopNames: true
7
+
8
+ Lint/AssignmentInCondition:
9
+ Enabled: false
10
+
11
+ Metrics/AbcSize:
12
+ Max: 30
13
+
14
+ Metrics/LineLength:
15
+ Max: 128
16
+
17
+ Metrics/MethodLength:
18
+ Enabled: false
19
+
20
+ Rails/HasAndBelongsToMany:
21
+ Enabled: false
22
+
23
+ Style/AlignParameters:
24
+ Enabled: false
25
+
26
+ Style/AsciiComments:
27
+ Enabled: false
28
+
29
+ Style/BlockComments:
30
+ Enabled: false
31
+
32
+ Style/ClassAndModuleChildren:
33
+ Enabled: false
34
+
35
+ Style/Documentation:
36
+ Enabled: false
37
+
38
+ Style/GuardClause:
39
+ Enabled: false
40
+
41
+ Style/NumericLiterals:
42
+ MinDigits: 10
43
+
44
+ Style/PercentLiteralDelimiters:
45
+ PreferredDelimiters:
46
+ '%': '{}'
47
+
48
+ Style/RedundantSelf:
49
+ Enabled: false
50
+
51
+ Style/SignalException:
52
+ Enabled: false
53
+
54
+ Style/SpaceBeforeFirstArg:
55
+ Enabled: false
56
+
57
+ Style/TrailingCommaInArguments:
58
+ EnforcedStyleForMultiline: comma
59
+
60
+ Style/TrailingCommaInLiteral:
61
+ EnforcedStyleForMultiline: comma
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,13 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-01-25 23:55:46 +0900 using RuboCop version 0.36.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ Style/MutableConstant:
12
+ Exclude:
13
+ - 'lib/validation_examples_matcher/version.rb'
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ - 2.2.4
5
+ - 2.1.8
6
+ - 2.0.0
7
+ env:
8
+ - RSPEC_VERSION=3.0.0
9
+ - RSPEC_VERSION=3.1.0
10
+ - RSPEC_VERSION=3.2.0
11
+ - RSPEC_VERSION=3.3.0
12
+ - RSPEC_VERSION=3.4.0
13
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in validation_examples_matcher.gemspec
4
+ gemspec
5
+
6
+ if rspec_version = ENV['RSPEC_VERSION']
7
+ gem 'rspec', rspec_version
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Hirokazu Nishioka
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # ValidationExamplesMatcher
2
+
3
+ [![Build Status](https://travis-ci.org/nisshiee/validation_examples_matcher.svg?branch=master)](https://travis-ci.org/nisshiee/validation_examples_matcher)
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/validation_examples_matcher`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ TODO: Delete this and the text above, and describe your gem
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'validation_examples_matcher'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install validation_examples_matcher
24
+
25
+ ## Usage
26
+
27
+ TODO: Write usage instructions here
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+
33
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/validation_examples_matcher.
38
+
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
43
+
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: [:rubocop, :spec]
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "validation_examples_matcher"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module ValidationExamplesMatcher
3
+ VERSION = '1.0.0'
4
+ end
@@ -0,0 +1,50 @@
1
+ require 'validation_examples_matcher/version'
2
+ require 'rspec/expectations'
3
+
4
+ module ValidationExamplesMatcher
5
+ def self.register(matchers = RSpec::Matchers)
6
+ matchers.define :be_valid_on do |attr_name|
7
+ match do |model|
8
+ model.send("#{attr_name}=", @value)
9
+ model.valid?(@context)
10
+ end
11
+
12
+ chain :with do |value|
13
+ @value = value
14
+ end
15
+
16
+ chain :on_context do |context|
17
+ @context = context
18
+ end
19
+
20
+ failure_message do |model|
21
+ "expect #{model.class} to be valid, but it is INVALID."
22
+ end
23
+ end
24
+
25
+ matchers.define :be_invalid_on do |attr_name|
26
+ match do |model|
27
+ model.send("#{attr_name}=", @value)
28
+ model.invalid?(@context) && model.errors[attr_name].size >= 1
29
+ end
30
+
31
+ chain :with do |value|
32
+ @value = value
33
+ end
34
+
35
+ chain :on_context do |context|
36
+ @context = context
37
+ end
38
+
39
+ failure_message do |model|
40
+ if model.valid?(@context)
41
+ "expect #{model.class} to be invalid, but it is VALID."
42
+ else
43
+ "expect #{model.class} to have errors on #{attr_name}, but EMPTY."
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ register
50
+ end
@@ -0,0 +1,31 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'validation_examples_matcher/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'validation_examples_matcher'
7
+ spec.version = ValidationExamplesMatcher::VERSION
8
+ spec.authors = ['Hirokazu Nishioka']
9
+ spec.email = ['hiro@nisshiee.org']
10
+
11
+ spec.summary = 'Validation matcher with examples for RSpec'
12
+ spec.description = 'validation_examples_matcher provides rspec matcher testing validations with examples.'
13
+ spec.homepage = 'https://github.com/nisshiee/validation_examples_matcher'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.required_ruby_version = '>= 2.0'
22
+
23
+ spec.add_runtime_dependency 'rspec-expectations', '~> 3.0'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.11'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
+ spec.add_development_dependency 'activemodel', '~> 4.2.5'
29
+ spec.add_development_dependency 'pry-byebug', '~> 3.3.0'
30
+ spec.add_development_dependency 'rubocop', '>= 0.36.0', '< 0.37.0'
31
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: validation_examples_matcher
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Hirokazu Nishioka
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec-expectations
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activemodel
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 4.2.5
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 4.2.5
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.3.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.3.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 0.36.0
104
+ - - "<"
105
+ - !ruby/object:Gem::Version
106
+ version: 0.37.0
107
+ type: :development
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: 0.36.0
114
+ - - "<"
115
+ - !ruby/object:Gem::Version
116
+ version: 0.37.0
117
+ description: validation_examples_matcher provides rspec matcher testing validations
118
+ with examples.
119
+ email:
120
+ - hiro@nisshiee.org
121
+ executables: []
122
+ extensions: []
123
+ extra_rdoc_files: []
124
+ files:
125
+ - ".gitignore"
126
+ - ".rspec"
127
+ - ".rubocop.yml"
128
+ - ".rubocop_todo.yml"
129
+ - ".travis.yml"
130
+ - Gemfile
131
+ - LICENSE.txt
132
+ - README.md
133
+ - Rakefile
134
+ - bin/console
135
+ - bin/setup
136
+ - lib/validation_examples_matcher.rb
137
+ - lib/validation_examples_matcher/version.rb
138
+ - validation_examples_matcher.gemspec
139
+ homepage: https://github.com/nisshiee/validation_examples_matcher
140
+ licenses:
141
+ - MIT
142
+ metadata: {}
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '2.0'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 2.5.1
160
+ signing_key:
161
+ specification_version: 4
162
+ summary: Validation matcher with examples for RSpec
163
+ test_files: []
164
+ has_rdoc: