Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HintComponent and ErrorMessageComponent #98

Merged
merged 17 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix specs
  • Loading branch information
tmaier committed Jan 26, 2022
commit 50e08a402be1519c31db559f5a3680c4f47bf7d0
2 changes: 2 additions & 0 deletions spec/view_component/form/error_message_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

RSpec.describe ViewComponent::Form::ErrorMessageComponent, type: :component do
subject(:rendered_component) { render_inline(component) }

let(:component) { described_class.new(form, object_name, :first_name, options) }

let(:object_klass) do
Expand All @@ -27,6 +28,7 @@ def name

context "with valid object" do
subject { component }

let(:object) { object_klass.new(first_name: "John") }

before { object.validate }
Expand Down
6 changes: 3 additions & 3 deletions spec/view_component/form/hint_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

RSpec.describe ViewComponent::Form::HintComponent, type: :component do
subject(:rendered_component) { render_inline(component) }

let(:component) { described_class.new(form, object_name, :birth_date, "this is my hint for you", options) }
let(:object) { OpenStruct.new }
let(:form) { form_with(object) }
let(:options) { {} }
let(:component_html_attributes) { component.css("div").first.attributes }
let(:component_html_attributes) { rendered_component.css("div").first.attributes }

context "with simple args" do
it { is_expected.to eq_html '<div>this is my hint for you</div>' }
it { is_expected.to eq_html "<div>this is my hint for you</div>" }
end

include_examples "component with custom html classes"
Expand Down