remockable 0.3.7 → 0.3.8
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/remockable/active_record/have_index.rb +4 -4
- data/lib/remockable/version.rb +1 -1
- data/spec/active_record/have_index_spec.rb +29 -13
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd890b89ca6632cc7b8461f13e0ef884369eaba7aeeec9a60f9ce7e416d39842
|
4
|
+
data.tar.gz: c38b42c84ca19e6a25a79583ea485bc5ce2443b18b12a1bc5755942d6cf07bed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db7c72e95d189e453a5d65aad26a11f20d4995e28ca0809d1d821fc232891ef4991d62f4a355df4e5d9ef54072017325aa59bfbcde1258abac04f845c63938c7
|
7
|
+
data.tar.gz: 908cb59b56057aa44417ed2e6219577cddf7a50607f07afbda28d700b1bece69ec0c3f4c7eb26a9177016f187efd5b92f289873f09e63a7246ba06f3ea3d6544
|
data/CHANGELOG.md
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
RSpec::Matchers.define(:have_index) do
|
2
2
|
include Remockable::ActiveRecord::Helpers
|
3
3
|
|
4
|
-
valid_options %w(name unique)
|
4
|
+
valid_options %w(name unique where)
|
5
5
|
|
6
6
|
def column_names
|
7
7
|
@column_names ||= expected_as_array.flatten.collect(&:to_s)
|
8
8
|
end
|
9
9
|
|
10
10
|
match do |actual|
|
11
|
-
name = options
|
12
|
-
unique = options[:unique]
|
11
|
+
name, unique, where = options.values_at(:name, :unique, :where)
|
13
12
|
indexes = ActiveRecord::Base.connection.indexes(subject.class.table_name)
|
14
13
|
|
15
14
|
index = indexes.detect do |index|
|
@@ -23,8 +22,9 @@ RSpec::Matchers.define(:have_index) do
|
|
23
22
|
if index
|
24
23
|
name_matches = name.nil? || matches_name?(index, name)
|
25
24
|
unique_matches = unique.nil? || index.unique == unique
|
25
|
+
where_matches = where.nil? || index.where == where
|
26
26
|
|
27
|
-
name_matches && unique_matches
|
27
|
+
name_matches && unique_matches && where_matches
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
data/lib/remockable/version.rb
CHANGED
@@ -45,6 +45,28 @@ describe :have_index do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
context 'with option :name' do
|
49
|
+
it 'matches if the index exists' do
|
50
|
+
ActiveRecord::Base.connection.add_index :users, :one, name: :oneness
|
51
|
+
expect(model).to have_index :one, name: :oneness
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'does not match if the index does not exist' do
|
55
|
+
expect(model).to_not have_index :one, name: :oneness
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'with option :name and without :one' do
|
60
|
+
it 'matches if the index exists' do
|
61
|
+
ActiveRecord::Base.connection.add_index :users, :one, name: :oneness
|
62
|
+
expect(model).to have_index name: :oneness
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'does not match if the index does not exist' do
|
66
|
+
expect(model).to_not have_index name: :oneness
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
48
70
|
context 'with option :unique' do
|
49
71
|
it 'matches if the index exists' do
|
50
72
|
ActiveRecord::Base.connection.add_index :users, :one, unique: true
|
@@ -61,25 +83,19 @@ describe :have_index do
|
|
61
83
|
end
|
62
84
|
end
|
63
85
|
|
64
|
-
context 'with option :
|
86
|
+
context 'with option :where' do
|
65
87
|
it 'matches if the index exists' do
|
66
|
-
ActiveRecord::Base.connection.add_index :users, :one,
|
67
|
-
expect(model).to have_index :one,
|
88
|
+
ActiveRecord::Base.connection.add_index :users, :one, where: 'two = 2'
|
89
|
+
expect(model).to have_index :one, where: 'two = 2'
|
68
90
|
end
|
69
91
|
|
70
|
-
it 'does not match if the index
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'with option :name and without :one' do
|
76
|
-
it 'matches if the index exists' do
|
77
|
-
ActiveRecord::Base.connection.add_index :users, :one, name: :oneness
|
78
|
-
expect(model).to have_index name: :oneness
|
92
|
+
it 'does not match if the index conditions are different' do
|
93
|
+
ActiveRecord::Base.connection.add_index :users, :one, where: 'two = 2'
|
94
|
+
expect(model).to_not have_index :one, where: 'two = 1'
|
79
95
|
end
|
80
96
|
|
81
97
|
it 'does not match if the index does not exist' do
|
82
|
-
expect(model).to_not have_index
|
98
|
+
expect(model).to_not have_index :one, where: 'two = 2'
|
83
99
|
end
|
84
100
|
end
|
85
101
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remockable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Hunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
253
|
- !ruby/object:Gem::Version
|
254
254
|
version: '0'
|
255
255
|
requirements: []
|
256
|
-
rubygems_version: 3.1.
|
256
|
+
rubygems_version: 3.1.6
|
257
257
|
signing_key:
|
258
258
|
specification_version: 4
|
259
259
|
summary: A collection of RSpec matchers for web apps.
|