Class: Cashier::Matchers::Cache
- Inherits:
-
Object
- Object
- Cashier::Matchers::Cache
- Defined in:
- lib/cashier/matchers.rb
Instance Method Summary collapse
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
- #matches?(target) ⇒ Boolean
Instance Method Details
#failure_message_for_should ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/cashier/matchers.rb', line 19 def <<-msg expected the Rails.cache to include all these keys: #{Cashier.keys_for(@target).to_sentence}, but it did not include these keys: #{@test_results.keys.select {|k| @test_results[k] == false }.to_sentence} msg end |
#failure_message_for_should_not ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/cashier/matchers.rb', line 28 def <<-msg expected the Rails.cache to not include all these keys: #{Cashier.keys_for(@target).to_sentence}, but it did include these keys: #{@test_results.keys.select {|k| @test_results[k] == true }.to_sentence} msg end |
#matches?(target) ⇒ Boolean
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/cashier/matchers.rb', line 8 def matches?(target) @target = target @test_results = Cashier.keys_for(@target).inject({}) do |hash, key| hash.merge(key => Rails.cache.exist?(key)) end flag = @test_results.values.inject(true) { |f, v| f && v } flag && Cashier.keys_for(@target).present? end |