class Array
Public Instance Methods
last()
click to toggle source
# File lib/spectre/helpers.rb, line 121 def last self[-1] end
should_be_empty()
click to toggle source
# File lib/spectre/assertion.rb, line 93 def should_be_empty raise AssertionFailure.new('empty list', self) unless self.empty? end
should_contain(val)
click to toggle source
# File lib/spectre/assertion.rb, line 71 def should_contain(val) list = self if val.is_a? Hash and self.all? { |x| x.is_a? OpenStruct or x.is_a? Hash } list = self.map { |x| OpenStruct.new(x) } val = OpenStruct.new(val) end raise AssertionFailure.new("The list [#{list.join(', ').trim}] should contain '#{val.to_s.trim}'", val, list) unless list.include? val end
should_not_be_empty()
click to toggle source
# File lib/spectre/assertion.rb, line 97 def should_not_be_empty raise AssertionFailure.new('no empty list', self) if self.empty? end
should_not_contain(val)
click to toggle source
# File lib/spectre/assertion.rb, line 82 def should_not_contain(val) list = self if val.is_a? Hash and self.all? { |x| x.is_a? OpenStruct or x.is_a? Hash } list = self.map { |x| OpenStruct.new(x) } val = OpenStruct.new(val) end raise AssertionFailure.new("The list [#{list.join(', ').trim}] should not contain '#{val.to_s.trim}'", val, list) if list.include? val end