has_serialized-matchers 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84cb865c9ee22171be88cd24f6610089f1147f49
4
- data.tar.gz: cf61201dc4e93016589e4a4272da6757ff1dfb5c
3
+ metadata.gz: e1d2356708d427263dba8c2aa6cf4eaae3a6620f
4
+ data.tar.gz: 86eaba14d909b57dd225d30a743cb6d2767df0be
5
5
  SHA512:
6
- metadata.gz: 81ad72ca5339941d96c3669128b03da897b7f851002f267ee9c9360cfbbecb7ce5193226da2bd5741554850263839642f76d6091ba0da449e1f2502cab9c00de
7
- data.tar.gz: d08d9fae8045b3b6b5199373843c96dda5599812b3073e305fe380e7363cc143f31e3960d2f45f5a3d4421ed250b6bc6634b5c7792fd25777bb4023f41765956
6
+ metadata.gz: 7d0f9e988d1a0f87f16ca01ea4b8f643fc5abd43e08ee063c8d1f9df6660a4a90585fbb0d9db2abcf44d2a7773e88b42c0927bea1709dc02f82e41652eaf06b5
7
+ data.tar.gz: a2bd7c667739f9d845aec5717f98cc44cbebe9e7b8873ffdfc15753e69084429bba20890bcc3c1c36bfc1534c452680e97c9cf4083626e4c9e369d69463f12fa
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ # 0.1.0
2
+ - add a chainable `with_default_value` matcher
data/README.md CHANGED
@@ -18,7 +18,7 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- it { should have_serialized_attribute(:serialized_attr).in(:serialized_attributes_list) }
21
+ it { should have_serialized_attribute(:serialized_attr).in(:serialized_attributes_list).with_default_value(value) }
22
22
 
23
23
  ## Contributing
24
24
 
@@ -7,7 +7,7 @@ module HasSerialized
7
7
 
8
8
  def matches?(model)
9
9
  @model = model
10
- check_methods
10
+ methods_correct? && values_correct?
11
11
  end
12
12
 
13
13
  def in(column)
@@ -15,8 +15,22 @@ module HasSerialized
15
15
  self
16
16
  end
17
17
 
18
+ def with_default_value(value)
19
+ @value = value
20
+ self
21
+ end
22
+
18
23
  def failure_message
19
- "expected #{@model.inspect} to have serialized attribute #{@attr_name}"
24
+ base_message = %Q{expected #{@model.class.name} to
25
+ have serialized attribute #{@attr_name}
26
+ in #{@column}
27
+ }
28
+
29
+ if @value.to_s
30
+ base_message += "with default value #{@value}"
31
+ end
32
+
33
+ base_message
20
34
  end
21
35
 
22
36
  def description
@@ -25,14 +39,24 @@ module HasSerialized
25
39
 
26
40
  private
27
41
 
28
- def check_methods
42
+ def methods_correct?
29
43
  unless @column
30
44
  fail %Q{
31
45
  Please specify the column in which to find the `#{@attr_name}`.
32
46
  Ex: have_serialized_attribute(:#{@attr_name}).in(:column_name)
33
47
  }
34
48
  end
35
- @model.send(@column).has_key? @attr_name
49
+
50
+ serialized_column = @model.send(@column)
51
+ serialized_column and serialized_column.has_key? @attr_name
52
+ end
53
+
54
+ def values_correct?
55
+ if @value
56
+ @model.send(@attr_name) == @value
57
+ else
58
+ true
59
+ end
36
60
  end
37
61
  end
38
62
  end
@@ -1,5 +1,5 @@
1
1
  module HasSerialized
2
2
  module Matchers
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -25,7 +25,7 @@ module HasSerialized
25
25
  context 'matchers' do
26
26
  subject{ Serializeable.new }
27
27
 
28
- it { should have_serialized_attribute(:serial_attr).in(:serial_attrs) }
28
+ it { should have_serialized_attribute(:serial_attr).in(:serial_attrs).with_default_value('dummy') }
29
29
  end
30
30
  end
31
31
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_serialized-matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cecille Manalang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-05 00:00:00.000000000 Z
11
+ date: 2014-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: has_serialized
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.1'
27
27
  description: RSpec matchers for `has_serialized`
@@ -31,7 +31,8 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - ".gitignore"
34
+ - .gitignore
35
+ - CHANGELOG.md
35
36
  - Gemfile
36
37
  - LICENSE.txt
37
38
  - README.md
@@ -54,17 +55,17 @@ require_paths:
54
55
  - lib
55
56
  required_ruby_version: !ruby/object:Gem::Requirement
56
57
  requirements:
57
- - - ">="
58
+ - - '>='
58
59
  - !ruby/object:Gem::Version
59
60
  version: '0'
60
61
  required_rubygems_version: !ruby/object:Gem::Requirement
61
62
  requirements:
62
- - - ">="
63
+ - - '>='
63
64
  - !ruby/object:Gem::Version
64
65
  version: '0'
65
66
  requirements: []
66
67
  rubyforge_project:
67
- rubygems_version: 2.2.0
68
+ rubygems_version: 2.0.3
68
69
  signing_key:
69
70
  specification_version: 4
70
71
  summary: RSpec matchers for `has_serialized`