query_matchers 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/query_matchers/version.rb +1 -1
- data/query_matchers.gemspec +2 -2
- data/spec/query_counter_spec.rb +7 -7
- data/spec/query_execution_matcher_spec.rb +9 -9
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f78d721c38dc71a9253a97fcfa30a776b3b5b721
|
4
|
+
data.tar.gz: 92641ed402a948cea988adcc6bbdfe5a28c6ea13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8225933bccc86b9dda7dd7d6ca23222b87be5867e9b683a7e9134992c19744d63155cbddb6128ae959684850a915bd701ca3a9b4b3115aa49d8353a15330cabf
|
7
|
+
data.tar.gz: 31c22139aaeaa65f0849652049548333980b638ee2c86a7b327ddc7e1201c838d43888b92808db8290f984634e38dad364e0c8fd8c0486768c4da4b07aea5d94
|
data/query_matchers.gemspec
CHANGED
@@ -17,9 +17,9 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_runtime_dependency "activesupport", ["> 3.0", "< 5.
|
20
|
+
spec.add_runtime_dependency "activesupport", ["> 3.0", "< 5.2"]
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.5"
|
23
23
|
spec.add_development_dependency "rake"
|
24
|
-
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
25
|
end
|
data/spec/query_counter_spec.rb
CHANGED
@@ -8,44 +8,44 @@ describe QueryMatchers::QueryCounter do
|
|
8
8
|
query = "SELECT * FROM somewhere"
|
9
9
|
counter.execute!(sql_target(query))
|
10
10
|
|
11
|
-
counter.queries.
|
11
|
+
expect(counter.queries).to eq([query])
|
12
12
|
end
|
13
13
|
|
14
14
|
it "counts the number of queries performed in the target block" do
|
15
15
|
target = proc { 3.times { perform_sql("INSERT INTO jokes") } }
|
16
16
|
counter.execute!(target)
|
17
17
|
|
18
|
-
counter.query_count.
|
18
|
+
expect(counter.query_count).to eq(3)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "counts INSERT queries" do
|
22
22
|
counter.execute!(sql_target("INSERT INTO jokes"))
|
23
23
|
|
24
|
-
counter.query_count.
|
24
|
+
expect(counter.query_count).to eq(1)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "counts UPDATE queries" do
|
28
28
|
counter.execute!(sql_target("UPDATE mood SET laughing = 0"))
|
29
29
|
|
30
|
-
counter.query_count.
|
30
|
+
expect(counter.query_count).to eq(1)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "counts DELETE queries" do
|
34
34
|
counter.execute!(sql_target("DELETE FROM goodwill"))
|
35
35
|
|
36
|
-
counter.query_count.
|
36
|
+
expect(counter.query_count).to eq(1)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "counts SELECT queries" do
|
40
40
|
counter.execute!(sql_target("SELECT FROM inventory"))
|
41
41
|
|
42
|
-
counter.query_count.
|
42
|
+
expect(counter.query_count).to eq(1)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "doesn't count any other type of query" do
|
46
46
|
counter.execute!(sql_target("BREAKDANCE"))
|
47
47
|
|
48
|
-
counter.query_count.
|
48
|
+
expect(counter.query_count).to eq(0)
|
49
49
|
end
|
50
50
|
|
51
51
|
def sql_target(sql)
|
@@ -7,22 +7,22 @@ describe QueryMatchers::QueryExecutionMatcher do
|
|
7
7
|
|
8
8
|
describe "#matches?" do
|
9
9
|
before do
|
10
|
-
counter.
|
10
|
+
allow(counter).to receive(:execute!)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "executes the target" do
|
14
14
|
matcher.matches?(:whatever)
|
15
|
-
counter.
|
15
|
+
expect(counter).to have_received(:execute!).with(:whatever)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "returns true if the number of queries performed matched the expectation" do
|
19
|
-
counter.
|
20
|
-
matcher.matches?(:whatever).
|
19
|
+
allow(counter).to receive(:query_count) { 4 }
|
20
|
+
expect(matcher.matches?(:whatever)).to eq(true)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "returns false if the number of queries performed doesn't match the expectation" do
|
24
|
-
counter.
|
25
|
-
matcher.matches?(:whatever).
|
24
|
+
allow(counter).to receive(:query_count) { 3 }
|
25
|
+
expect(matcher.matches?(:whatever)).to eq(false)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -31,10 +31,10 @@ describe QueryMatchers::QueryExecutionMatcher do
|
|
31
31
|
query1 = "SELECT FROM jokes WHERE puns > 3"
|
32
32
|
query2 = "DELETE FROM jokes WHERE inappropriate = 1"
|
33
33
|
|
34
|
-
counter.
|
35
|
-
counter.
|
34
|
+
allow(counter).to receive(:query_count) { 99 }
|
35
|
+
allow(counter).to receive(:queries) { [query1, query2] }
|
36
36
|
|
37
|
-
matcher.failure_message.
|
37
|
+
expect(matcher.failure_message).to eq <<-MESSAGE.strip_heredoc.chomp
|
38
38
|
expected block to execute 4 SQL queries, but executed 99:
|
39
39
|
|
40
40
|
- SELECT FROM jokes WHERE puns > 3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: query_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schierbeck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '3.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '5.
|
22
|
+
version: '5.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '3.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '5.
|
32
|
+
version: '5.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,16 +62,16 @@ dependencies:
|
|
62
62
|
name: rspec
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
67
|
+
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - "
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: '0'
|
75
75
|
description:
|
76
76
|
email:
|
77
77
|
- dasch@zendesk.com
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.6.
|
114
|
+
rubygems_version: 2.6.11
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Match the number of queries performed in any block of code
|