Sha256: 1c374794ea6e3c838d880b361623b8084fb1d55d40760f8d75365d796bda07b8

Contents?: true

Size: 890 Bytes

Versions: 6

Compression:

Stored size: 890 Bytes

Contents

ORDINALS = [:first,:second,:third,:fourth,:fifth]

RSpec::Matchers.define :set_the_attribute do |expected|
  match do |annotations|
    @attribute = expected.keys.first
    @value     = expected.values.first
    if @ordinal
      @actual = annotations[ORDINALS.index(@ordinal)].send(@attribute)
       @actual == @value
    else
      annotations.all?{|a| a.send(@attribute) == @value }
    end
  end

  chain :only_for_the do |ordinal|
    @ordinal = ordinal
  end

  description do
    string = "set the annotation #{@attribute} attribute to \"#{@value}\""
    string << " for the #{@ordinal} annotation" if @ordinal
    string
  end

  failure_message_for_should do |annotations|
    message = "expected \"#{@attribute}\" to be \"#{@value}\" "
    message + if @ordinal
      "but was \"#{actual}\" for the #{@ordinal} annotation"
    else
      "for all annotations"
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
scaffolder-annotation-locator-0.2.0 spec/support/gff_attribute_matcher.rb
scaffolder-annotation-locator-0.1.4 spec/support/gff_attribute_matcher.rb
scaffolder-annotation-locator-0.1.2 spec/support/gff_attribute_matcher.rb
scaffolder-annotation-locator-0.1.1 spec/support/gff_attribute_matcher.rb
scaffolder-annotation-locator-0.1.0 spec/support/gff_attribute_matcher.rb
scaffolder-annotation-locator-0.0.1 spec/support/gff_attribute_matcher.rb