mongoid-minitest 1.0.0 → 1.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: 8eebdad8b5b9c67d775c9a7b274d277c04685f29
4
- data.tar.gz: edc782fd5cea7937ffaff2a0eb1458934dab5015
3
+ metadata.gz: 6a8515ad792ea491178ce0350b57e4f84d4325fb
4
+ data.tar.gz: b9d87d463baa601969be68b7cb2d642dbc6a9e3c
5
5
  SHA512:
6
- metadata.gz: 8ca707f22905c2e26a37bbf768a6ba0700df1ba2186470db9187fd555ebf877e1310385a46a9bd498edb54526e0c0b7e29e5dfcc7a35261df827007d90e67196
7
- data.tar.gz: 36c28d586589aaa40dad9a230b890cd71de33d6dde6c11f4c8af753b85c0399509bbdee21abf97fc95b6f956b3b914e22a764b603eaece40f52be57f3090b070
6
+ metadata.gz: 1124b1d5e81d9388b4617b985c147aaad04d5aa656d7505acc039d0b1bc4a04b90abcd06447796cc3acaab797843c46f947d73393c12ae74caf85e5d9ae55fab
7
+ data.tar.gz: 08fb6f6c5fe7b4344e664f45e41e73f2d05db78b3514c12c3b000d743d31ddba37367b5c5ffd308a0527aa0b0879e91c8b623824ec366144ff230c6c35cea8a0
data/.gitignore CHANGED
@@ -4,6 +4,7 @@
4
4
  .config
5
5
  .yardoc
6
6
  Gemfile.lock
