has_serialized-matchers 0.0.1

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: 84cb865c9ee22171be88cd24f6610089f1147f49
4
+ data.tar.gz: cf61201dc4e93016589e4a4272da6757ff1dfb5c
5
+ SHA512:
6
+ metadata.gz: 81ad72ca5339941d96c3669128b03da897b7f851002f267ee9c9360cfbbecb7ce5193226da2bd5741554850263839642f76d6091ba0da449e1f2502cab9c00de
7
+ data.tar.gz: d08d9fae8045b3b6b5199373843c96dda5599812b3073e305fe380e7363cc143f31e3960d2f45f5a3d4421ed250b6bc6634b5c7792fd25777bb4023f41765956
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .gems
7
+ .gs
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in has_serialized-matchers.gemspec
4
+ gemspec
5
+
6
+ gem "bundler"
7
+ gem "rake"
8
+ gem "rspec"
9
+ gem "sqlite3"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Developer Account
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # HasSerialized::Matchers
2
+
3
+ Provides shoulda-style matchers for RSpec to [has_serialized](https://github.com/ramontayag/has_serialized)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'has_serialized-matchers', group: :test
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install has_serialized-matchers
18
+
19
+ ## Usage
20
+
21
+ it { should have_serialized_attribute(:serialized_attr).in(:serialized_attributes_list) }
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/has_serialized-matchers/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'has_serialized/matchers/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "has_serialized-matchers"
8
+ spec.version = HasSerialized::Matchers::VERSION
9
+ spec.authors = ["Cecille Manalang"]
10
+ spec.email = ["cecille@onegoodcode.com"]
11
+ spec.summary = %q{RSpec matchers for `has_serialized`}
12
+ spec.description = %q{RSpec matchers for `has_serialized`}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'has_serialized', '~> 1.1'
22
+ end
@@ -0,0 +1,39 @@
1
+ module HasSerialized
2
+ module Matchers
3
+ class HaveSerializedAttribute
4
+ def initialize(attr_name)
5
+ @attr_name = attr_name
6
+ end
7
+
8
+ def matches?(model)
9
+ @model = model
10
+ check_methods
11
+ end
12
+
13
+ def in(column)
14
+ @column = column
15
+ self
16
+ end
17
+
18
+ def failure_message
19
+ "expected #{@model.inspect} to have serialized attribute #{@attr_name}"
20
+ end
21
+
22
+ def description
23
+ "Ensures that #{@model} has serialized attribute #{@attr_name}."
24
+ end
25
+
26
+ private
27
+
28
+ def check_methods
29
+ unless @column
30
+ fail %Q{
31
+ Please specify the column in which to find the `#{@attr_name}`.
32
+ Ex: have_serialized_attribute(:#{@attr_name}).in(:column_name)
33
+ }
34
+ end
35
+ @model.send(@column).has_key? @attr_name
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,6 @@
1
+ require 'rspec/core'
2
+
3
+ RSpec.configure do |config|
4
+ require 'has_serialized/matchers'
5
+ config.include HasSerialized::Matchers
6
+ end
@@ -0,0 +1,5 @@
1
+ module HasSerialized
2
+ module Matchers
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ require "has_serialized/matchers/version"
2
+ require "has_serialized/matchers/have_serialized_attribute"
3
+ require "has_serialized/matchers/rspec"
4
+
5
+ module HasSerialized
6
+ module Matchers
7
+ def have_serialized_attribute(expected)
8
+ HaveSerializedAttribute.new(expected)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ require 'has_serialized/matchers'
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'has_serialized'
3
+
4
+ module HasSerialized
5
+ module Matchers
6
+ describe HaveSerializedAttribute do
7
+ before :all do
8
+ m = ActiveRecord::Migration.new
9
+ m.verbose = false
10
+ m.create_table :serializeables do |t|
11
+ t.string :serial_attrs
12
+ end
13
+ end
14
+
15
+ after :all do
16
+ m = ActiveRecord::Migration.new
17
+ m.verbose = false
18
+ m.drop_table :serializeables
19
+ end
20
+
21
+ class Serializeable < ActiveRecord::Base
22
+ has_serialized :serial_attrs, serial_attr: 'dummy'
23
+ end
24
+
25
+ context 'matchers' do
26
+ subject{ Serializeable.new }
27
+
28
+ it { should have_serialized_attribute(:serial_attr).in(:serial_attrs) }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'has_serialized-matchers'
5
+ require 'active_record'
6
+
7
+ ActiveRecord::Base.establish_connection(
8
+ adapter: 'sqlite3',
9
+ database: ':memory:'
10
+ )
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: has_serialized-matchers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Cecille Manalang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: has_serialized
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ description: RSpec matchers for `has_serialized`
28
+ email:
29
+ - cecille@onegoodcode.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - has_serialized-matchers.gemspec
40
+ - lib/has_serialized-matchers.rb
41
+ - lib/has_serialized/matchers.rb
42
+ - lib/has_serialized/matchers/have_serialized_attribute.rb
43
+ - lib/has_serialized/matchers/rspec.rb
44
+ - lib/has_serialized/matchers/version.rb
45
+ - spec/has_serialized/matchers/have_serialized_attribute_spec.rb
46
+ - spec/spec_helper.rb
47
+ homepage: ''
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 2.2.0
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: RSpec matchers for `has_serialized`
71
+ test_files:
72
+ - spec/has_serialized/matchers/have_serialized_attribute_spec.rb
73
+ - spec/spec_helper.rb