Sha256: 2feaa106318c9b8fa1efbc14435332ab260d648af7a199afd1429fef625742a4

Contents?: true

Size: 941 Bytes

Versions: 1

Compression:

Stored size: 941 Bytes

Contents

require "active_support/concern"
module RSpec
  module ViewComponent
    module Context
      extend ActiveSupport::Concern

      included do
        RSpec.shared_context "ViewComponent" do
          subject do
            render_inline component, &content
            rendered_component
          end

          let(:component) do
            described_class.new(
              *(defined?(args) ? args : []),
              **(defined?(kwargs) ? kwargs : {})
            )
          end
          let(:content) { ->(_view_context = nil) {} }
          let(:component_instance) do
            rendered_content = content.call
            rendered_content ? component.with_content(rendered_content) : component
          end

          matcher :be_rendered do
            match do |actual|
              expect(actual).to be_render
            end
          end
        end

        include_context "ViewComponent"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-viewcomponent-0.1.0 lib/rspec/viewcomponent/context.rb