enumerize 1.1.0 → 1.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: a5f9d4b829c7ef4c4f41e2a96e041a4a66771268
4
- data.tar.gz: b961d9d0ebe14b4d0f2eadc334fef61cc348283f
3
+ metadata.gz: 5542a2d4391256f030660b112b5550d304f54364
4
+ data.tar.gz: 8146fa77598d876ae818b44f923382ec7fa87745
5
5
  SHA512:
6
- metadata.gz: 53ee726338ce9d36c152691073e5bae144e6fbb665c8d03511a7e66772e116d90dd1a74c8d7b1fa100e7855e9336d45ef5d3afdeb05053f398ee3a073bd854c2
7
- data.tar.gz: f3ac55edcb00daeca98564a1da87c4df44c5c32a76e422ad206d50ee7fa0821964c572eefc030b4fec4edb7710582730f43435a57ec452284a235bb39e7e7db5
6
+ metadata.gz: 1ee6f8b28d3da326a8ab68a9d5a8639b5dca559b58f32d2104364c540911e26a294d7c733a954075be09aa72a5b4890df8304415e69228c89ece1f52b8411cba
7
+ data.tar.gz: b997d62b2e1e759b50cd89921af5f16a7e88e0356a3eb674540ff5562fdde09259920ca9522f001b38ad33419c251cfbe019305752c6ae2ab9947f4a1caf018b
data/CHANGELOG.md CHANGED
@@ -4,10 +4,16 @@
4
4
 
5
5
  ### bug fix
6
6
 
7
+ ## 1.1.1 (January 25, 2016)
8
+
9
+ ### bug fix
10
+
11
+ * Fix exception when using predicate methods and enumerized values have dash in it. (by [@nashby](https://github.com/nashby))
12
+
7
13
  ## 1.1.0 (November 15, 2015)
8
14
 
9
15
  ### enhancements
10
- * Add Sequel support. (by [@mrbrdo](https://github.com/mrbrdo))
16
+ * Add Sequel support. (by [@mrbrdo](https://github.com/mrbrdo))
11
17
  * Add qualifiers to RSpec matcher. (by [@maurogeorge](https://github.com/maurogeorge))
12
18
  * Support hash in the RSpec matcher. (by [@maurogeorge](https://github.com/maurogeorge))
13
19
 
data/Gemfile CHANGED
@@ -2,4 +2,4 @@ eval_gemfile('Gemfile.global')
2
2
 
3
3
  gem 'minitest', '~> 5.8'
4
4
  gem 'rails', '4.2.4', :require => false
5
- gem 'mongoid'
5
+ gem 'mongoid', '~> 5.0'
data/README.md CHANGED
@@ -278,6 +278,12 @@ class User < ActiveRecord::Base
278
278
  end
279
279
  ```
280
280
 
281
+ get an array of all text values:
282
+
283
+ ```ruby
284
+ @user.interests.texts # shortcut for @user.interests.map(&:text)
285
+ ```
286
+
281
287
  ### SimpleForm
282
288
 
283
289
  If you are using SimpleForm gem you don't need to specify input type (`:select` by default) and collection:
@@ -8,7 +8,7 @@ module Enumerize
8
8
  end
9
9
 
10
10
  def in(*expected_values)
11
- self.expected_values = expected_values
11
+ self.expected_values = expected_values.flatten
12
12
  self
13
13
  end
14
14
 
@@ -63,7 +63,7 @@ module Enumerize
63
63
  end
64
64
 
65
65
  def names
66
- values.map { |v| "#{v}?" }
66
+ values.map { |v| "#{v.tr('-', '_')}?" }
67
67
  end
68
68
 
69
69
  def build(klass)
@@ -1,3 +1,3 @@
1
1
  module Enumerize
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -61,7 +61,11 @@ RSpec.describe Enumerize::Integrations::RSpec::Matcher do
61
61
  model.enumerize(:sex, :in => [:male, :female])
62
62
  end
63
63
 
64
- it 'accepts the right params as a array' do
64
+ it 'accepts the right params as an array' do
65
+ expect(subject).to enumerize(:sex).in([:male, :female])
66
+ end
67
+
68
+ it 'accepts the right params as regular params' do
65
69
  expect(subject).to enumerize(:sex).in(:male, :female)
66
70
  end
67
71
 
@@ -90,7 +94,7 @@ RSpec.describe Enumerize::Integrations::RSpec::Matcher do
90
94
  model.enumerize(:sex, :in => { male: 0, female: 1 })
91
95
  end
92
96
 
93
- it 'accepts the right params as a array' do
97
+ it 'accepts the right params as an array' do
94
98
  expect(subject).to enumerize(:sex).in(:male, :female)
95
99
  end
96
100
 
data/spec/spec_helper.rb CHANGED
@@ -8,17 +8,21 @@ RSpec.configure do |config|
8
8
  Kernel.srand config.seed
9
9
  config.filter_run focus: true
10
10
  config.run_all_when_everything_filtered = true
11
+
11
12
  config.expect_with :rspec do |expectations|
12
13
  expectations.syntax = :expect
13
14
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
14
15
  end
16
+
15
17
  config.mock_with :rspec do |mocks|
16
18
  mocks.syntax = :expect
17
19
  mocks.verify_partial_doubles = true
18
20
  end
21
+
19
22
  if config.files_to_run.one?
20
23
  config.default_formatter = 'doc'
21
24
  end
25
+
22
26
  config.warnings = true
23
27
  config.include RSpec::Matchers::FailMatchers
24
28
  end
data/test/mongoid_test.rb CHANGED
@@ -7,9 +7,8 @@ silence_warnings do
7
7
  end
8
8
 
9
9
  Mongoid.configure do |config|
10
- config.sessions = { :default => { :database => 'enumerize-test-suite', hosts: ['127.0.0.1:27017'] } }
11
- config.use_utc = true
12
- config.include_root_in_json = true
10
+ config.connect_to('enumerize-test-suite')
11
+ config.options = { use_utc: true, include_root_in_json: true }
13
12
  end
14
13
 
15
14
  describe Enumerize do
@@ -15,6 +15,12 @@ describe Enumerize::Predicates do
15
15
  object.must_respond_to :b?
16
16
  end
17
17
 
18
+ it 'creates predicate methods when enumerized values have dash in it' do
19
+ klass.enumerize(:foo, in: %w(foo-bar bar-foo), predicates: true)
20
+ object.must_respond_to :foo_bar?
21
+ object.must_respond_to :bar_foo?
22
+ end
23
+
18
24
  it 'creates predicate methods on multiple attribute' do
19
25
  klass.enumerize(:foo, in: %w(a b), predicates: true, multiple: true)
20
26
  object.must_respond_to :a?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumerize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Nartimov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-15 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.4.5.1
109
+ rubygems_version: 2.4.6
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Enumerated attributes with I18n and ActiveRecord/Mongoid/MongoMapper support