Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions spec/components/chapter_picker_component_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'rails_helper'
require 'view_component/test_helpers'

RSpec.describe ChapterPickerComponent do
include ViewComponent::TestHelpers

let(:chapters) { Fabricate.times(3, :chapter) }

it 'renders a text input with datalist attributes' do
Expand Down
2 changes: 0 additions & 2 deletions spec/components/chapters_sidebar_component_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require 'rails_helper'
require 'view_component/test_helpers'

RSpec.describe ChaptersSidebarComponent do
include ViewComponent::TestHelpers
include Rails.application.routes.url_helpers

let(:chapters) { Fabricate.times(3, :chapter) }
Expand Down
2 changes: 0 additions & 2 deletions spec/components/event_card_component_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require 'rails_helper'
require 'view_component/test_helpers'

RSpec.describe EventCardComponent, type: :component do
include ViewComponent::TestHelpers
let(:chapter) { Fabricate(:chapter, active: true) }

context 'with a workshop' do
Expand Down
13 changes: 8 additions & 5 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@
config.use_transactional_fixtures = true

# RSpec Rails can automatically mix in different behaviours based on the
# file location of the spec. This line needs to be present for ViewComponent
# to work with controller specs
# file location of the spec.
# Register the spec/components directory mapping BEFORE inference runs —
# `infer_spec_type_from_file_location!` snapshots DIRECTORY_MAPPINGS at call time.
RSpec::Rails::DIRECTORY_MAPPINGS[:component] = %w[spec components]
config.infer_spec_type_from_file_location!

# Connect ViewComponent to RSpec, adding RSpec metadata type: :component.
# This extends Rails' own built-in (e.g. "type: :controller") metadata system.
RSpec::Rails::DIRECTORY_MAPPINGS[:component] = %w[spec/components]
# ViewComponent does not wire its RSpec helpers into RSpec itself (no
# lib/view_component/rspec.rb in v4), so include them for type: :component specs.
require 'view_component/test_helpers'
config.include ViewComponent::TestHelpers, type: :component

# Filter lines from Rails gems in backtraces.
config.filter_rails_from_backtrace!
Expand Down