Module: Minitest::Capybara::Helpers

Defined in:
lib/minitest/capybara/helpers.rb

Class Method Summary collapse

Class Method Details

.count_message(options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/minitest/capybara/helpers.rb', line 20

def self.count_message(options)
  if options[:count]
    " #{options[:count]} #{declension('time', 'times', options[:count])}"
  elsif options[:between]
    " between #{options[:between].first} and #{options[:between].last} times"
  elsif options[:maximum]
    " at most #{options[:maximum]} #{declension('time', 'times', options[:maximum])}"
  elsif options[:minimum]
    " at least #{options[:minimum]} #{declension('time', 'times', options[:minimum])}"
  else
    ""
  end
end

.declension(singular, plural, count) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/minitest/capybara/helpers.rb', line 12

def self.declension(singular, plural, count)
  if count == 1
    singular
  else
    plural
  end
end

.failure_message(description, options = {}) ⇒ Object



4
5
6
# File 'lib/minitest/capybara/helpers.rb', line 4

def self.failure_message(description, options={})
  "expected to find #{description}" + count_message(options)
end

.negative_failure_message(description, options = {}) ⇒ Object



8
9
10
# File 'lib/minitest/capybara/helpers.rb', line 8

def self.negative_failure_message(description, options={})
  "expected not to find #{description}" + count_message(options)
end