Sha256: 68534eea00cfee842fc240b4207cf4e0e038efa2f22041554d52fb78b7be1be5

Contents?: true

Size: 1.17 KB

Versions: 31

Compression:

Stored size: 1.17 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

RSpec::Matchers.define :offset do |num|
  match do |collection|
    collection.offset_value == num
  end
end

Version data entries

31 entries across 31 versions & 9 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/kaminari-0.17.0/spec/support/matchers.rb
bootstrap_pager-0.11.0 spec/support/matchers.rb
kaminari-0.17.0 spec/support/matchers.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/kaminari-0.16.3/spec/support/matchers.rb
bootstrap_pager-0.10.1 spec/support/matchers.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/kaminari-0.16.3/spec/support/matchers.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/kaminari-0.16.3/spec/support/matchers.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/kaminari-0.16.3/spec/support/matchers.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/kaminari-0.16.3/spec/support/matchers.rb
bootstrap_pager-0.10.0 spec/support/matchers.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/kaminari-0.16.3/spec/support/matchers.rb
kaminari-0.16.3 spec/support/matchers.rb
kaminari-0.16.2 spec/support/matchers.rb
bootstrap_pager-0.9.3 spec/support/matchers.rb
kaminari-0.16.1 spec/support/matchers.rb
kaminari-0.16.0 spec/support/matchers.rb
kaminari-0.15.1 spec/support/matchers.rb
kaminari-0.15.0 spec/support/matchers.rb
bootstrap_pager-0.9.2 spec/support/matchers.rb
bootstrap_pager-0.9.1 spec/support/matchers.rb