Class: ActiveStorageMatchers::IncludeBlobUrls

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/dev/test/rspec_support/activestorage_matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ IncludeBlobUrls

Returns a new instance of IncludeBlobUrls.



115
116
117
# File 'lib/decidim/dev/test/rspec_support/activestorage_matchers.rb', line 115

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



119
120
121
# File 'lib/decidim/dev/test/rspec_support/activestorage_matchers.rb', line 119

def description
  "include blob URLs"
end

#failure_messageObject



132
133
134
# File 'lib/decidim/dev/test/rspec_support/activestorage_matchers.rb', line 132

def failure_message
  "expected #{actual.inspect} to match blobs with ID #{expected.map(&:id).join(", ")}"
end

#failure_message_when_negatedObject



136
137
138
# File 'lib/decidim/dev/test/rspec_support/activestorage_matchers.rb', line 136

def failure_message_when_negated
  "expected #{actual.inspect} not to match blobs with ID #{expected.map(&:id).join(", ")}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


123
124
125
126
127
128
129
130
# File 'lib/decidim/dev/test/rspec_support/activestorage_matchers.rb', line 123

def matches?(actual)
  @actual = actual

  actual.all? do |url|
    match = BlobMatch.new(url)
    expected.include?(match.blob)
  end
end