mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add (very simple) spec for a ViewComponent component
- Add `ViewComponent::TestHelpers` to get the helper method `render_inline` - Use Capybara to expect some assertion
This commit is contained in:
8
spec/components/example_component_spec.rb
Normal file
8
spec/components/example_component_spec.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "ExampleComponent tests", type: :component do
|
||||
it "displays the h1 with the given parameter" do
|
||||
render_inline(ExampleComponent.new(title: "Hello")) { }
|
||||
expect(page).to have_selector "h1", text: "Hello"
|
||||
end
|
||||
end
|
||||
@@ -74,6 +74,8 @@ require "paperclip/matchers"
|
||||
# Override setting in Spree engine: Spree::Core::MailSettings
|
||||
ActionMailer::Base.default_url_options[:host] = 'test.host'
|
||||
|
||||
require "view_component/test_helpers"
|
||||
|
||||
RSpec.configure do |config|
|
||||
# ## Mock Framework
|
||||
#
|
||||
@@ -232,6 +234,8 @@ RSpec.configure do |config|
|
||||
# PerfTools::CpuProfiler.stop
|
||||
# end
|
||||
config.infer_spec_type_from_file_location!
|
||||
|
||||
config.include ViewComponent::TestHelpers, type: :component
|
||||
end
|
||||
|
||||
FactoryBot.use_parent_strategy = false
|
||||
|
||||
Reference in New Issue
Block a user