Module: Shoulda::Matchers::ViewComponent

Defined in:
lib/shoulda/matchers/view_component.rb,
lib/shoulda/matchers/view_component/version.rb,
lib/shoulda/matchers/view_component/use_collection_parameter.rb

Defined Under Namespace

Classes: UseCollectionParameter

Constant Summary collapse

VERSION =
"1.0.0"

Instance Method Summary collapse

Instance Method Details

#use_collection_parameter(value) ⇒ HaveReadonlyAttributeMatcher

The ‘use_collection_parameter` matcher tests usage of the `with_collection_parameter` macro.

class ProductComponent < ViewComponent::Base
  with_collection_parameter :product

  def initialize(product:)
  end
end

# RSpec
RSpec.describe ProductComponent, type: :component do
  it { expect(described_class).to use_collection_parameter(:product) }
end

# Minitest (Shoulda)
class ProductComponentTest < ActiveSupport::TestCase
  should use_collection_parameter(:product)
end


28
29
30
# File 'lib/shoulda/matchers/view_component/use_collection_parameter.rb', line 28

def use_collection_parameter(value)
  UseCollectionParameter.new(value)
end