Skip to content

Commit

Permalink
Add extra specs covering absent values
Browse files Browse the repository at this point in the history
In these cases, where the attribute value is nil or an empty string, no
attribute should be added to the element.
  • Loading branch information
peteryates committed Apr 12, 2021
1 parent fa22de2 commit b8c171c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/support/shared/shared_html_attribute_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,15 @@
expect(parsed_subject).to contain_element(described_element).with_attribute("aria-describedby").that_has_values(custom_aria_described_by, generated_hint_id)
end
end

context 'when an empty string is provided' do
let(:data_attribute) { 'importance' }
subject do
builder.send(*args, data: { data_attribute => "" })
end

specify 'no attribute should be present' do
expect(parsed_subject.at_css(described_element).attributes).not_to have_key("data-#{data_attribute}")
end
end
end

0 comments on commit b8c171c

Please sign in to comment.