tram-policy 1.0.0 → 1.0.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
- SHA1:
3
- metadata.gz: 54f65bae74cb48be0cc7d481cb3abd8528f43749
4
- data.tar.gz: 4a100e49ec40986bc4f8781304169e6ecd2d5baf
2
+ SHA256:
3
+ metadata.gz: 3d9eceeea7e032619394e2a9c57b3a780031e6716e99115ab4d7f70aaa215730
4
+ data.tar.gz: 39fa500a2789eb528aac666711652ee0c7b9ed3a3a7d9b197333b133e94b17a3
5
5
  SHA512:
6
- metadata.gz: 107d99cdd79742b7ae85b5b1f8783f5eb6114c864cbfb7732251c2a4542261effec81ec171d61dbc0da6787ca576efc581dae43f76f75ef4a16d2d7934edea9f
7
- data.tar.gz: 3dc2b45735369a9097b525b1681ea8dee24ed84675bc8cfde67b1f87394647f345abedd45db4c12d3725d3cd56df8193e70b8c92e5ec62e9e1c14970097c6ee8
6
+ metadata.gz: 0654b385b2dc583a467824fc473e9873408297795fc172ed70313d25ef9a352d34802640e10a8f68e861122dedbc6146678d225c4fff2d60510901a62f30d2e9
7
+ data.tar.gz: c45529180fc6e8d99ab3b071ac3fc886b41bc84bf0b57769ad83ccbe046b0b03ea03d026fc974e6acd842c6e2807219707ea83cfbd258f1b27ea078465d52ba1
data/.travis.yml CHANGED
@@ -8,18 +8,15 @@ script:
8
8
  - bundle exec rubocop
9
9
  rvm:
10
10
  - 2.3.0
11
- - 2.4.0
11
+ - 2.6.2
12
12
  - ruby-head
13
- - jruby-9.1.0.0
14
- - rbx-3
13
+ - jruby-9.2.7.0
14
+ - truffleruby
15
15
  env:
16
16
  global:
17
17
  - JRUBY_OPTS='--dev -J-Xmx1024M'
18
18
  matrix:
19
19
  allow_failures:
20
- - rvm: rbx-3
21
20
  - rvm: ruby-head
22
21
  - rvm: jruby-head
23
- include:
24
- - rvm: jruby-head
25
- before_install: gem install bundler --no-ri --no-rdoc
22
+ - rvm: truffleruby
data/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [1.0.1] - [2019-05-06]
8
+
9
+ ### Added
10
+ - Support of `dry-initializer` v3.0+ (nepalez)
11
+
12
+ ### Fixed
13
+ - Fix be_invalid RSpec matcher if non-policy model is passed (Envek)
14
+ - Disable translation check for non-strings in rspec matcher (Envek)
15
+
7
16
  ## [1.0.0] - [2018-02-17]
8
17
 
9
18
  ### Changed