7
+ gemfiles/*.lock
7
8
  InstalledFiles
8
9
  _yardoc
9
10
  coverage
@@ -1,12 +1,16 @@
1
1
  language: ruby
2
- before_install:
3
- - gem install bundler
4
2
  rvm:
5
- - 1.9.3
6
- - 2.0.0
7
- - ruby-head
3
+ - 2.1
4
+ - 2.2
8
5
  - rbx-19mode
9
6
  - jruby-19mode
10
7
  gemfile:
8
+ - gemfiles/mongoid-3.1.gemfile
9
+ - gemfiles/mongoid-4.0.gemfile
10
+ - gemfiles/edge.gemfile
11
11
  - Gemfile
12
- - Gemfile.edge
12
+
13
+ matrix:
14
+ allow_failures:
15
+ - gemfile: gemfiles/edge.gemfile
16
+ fast_finish: true
@@ -1,3 +1,10 @@
1
+ ## 1.1.0
2
+
3
+ + Upgrade to minitest 5
4
+ Pull Request [#20](https://github.com/frodsan/mongoid-minitest/pull/16) - *Ryan McGeary*.
5
+
6
+ + Add support for Ruby 2.1 and 2.2 - *Ryan McGeary*.
7
+
1
8
  ## 1.0.0 - February 27, 2013
2
9
 
3
10
  + Extract Validation Matchers to [minitest-activemodel](https://github.com/frodsan/minitest-activemodel) gem.
data/README.md CHANGED
@@ -3,9 +3,10 @@ mongoid-minitest
3
3
 
4
4
  MiniTest matchers for Mongoid.
5
5
 
6
- [![Build Status](https://secure.travis-ci.org/frodsan/mongoid-minitest.png?branch=master&.png)](http://travis-ci.org/frodsan/mongoid-minitest)
7
- [![Dependency Status](https://gemnasium.com/frodsan/mongoid-minitest.png)](https://gemnasium.com/frodsan/mongoid-minitest)
8
- [![Code Climate](https://codeclimate.com/github/frodsan/mongoid-minitest.png)](https://codeclimate.com/github/frodsan/mongoid-minitest)
6
+ [![Gem Version](http://img.shields.io/gem/v/mongoid-minitest.svg)](https://rubygems.org/gems/mongoid-minitest)
7
+ [![Build Status](https://travis-ci.org/frodsan/mongoid-minitest.svg?branch=master)](http://travis-ci.org/frodsan/mongoid-minitest)
8
+ [![Dependency Status](http://img.shields.io/gemnasium/frodsan/mongoid-minitest.svg)](https://gemnasium.com/frodsan/mongoid-minitest)
9
+ [![Code Climate](http://img.shields.io/codeclimate/github/frodsan/mongoid-minitest.svg)](https://codeclimate.com/github/frodsan/mongoid-minitest)
9
10
 
10
11
  Support
11
12
  -------
@@ -1,6 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec
4
-
3
+ gemspec path: "../"
5
4
  gem 'mongoid', github: 'mongoid/mongoid'
6
5
  gem 'minitest-activemodel', github: 'frodsan/minitest-activemodel'
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: "../"
4
+ gem 'mongoid', '~> 3.1.0'
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: "../"
4
+ gem 'mongoid', '~> 4.0.0'
@@ -1,21 +1,33 @@
1
1
  module Mongoid
2
2
  module Matchers
3
+ def be_stored_in collection_name
4
+ BeStoredInMatcher.new collection_name
5
+ end
6
+
7
+ private
8
+
3
9
  class BeStoredInMatcher < Matcher
10
+ attr_reader :collection_name
11
+
4
12
  def initialize collection_name
5
13
  @collection_name = collection_name.to_s
6
14
  end
7
15
 
8
16
  def matches? subject
9
- class_of(subject).collection_name.to_s == @collection_name
17
+ class_of(subject).collection_name.to_s == collection_name
10
18
  end
11
19
 
12
- def description
13
- "be stored in #{@collection_name.inspect}"
20
+ def failure_message
21
+ "Expected #{inspect} to #{description}"
14
22
  end
15
- end
16
23
 
17
- def be_stored_in collection_name
18
- BeStoredInMatcher.new collection_name
24
+ def negative_failure_message
25
+ "Expected not to #{description}"
26
+ end
27
+
28
+ def description
29
+ "be stored in #{collection_name.inspect}"
30
+ end
19
31
  end
20
32
  end
21
33
  end
@@ -2,49 +2,65 @@ module Mongoid
2
2
  module Matchers
3
3
  module Document
4
4
  DOCUMENT = Mongoid::Document
5
- PARANOIA = Mongoid::Paranoia unless Mongoid::VERSION == '4.0.0'
6
- VERSIONING = Mongoid::Versioning unless Mongoid::VERSION == '4.0.0'
5
+ PARANOIA = Mongoid::Paranoia unless Mongoid::VERSION.to_i >= 4
6
+ VERSIONING = Mongoid::Versioning unless Mongoid::VERSION.to_i >= 4
7
7
  TIMESTAMPS = Mongoid::Timestamps
8
8
 
9
- class DocumentMatcher < Matcher
10
- def initialize mod
11
- @mod = mod
12
- end
13
-
14
- def matches? subject
15
- class_of(subject).included_modules.include? @mod
16
- end
17
-
18
- def description
19
- msg = case
20
- when @mod == DOCUMENT then ''
21
- when @mod == PARANOIA then 'paranoid '
22
- when @mod == VERSIONING then 'versioned '
23
- when @mod == TIMESTAMPS then 'timestamped '
24
- else raise "Unknow Mongoid module #{@mod}"
25
- end
26
-
27
- "be a #{msg}Mongoid document"
28
- end
29
- end
30
-
9
+ # TODO: add documentation.
31
10
  def be_document
32
11
  DocumentMatcher.new DOCUMENT
33
12
  end
34
13
 
35
- unless Mongoid::VERSION == '4.0.0'
14
+ unless Mongoid::VERSION.to_i >= 4
15
+ # TODO: add documentation.
36
16
  def be_paranoid
37
17
  DocumentMatcher.new PARANOIA
38
18
  end
39
19
 
20
+ # TODO: add documentation.
40
21
  def be_versioned
41
22
  DocumentMatcher.new VERSIONING
42
23
  end
43
24
  end
44
25
 
26
+ # TODO: add documentation.
45
27
  def be_timestamped
46
28
  DocumentMatcher.new TIMESTAMPS
47
29
  end
30
+
31
+ private
32
+
33
+ class DocumentMatcher < Matcher
34
+ attr_reader :mod
35
+
36
+ def initialize mod
37
+ @mod = mod
38
+ end
39
+
40
+ def matches? subject
41
+ class_of(subject).included_modules.include? mod
42
+ end
43
+
44
+ def failure_message
45
+ "Expected #{inspect} to #{description}"
46
+ end
47
+
48
+ def negative_failure_message
49
+ "Expected not to #{description}"
50
+ end
51
+
52
+ def description
53
+ msg = case
54
+ when mod == DOCUMENT then ''
55
+ when mod == PARANOIA then 'paranoid '
56
+ when mod == VERSIONING then 'versioned '
57
+ when mod == TIMESTAMPS then 'timestamped '
58
+ else raise "Unknow Mongoid module #{mod}"
59
+ end
60
+
61
+ "be a #{msg}Mongoid document"
62
+ end
63
+ end
48
64
  end
49
65
  end
50
66
  end
@@ -1,9 +1,20 @@
1
1
  module Mongoid
2
2
  module Matchers
3
3
  module Document
4
+ # TODO: Add documentation.
5
+ def have_field *fields
6
+ HaveFieldMatcher.new(*fields)
7
+ end
8
+ alias :have_fields :have_field
9
+
10
+ private
11
+
4
12
  class HaveFieldMatcher < Matcher
13
+ attr_reader :fields, :klass, :type, :default, :errors
14
+
5
15
  def initialize *fields
6
16
  @fields = fields.collect(&:to_s)
17
+ @errors = []
7
18
  end
8
19
 
9
20
  def of_type type
@@ -17,13 +28,12 @@ module Mongoid
17
28
  end
18
29
 
19
30
  def matches? subject
20
- @klass = class_of subject
21
- @errors = []
31
+ @klass = class_of subject
22
32
 
23
- @fields.each do |field|
24
- if @klass.fields.include? field
33
+ fields.each do |field|
34
+ if klass.fields.include? field
25
35
  error = ''
26
- result_field = @klass.fields[field]
36
+ result_field = klass.fields[field]
27
37
 
28
38
  if check_type_with result_field.type
29
39
  error << " of type #{result_field.type.inspect}"
@@ -33,47 +43,42 @@ module Mongoid
33
43
  error << " with default value of #{result_field.default_val.inspect}"
34
44
  end
35
45
 
36
- @errors << "field #{field.inspect << error}" if !error.blank?
46
+ errors << "field #{field.inspect << error}" if !error.blank?
37
47
  else
38
- @errors << "no field named #{field.inspect}"
48
+ errors << "no field named #{field.inspect}"
39
49
  end
40
50
  end
41
51
 
42
- @errors.empty?
52
+ errors.empty?
43
53
  end
44
54
 
45
55
  def failure_message
46
- "#{@klass} to #{description}, got #{@errors.to_sentence}"
56
+ "#{klass} to #{description}, got #{errors.to_sentence}"
47
57
  end
48
58
 
49
59
  def negative_failure_message
50
- msg = "#{@klass.inspect} to not #{description}, "
51
- msg << "got #{@klass.inspect} to #{description}"
60
+ msg = "#{klass.inspect} to not #{description}, "
61
+ msg << "got #{klass.inspect} to #{description}"
52
62
  end
53
63
 
54
64
  def description
55
- desc = "have #{@fields.size > 1 ? 'fields' : 'field'} named"
56
- desc << " #{to_sentence(@fields)}"
57
- desc << " of type #{@type.inspect}" if @type
58
- desc << " with default value of #{@default.inspect}" if !@default.nil?
65
+ desc = "have #{fields.size > 1 ? 'fields' : 'field'} named"
66
+ desc << " #{to_sentence(fields)}"
67
+ desc << " of type #{type.inspect}" if type
68
+ desc << " with default value of #{default.inspect}" if !default.nil?
59
69
  desc
60
70
  end
61
71
 
62
72
  private
63
73
 
64
- def check_type_with type
65
- @type && type != @type
74
+ def check_type_with _type
75
+ type && _type != type
66
76
  end
67
77
 
68
- def check_default_with default
69
- !@default.nil? && !default.nil? && default != @default
78
+ def check_default_with _default
79
+ !default.nil? && !_default.nil? && _default != default
70
80
  end
71
81
  end
72
-
73
- def have_field *fields
74
- HaveFieldMatcher.new(*fields)
75
- end
76
- alias :have_fields :have_field
77
82
  end
78
83
  end
79
84
  end
@@ -1,36 +1,49 @@
1
1
  module Mongoid
2
2
  module Matchers
3
+ # TODO: Add documentation.
4
+ def have_index_for *attrs
5
+ HaveIndexMatcher.new(*attrs)
6
+ end
7
+
8
+ private
9
+
3
10
  class HaveIndexMatcher < Matcher
4
- def initialize *fields
5
- @fields = fields.map(&:to_sym)
11
+ attr_reader :attrs, :klass
12
+
13
+ def initialize *attrs
14
+ @attrs = attrs.map(&:to_sym)
6
15
  end
7
16
 
8
17
  def matches? subject
9
18
  @klass = class_of subject
10
- @klass.index_options.any? do |index, options|
11
- index.keys == @fields
12
- end
19
+ index_options.any? { |idx, _| idx.keys == attrs }
13
20
  end
14
21
 
15
22
  def failure_message
16
- "#{@klass} to #{description}, but only found indexes #{indexes.inspect}"
23
+ "#{klass} to #{description}, but only found indexes #{indexes.inspect}"
17
24
  end
18
25
 
19
26
  def negative_failure_message
20
- "#{@klass} to not #{description}, but found an index for #{@fields.inspect}"
27
+ "#{klass} to not #{description}, but found an index for #{attrs.inspect}"
21
28
  end
22
29
 
23
30
  def description
24
- "have an index for #{@fields.inspect}"
31
+ "have an index for #{attrs.inspect}"
25
32
  end
26
33
 
27
- def indexes
28
- @klass.index_options.keys.map(&:keys)
34
+ private
35
+
36
+ def index_options
37
+ if Mongoid::VERSION.to_i < 4
38
+ klass.index_options
39
+ else
40
+ Hash[klass.index_specifications.map{ |i| [i.key, i.options] }]
41
+ end
29
42
  end
30
- end
31
43
 
32
- def have_index_for *fields
33
- HaveIndexMatcher.new(*fields)
44
+ def indexes
45
+ index_options.keys.map(&:keys)
46
+ end
34
47
  end
35
48
  end
36
49
  end
@@ -2,14 +2,6 @@ module Mongoid
2
2
  module Matchers
3
3
  class Matcher
4
4
  include MiniTest::Matchers::ActiveModel::Helpers
5
-
6
- def failure_message
7
- "Expected #{inspect} to #{description}".squeeze ' '
8
- end
9
-
10
- def negative_failure_message
11
- "Expected not to #{description}".squeeze ' '
12
- end
13
5
  end
14
6
  end
15
7
  end
@@ -1,4 +1,3 @@
1
- gem 'minitest'
2
1
  require 'minitest-activemodel'
3
2
  require 'matchers/matcher'
4
3
  require 'matchers/document/document'
@@ -2,10 +2,10 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'mongoid-minitest'
5
- gem.version = '1.0.0'
5
+ gem.version = '1.1.0'
6
6
 
7
7
  gem.authors = ['Francesco Rodriguez', 'Sascha Wessel', 'Godfrey Chan', 'Ryan McGeary']
8
- gem.email = ['lrodriguezsanc@gmail.com', 'ryan@mcgeary.org']
8
+ gem.email = ['frodsan@protonmail.ch', 'godfreykfc@gmail.com', 'ryan@mcgeary.org']
9
9
  gem.description = %q{MiniTest matchers for Mongoid}
10
10
  gem.summary = gem.description
11
11
  gem.homepage = 'https://github.com/frodsan/mongoid-minitest'
@@ -20,9 +20,10 @@ Gem::Specification.new do |gem|
20
20
 
21
21
  gem.required_ruby_version = '>= 1.9.3'
22
22
 
23
- gem.add_dependency 'minitest', '~> 4.1'
24
- gem.add_dependency 'minitest-matchers', '~> 1.2'
23
+ gem.add_dependency 'minitest', '~> 5.0'
25
24
  gem.add_dependency 'mongoid' , '>= 3'
26
- gem.add_dependency 'minitest-activemodel', '~> 1.0'
25
+ gem.add_dependency 'minitest-activemodel', '~> 1.1'
26
+
27
+ gem.add_development_dependency 'minitest-matchers'
27
28
  gem.add_development_dependency 'rake'
28
29
  end
@@ -6,7 +6,7 @@ describe 'Document' do
6
6
 
7
7
  it { must be_document }
8
8
  it { must be_timestamped }
9
- unless Mongoid::VERSION == '4.0.0'
9
+ unless Mongoid::VERSION.to_i >= 4
10
10
  it { must be_paranoid }
11
11
  it { must be_versioned }
12
12
  end
@@ -1,7 +1,7 @@
1
1
  class Person
2
2
  include Mongoid::Document
3
3
  include Mongoid::Timestamps
4
- unless Mongoid::VERSION == '4.0.0'
4
+ unless Mongoid::VERSION.to_i >= 4
5
5
  include Mongoid::Paranoia
6
6
  include Mongoid::Versioning
7
7
  end
@@ -1,5 +1,4 @@
1
1
  require 'bundler/setup'
2
- gem 'minitest'
3
2
  require 'minitest/autorun'
4
3
  require 'mongoid'
5
4
  require 'mongoid-minitest'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Rodriguez
@@ -11,81 +11,82 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-02-27 00:00:00.000000000 Z
14
+ date: 2015-06-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: minitest
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - ~>
20
+ - - "~>"
21
21
  - !ruby/object:Gem::Version
22
- version: '4.1'
22
+ version: '5.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ~>
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '4.1'
29
+ version: '5.0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: minitest-matchers
31
+ name: mongoid
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - ~>
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: '1.2'
36
+ version: '3'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ~>
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: '1.2'
43
+ version: '3'
44
44
  - !ruby/object:Gem::Dependency
45
- name: mongoid
45
+ name: minitest-activemodel
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - '>='
48
+ - - "~>"
49
49
  - !ruby/object:Gem::Version
50
- version: '3'
50
+ version: '1.1'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - '>='
55
+ - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '3'
57
+ version: '1.1'
58
58
  - !ruby/object:Gem::Dependency
59
- name: minitest-activemodel
59
+ name: minitest-matchers
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - ~>
62
+ - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: '1.0'
65
- type: :runtime
64
+ version: '0'
65
+ type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - ~>
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: '1.0'
71
+ version: '0'
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: rake
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - '>='
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - '>='
83
+ - - ">="
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  description: MiniTest matchers for Mongoid
87
87
  email:
88
- - lrodriguezsanc@gmail.com
88
+ - frodsan@protonmail.ch
89
+ - godfreykfc@gmail.com
89
90
  - ryan@mcgeary.org
90
91
  executables: []
91
92
  extensions: []
@@ -94,14 +95,16 @@ extra_rdoc_files:
94
95
  - LICENSE.md
95
96
  - README.md
96
97
  files:
97
- - .gitignore
98
- - .travis.yml
98
+ - ".gitignore"
99
+ - ".travis.yml"
99
100
  - CHANGELOG.md
100
101
  - Gemfile
101
- - Gemfile.edge
102
102
  - LICENSE.md
103
103
  - README.md
104
104
  - Rakefile
105
+ - gemfiles/edge.gemfile
106
+ - gemfiles/mongoid-3.1.gemfile
107
+ - gemfiles/mongoid-4.0.gemfile
105
108
  - lib/matchers/associations/associations.rb
106
109
  - lib/matchers/document/be_stored_in.rb
107
110
  - lib/matchers/document/document.rb
@@ -120,22 +123,22 @@ licenses:
120
123
  metadata: {}
121
124
  post_install_message:
122
125
  rdoc_options:
123
- - --charset=UTF-8
126
+ - "--charset=UTF-8"
124
127
  require_paths:
125
128
  - lib
126
129
  required_ruby_version: !ruby/object:Gem::Requirement
127
130
  requirements:
128
- - - '>='
131
+ - - ">="
129
132
  - !ruby/object:Gem::Version
130
133
  version: 1.9.3
131
134
  required_rubygems_version: !ruby/object:Gem::Requirement
132
135
  requirements:
133
- - - '>='
136
+ - - ">="
134
137
  - !ruby/object:Gem::Version
135
138
  version: '0'
136
139
  requirements: []
137
140
  rubyforge_project:
138
- rubygems_version: 2.0.0
141
+ rubygems_version: 2.4.6
139
142
  signing_key:
140
143
  specification_version: 4
141
144
  summary: MiniTest matchers for Mongoid