Sha256: 1b9fc674b88e7ce9744e526a754e23a4e635d4ae572087c7514b9114a54001cf

Contents?: true

Size: 915 Bytes

Versions: 14

Compression:

Stored size: 915 Bytes

Contents

# RSpec matcher to spec delegations.

RSpec::Matchers.define :have_unique_field do |expected_field_name|
  match do |subject|
    subject.should respond_to(expected_field_name)
    field_value = subject.send(expected_field_name)
    field_value.nil? || !field_value.kind_of?(Array)
  end

  description do
    "expected to have a single-valued field named #{expected_field_name}"
  end

  failure_message_for_should do |subject|
    "#{subject.inspect} should respond to #{expected_field_name} as a single-value, not an Array. Responded with #{subject.send(expected_field_name).inspect}"
  end
end

RSpec::Matchers.define :have_multivalue_field do |expected_field_name|
  match do |subject|
    subject.should respond_to(expected_field_name)
    subject.send(expected_field_name).should be_instance_of Array
  end

  description do
    "expected to have a multi-valued field named #{expected_field_name}"
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
worthwhile-0.0.1 spec/matchers/metadata_field_matchers.rb
curate-0.6.6 spec/matchers/metadata_field_matchers.rb
curate-0.6.5 spec/matchers/metadata_field_matchers.rb
curate-0.6.4 spec/matchers/metadata_field_matchers.rb
curate-0.6.3 spec/matchers/metadata_field_matchers.rb
curate-0.6.1 spec/support/matchers/metadata_field_matchers.rb
curate-0.6.0 spec/support/matchers/metadata_field_matchers.rb
curate-0.5.6 spec/support/matchers/metadata_field_matchers.rb
curate-0.5.5 spec/support/matchers/metadata_field_matchers.rb
curate-0.5.4 spec/support/matchers/metadata_field_matchers.rb
curate-0.5.2 spec/support/matchers/metadata_field_matchers.rb
curate-0.5.1 spec/support/matchers/metadata_field_matchers.rb
curate-0.5.0 spec/support/matchers/metadata_field_matchers.rb
curate-0.4.2 spec/support/matchers/metadata_field_matchers.rb