mongoid-minitest 0.1.4 → 0.1.5

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: fbba88296751c989d9b415ed8657092048c4ac51
4
+ data.tar.gz: 812b20db8de722f9fe3d650b4eb242c7a01ab345
5
+ SHA512:
6
+ metadata.gz: a41749d8ad83925d6ccf311f9d2c318d9f4270c506ebd71146472551bce0d3b0808460351c4d965a0b2ed120d4c1127f6c36c4838422cda0449a268d2cf91c38
7
+ data.tar.gz: 364a09c71d33a04baf6d2247900007bac3eabb02e70a4b1fb147a60836f614e9239c3f481544640d9b892443ab4130f0b4ce6fa546d2106cdc6c1175bcb4e4bf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 0.1.5 - February 26, 2013
2
+
3
+ + Add Ruby 2.0.0 support - *Francesco Rodriguez*.
4
+ + Make mongoid version more flexible in gemspec.
5
+ Pull Request [#16](https://github.com/frodsan/mongoid-minitest/pull/16) - *Ryan McGeary*.
6
+ + Add compound indexes support for `have_index` matcher.
7
+ Pull Request [#15](https://github.com/frodsan/mongoid-minitest/pull/15) - *Ryan McGeary*.
8
+ + Remove support for automatically appending `_id` to fields passed to
9
+ `have_index` matcher. See <https://github.com/frodsan/mongoid-minitest/pull/15#issuecomment-11851098>
10
+ form more information - *Ryan McGeary*.
11
+
1
12
  ## 0.1.4 - October 10, 2012
2
13
 
3
14
  + Bump mongoid version to 3.0.6 - *Francesco Rodriguez*.
data/README.md CHANGED
@@ -8,9 +8,9 @@ MiniTest matchers for Mongoid.
8
8
 
9
9
  This gem supports:
10
10
 
11
- * Ruby 1.9.3
12
- * Mongoid ~>3.0.4
13
- * MiniTest ~>3.4.0
11
+ * Ruby 1.9.3, 2.0.0
12
+ * Mongoid ~>3.0
13
+ * MiniTest ~>4.1
14
14
 
15
15
  If you're using Mongoid 2.4.x, you should use [0.0.3.1 version](https://github.com/frodsan/mongoid-minitest/tree/274976e8814cc9bfb3f1c83eba1bed21fa3cf26b).
16
16
 
@@ -18,7 +18,7 @@ If you're using Mongoid 2.4.x, you should use [0.0.3.1 version](https://github.c
18
18
 
19
19
  Add this line to your application's Gemfile:
20
20
 
21
- gem "mongoid-minitest"
21
+ gem 'mongoid-minitest'
22
22
 
23
23
  And then execute:
24
24
 
@@ -33,7 +33,7 @@ Or install it yourself as:
33
33
  Matchers are available at `Mongoid::Matchers` module.
34
34
  Setup matchers according to your testing preference:
35
35
 
36
- ### minitest/unit
36
+ ### minitest/unit
37
37
 
38
38
  class MiniTest::Unit::TestCase
39
39
  include Mongoid::Matchers
@@ -65,7 +65,7 @@ See the following examples:
65
65
 
66
66
  # minitest/spec with subject
67
67
  describe Dummy
68
- it { must have_field(:name) }
68
+ it { must have_field(:name) }
69
69
  it { wont have_field(:none) }
70
70
  end
71
71
 
@@ -86,7 +86,7 @@ See the following examples:
86
86
  describe Mongoid::Matchers::Document do
87
87
  subject { Person }
88
88
 
89
- it { must be_document } # if model includes Mongoid::Document
89
+ it { must be_document } # if model includes Mongoid::Document
90
90
  it { must be_paranoid } # if model includes Mongoid::Paranoia
91
91
  it { must be_versioned } # if model includes Mongoid::Versioning
92
92
  it { must be_timestamped } # if model includes Mongoid::Timestamps
@@ -104,6 +104,7 @@ See the following examples:
104
104
  it { must have_fields(:name, :login).of_type(String).with_default_value("me") }
105
105
 
106
106
  it { must have_index_for(:name) }
107
+ it { must have_index_for(:account_id, :email) }
107
108
  end
108
109
 
109
110
  ### Validation Matchers
@@ -114,10 +115,10 @@ See the following examples:
114
115
  it { must validate_presence_of(:name) }
115
116
 
116
117
  it { must validate_uniqueness_of(:login).case_insensitive }
117
- it { must validate_uniqueness_of(:login).scoped_to(:site) }
118
+ it { must validate_uniqueness_of(:login).scoped_to(:site) }
118
119
 
119
- it { must validate_length_of(:login).in(5..12) }
120
- it { must validate_length_of(:login).within(5..12) }
120
+ it { must validate_length_of(:login).in(5..12) }
121
+ it { must validate_length_of(:login).within(5..12) }
121
122
 
122
123
  it { must validate_length_of(:password).with_min(8) }
123
124
  it { must validate_length_of(:password).with_minimum(8) }
@@ -125,9 +126,9 @@ See the following examples:
125
126
  it { must validate_length_of(:password).with_maximum(16) }
126
127
 
127
128
  it { must validate_format_of(:email).to_allow("foo@bar.com") }
128
- it { must validate_format_of(:email).to_not_allow("foo_bar_com") }
129
+ it { must validate_format_of(:email).to_not_allow("foo_bar_com") }
129
130
 
130
- it { must validate_inclusion_of(:role).to_allow("user", "admin") }
131
+ it { must validate_inclusion_of(:role).to_allow("user", "admin") }
131
132
  it { must validate_exclusion_of(:email).to_not_allow("foo@bar.com", "fizz@buzz.com") }
132
133
 
133
134
  it { must validate_confirmation_of(:password) }
@@ -136,7 +137,7 @@ See the following examples:
136
137
  it { must validate_associated(:pets) }
137
138
 
138
139
  # Testing validators custom messages
139
- it { must validate_presence_of(:role).with_message("no role") }
140
+ it { must validate_presence_of(:role).with_message("no role") }
140
141
  it { must validate_length_of(:password).with_min(8).with_message("len >= 8") }
141
142
  end
142
143
 
@@ -148,7 +149,7 @@ See the following examples:
148
149
 
149
150
  it { must have_one(:account) }
150
151
  it { must have_many(:pets).of_type(Pet) }
151
- it { must have_and_belong_to_many(:friends) }
152
+ it { must have_and_belong_to_many(:friends) }
152
153
 
153
154
  it { must embed_one(:profile) }
154
155
  it { must embed_many(:sites) }
@@ -157,11 +158,11 @@ See the following examples:
157
158
  describe Pet do
158
159
  subject { Pet }
159
160
 
160
- it { must belong_to(:person) }
161
+ it { must belong_to(:person) }
161
162
  end
162
163
 
163
164
  describe Site do
164
- subject { Site }
165
+ subject { Site }
165
166
 
166
167
  it { must embedded_in(:person) }
167
168
  end
@@ -1,39 +1,36 @@
1
1
  module Mongoid
2
2
  module Matchers
3
3
  class HaveIndexMatcher < Matcher
4
- def initialize(field)
5
- @field = field.to_s
4
+ def initialize(*fields)
5
+ @fields = fields.map(&:to_sym)
6
6
  end
7
7
 
8
8
  def matches?(subject)
9
9
  @klass = class_of(subject)
10
-
11
- @klass.index_options.each do |key, options|
12
- unless key[@field.to_sym] || key[:"#{@field}_id"]
13
- @error = "no index for #{@field.inspect}"
14
-
15
- return false
16
- end
10
+ @klass.index_options.any? do |index, options|
11
+ index.keys == @fields
17
12
  end
18
-
19
- true
20
13
  end
21
14
 
22
15
  def failure_message
23
- "#{@klass} to #{description}, got #{@error}"
16
+ "#{@klass} to #{description}, but only found indexes #{indexes.inspect}"
24
17
  end
25
18
 
26
19
  def negative_failure_message
27
- "#{@klass} to not #{description}, got #{@klass} to #{description}"
20
+ "#{@klass} to not #{description}, but found an index for #{@fields.inspect}"
28
21
  end
29
22
 
30
23
  def description
31
- "have an index for #{@field.inspect}"
24
+ "have an index for #{@fields.inspect}"
25
+ end
26
+
27
+ def indexes
28
+ @klass.index_options.keys.map(&:keys)
32
29
  end
33
30
  end
34
31
 
35
- def have_index_for(field)
36
- HaveIndexMatcher.new(field)
32
+ def have_index_for(*fields)
33
+ HaveIndexMatcher.new(*fields)
37
34
  end
38
35
  end
39
36
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module MiniTest
3
- VERSION = '0.1.4'
3
+ VERSION = '0.1.5'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
5
- prerelease:
4
+ version: 0.1.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Francesco Rodriguez
@@ -11,70 +10,62 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2012-10-13 00:00:00.000000000 Z
13
+ date: 2013-02-26 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: minitest
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
- - - ! '>='
19
+ - - ~>
22
20
  - !ruby/object:Gem::Version
23
- version: 4.0.0
21
+ version: '4.1'
24
22
  type: :runtime
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
- - - ! '>='
26
+ - - ~>
30
27
  - !ruby/object:Gem::Version
31
- version: 4.0.0
28
+ version: '4.1'
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: minitest-matchers
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
33
  - - ~>
38
34
  - !ruby/object:Gem::Version
39
- version: 1.2.0
35
+ version: '1.2'
40
36
  type: :runtime
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
40
  - - ~>
46
41
  - !ruby/object:Gem::Version
47
- version: 1.2.0
42
+ version: '1.2'
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: mongoid
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
47
  - - ~>
54
48
  - !ruby/object:Gem::Version
55
- version: 3.0.6
49
+ version: '3.0'
56
50
  type: :runtime
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
54
  - - ~>
62
55
  - !ruby/object:Gem::Version
63
- version: 3.0.6
56
+ version: '3.0'
64
57
  - !ruby/object:Gem::Dependency
65
58
  name: rake
66
59
  requirement: !ruby/object:Gem::Requirement
67
- none: false
68
60
  requirements:
69
- - - ! '>='
61
+ - - '>='
70
62
  - !ruby/object:Gem::Version
71
63
  version: '0'
72
64
  type: :development
73
65
  prerelease: false
74
66
  version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
67
  requirements:
77
- - - ! '>='
68
+ - - '>='
78
69
  - !ruby/object:Gem::Version
79
70
  version: '0'
80
71
  description: Minitest matchers for Mongoid
@@ -108,27 +99,25 @@ files:
108
99
  - CHANGELOG.md
109
100
  homepage: https://github.com/frodsan/mongoid-minitest
110
101
  licenses: []
102
+ metadata: {}
111
103
  post_install_message:
112
104
  rdoc_options: []
113
105
  require_paths:
114
106
  - lib
115
107
  required_ruby_version: !ruby/object:Gem::Requirement
116
- none: false
117
108
  requirements:
118
- - - ! '>='
109
+ - - '>='
119
110
  - !ruby/object:Gem::Version
120
111
  version: '0'
121
112
  required_rubygems_version: !ruby/object:Gem::Requirement
122
- none: false
123
113
  requirements:
124
- - - ! '>='
114
+ - - '>='
125
115
  - !ruby/object:Gem::Version
126
116
  version: '0'
127
117
  requirements: []
128
118
  rubyforge_project:
129
- rubygems_version: 1.8.23
119
+ rubygems_version: 2.0.0
130
120
  signing_key:
131
- specification_version: 3
121
+ specification_version: 4
132
122
  summary: Minitest matchers for Mongoid
133
123
  test_files: []
134
- has_rdoc: