Module: RSpec::SqlMatcher::HaveRunQueries
- Defined in:
- lib/rspec/sql_matcher/have_run_queries.rb
Class Method Summary collapse
- .evaluate_expectation(count, options = {}) ⇒ Object
- .failure_message(count, options = {}) ⇒ Object
- .failure_message_when_negated(_count, options = {}) ⇒ Object
Class Method Details
.evaluate_expectation(count, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/rspec/sql_matcher/have_run_queries.rb', line 6 def self.evaluate_expectation(count, = {}) condition = true condition &&= count >= [:min] if [:min] condition &&= count <= [:max] if [:max] condition &&= count == [:exactly] if [:exactly] condition end |
.failure_message(count, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rspec/sql_matcher/have_run_queries.rb', line 15 def self.(count, = {}) return "Expected { } to run #{[:exactly]} queries, but there were #{count} instead." if [:exactly] if [:min] && [:max] return "Expected { } to run a number of query between #{[:min]} and #{[:max]}, but there were #{count} instead." end if [:min] return "Expected { } to run at least #{[:min]} queries, but there were #{count} instead." end return "Expected { } to run at most #{[:max]} queries, but there were #{count} instead." if [:max] 'Invalid expectation parameters. Please pass min, max or exactly.' end |
.failure_message_when_negated(_count, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rspec/sql_matcher/have_run_queries.rb', line 31 def self.(_count, = {}) return "Expected { } not to execute #{[:exactly]} queries, but it did." if [:exactly] if [:min] && [:max] return "Expected { } not to run a number of query between #{[:min]} and #{[:max]}, but it did." end return "Expected { } not to run at least #{[:min]} queries, but it did." if [:min] return "Expected { } not to run at most #{[:max]} queries, but it did." if [:max] 'Invalid expectation parameters. Please pass min, max or exactly.' end |