Sha256: 4e2a68422c7c6fc4f64ed3c070214f347f5195a9cc991ed4c60768e75db6f052

Contents?: true

Size: 1.06 KB

Versions: 19

Compression:

Stored size: 1.06 KB

Contents

RSpec::Matchers.define :contain_tag do |klass|
  match do |collection|
    if @num.blank?
      collection.any? {|tag| tag.is_a? klass}
    else
      (@count = collection.count {|tag| tag.is_a? klass}) == @num
    end
  end

  def count(num)
    @num = num
    self
  end

  description do
    "contain #{@num || 'any'} instance(s) of #{klass.name}"
  end
  failure_message_for_should do |collection|
    "expected #{@num || 'any'} instance(s) of #{klass.name} but was #{@count}"
  end
end

RSpec::Matchers.define :contain_tag_old do |count|
  match do |collection|
    (@count = collection.count {|tag| tag.is_a? @klass}) == count
  end

  def instance_of(klass)
    @klass = klass
    self
  end
  alias :instances_of :instance_of

  description do
    "contain #{count || 'any'} instance(s) of #{@klass.name}"
  end
  failure_message_for_should do |collection|
    "expected #{count || 'any'} instance(s) of #{@klass.name} but was #{@count}"
  end
end

RSpec::Matchers.define :skip do |num|
  match do |criteria|
    criteria.instance_variable_get('@options')[:skip] == num
  end
end

Version data entries

19 entries across 19 versions & 5 rubygems

Version Path
wulffeld_kaminari-0.12.4.2 spec/support/matchers.rb
wulffeld_kaminari-0.12.4.1 spec/support/matchers.rb
sayso-kaminari-0.12.4.001 spec/support/matchers.rb
dimkiriyenko-kaminari-0.12.6 spec/support/matchers.rb
dimkiriyenko-kaminari-0.12.5 spec/support/matchers.rb
dimkiriyenko-kaminari-0.12.4 spec/support/matchers.rb
kaminari-0.12.4 spec/support/matchers.rb
kaminari-0.12.3 spec/support/matchers.rb
kaminari-0.12.2 spec/support/matchers.rb
kaminari-0.12.1 spec/support/matchers.rb
kaminari-0.12.0 spec/support/matchers.rb
kaminari-0.11.0 spec/support/matchers.rb
zhanghd_kaminari-0.10.4.1 spec/support/matchers.rb
kaminari-0.10.4 spec/support/matchers.rb
kaminari-0.10.3 spec/support/matchers.rb
kaminari-0.10.2 spec/support/matchers.rb
kaminari-0.10.1 spec/support/matchers.rb
kaminari-0.10.0 spec/support/matchers.rb
kaminari-0.9.13 spec/support/matchers.rb