@@ -191,3 +200,5 @@ This is a first public release (@nepalez, @charlie-wasp, @JewelSam, @sergey-chec
191
200
  [0.3.0]: https://github.com/tram-rb/tram-policy/compare/v0.2.5...v0.3.0
192
201
  [0.3.1]: https://github.com/tram-rb/tram-policy/compare/v0.3.0...v0.3.1
193
202
  [0.4.0]: https://github.com/tram-rb/tram-policy/compare/v0.3.1...v0.4.0
203
+ [1.0.0]: https://github.com/tram-rb/tram-policy/compare/v0.4.0...v1.0.0
204
+ [1.0.1]: https://github.com/tram-rb/tram-policy/compare/v1.0.0...v1.0.1
data/README.md CHANGED
@@ -7,7 +7,6 @@ Policy Object Pattern
7
7
 
8
8
  [![Gem Version][gem-badger]][gem]
9
9
  [![Build Status][travis-badger]][travis]
10
- [![Dependency Status][gemnasium-badger]][gemnasium]
11
10
  [![Inline docs][inch-badger]][inch]
12
11
 
13
12
  ## Intro
@@ -128,7 +127,7 @@ You can change the root scope if you will (this could be useful in libraries):
128
127
 
129
128
  ```ruby
130
129
  class MyGemPolicy < Tram::Policy
131
- scope "mygem", "policies" # inherited by subclasses
130
+ root_scope "mygem", "policies" # inherited by subclasses
132
131
  end
133
132
 
134
133
  class Article::ReadinessPolicy < MyGemPolicy
@@ -338,8 +337,6 @@ The gem is available as open source under the terms of the [MIT License](http://
338
337
  [codeclimate]: https://codeclimate.com/github/tram-rb/tram-policy
339
338
  [gem-badger]: https://img.shields.io/gem/v/tram-policy.svg?style=flat
340
339
  [gem]: https://rubygems.org/gems/tram-policy
341
- [gemnasium-badger]: https://img.shields.io/gemnasium/tram-rb/tram-policy.svg?style=flat
342
- [gemnasium]: https://gemnasium.com/tram-rb/tram-policy
343
340
  [inch-badger]: http://inch-ci.org/github/tram-rb/tram-policy.svg
344
341
  [inch]: https://inch-ci.org/github/tram-rb/tram-policy
345
342
  [travis-badger]: https://img.shields.io/travis/tram-rb/tram-policy/master.svg?style=flat
@@ -17,8 +17,11 @@ RSpec::Matchers.define :be_invalid_at do |**tags|
17
17
 
18
18
  def missed_translations
19
19
  @missed_translations ||= \
20
- errors.flat_map { |rec| rec.values_at(*locales) }
21
- .select { |message| message.start_with? "translation missing" }
20
+ errors
21
+ .flat_map { |rec| rec.values_at(*locales) }
22
+ .select do |message|
23
+ message.is_a?(String) && message.start_with?("translation missing")
24
+ end
22
25
  end
23
26
 
24
27
  def report_errors
@@ -57,10 +60,12 @@ end
57
60
 
58
61
  RSpec::Matchers.define :be_invalid do
59
62
  match do |policy|
63
+ return expect(policy.valid?).to(be_falsey) unless policy.is_a?(Tram::Policy)
60
64
  expect(policy).to be_invalid_at
61
65
  end
62
66
 
63
67
  match_when_negated do |policy|
68
+ return expect(policy.valid?).to(be_truthy) unless policy.is_a?(Tram::Policy)
64
69
  expect(policy).not_to be_invalid_at
65
70
  end
66
71
  end
@@ -46,4 +46,19 @@ RSpec.describe "RSpec support:" do
46
46
  .to raise_error RSpec::Expectations::ExpectationNotMetError
47
47
  end
48
48
  end
49
+
50
+ describe "to be_invalid" do
51
+ subject { double("model") }
52
+
53
+ it "fails with valid non-policy object" do
54
+ allow(subject).to receive(:valid?).and_return(true)
55
+ expect { expect(subject).to be_invalid }
56
+ .to raise_error RSpec::Expectations::ExpectationNotMetError
57
+ end
58
+
59
+ it "passes with invalid non-policy object" do
60
+ allow(subject).to receive(:valid?).and_return(false)
61
+ expect { expect(subject).to be_invalid }.not_to raise_error
62
+ end
63
+ end
49
64
  end
data/tram-policy.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "tram-policy"
3
- gem.version = "1.0.0"
3
+ gem.version = "1.0.1"
4
4
  gem.author = ["Viktor Sokolov (gzigzigzeo)", "Andrew Kozin (nepalez)"]
5
5
  gem.email = "andrew.kozin@gmail.com"
6
6
  gem.homepage = "https://github.com/tram/tram-policy"
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
 
15
15
  gem.required_ruby_version = ">= 2.3"
16
16
 
17
- gem.add_runtime_dependency "dry-initializer", "~> 2.0"
17
+ gem.add_runtime_dependency "dry-initializer", "> 2", "< 4"
18
18
  gem.add_runtime_dependency "i18n", "~> 1.0"
19
19
 
20
20
  gem.add_development_dependency "rake", "> 10"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tram-policy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktor Sokolov (gzigzigzeo)
@@ -9,22 +9,28 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-17 00:00:00.000000000 Z
12
+ date: 2019-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-initializer
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">"
19
+ - !ruby/object:Gem::Version
20
+ version: '2'
21
+ - - "<"
19
22
  - !ruby/object:Gem::Version
20
- version: '2.0'
23
+ version: '4'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">"
29
+ - !ruby/object:Gem::Version
30
+ version: '2'
31
+ - - "<"
26
32
  - !ruby/object:Gem::Version
27
- version: '2.0'
33
+ version: '4'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: i18n
30
36
  requirement: !ruby/object:Gem::Requirement
@@ -173,8 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
179
  - !ruby/object:Gem::Version
174
180
  version: '0'
175
181
  requirements: []
176
- rubyforge_project:
177
- rubygems_version: 2.6.14
182
+ rubygems_version: 3.0.3
178
183
  signing_key:
179
184
  specification_version: 4
180
185
  summary: Policy Object Pattern