Define and apply matcher :be_rendered

Add this changes to make components specs clear
This commit is contained in:
taitus
2021-11-03 18:17:30 +01:00
parent 2b35144540
commit 612872ac7a
20 changed files with 41 additions and 28 deletions

View File

@@ -49,7 +49,7 @@ describe Admin::Budgets::DurationComponent do
render Admin::Budgets::DurationComponent.new(durable).duration
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "is not defined when no start date is defined" do
@@ -57,7 +57,7 @@ describe Admin::Budgets::DurationComponent do
render Admin::Budgets::DurationComponent.new(durable).duration
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
end

View File

@@ -6,7 +6,7 @@ describe Admin::BudgetsWizard::Headings::GroupSwitcherComponent do
render_inline Admin::BudgetsWizard::Headings::GroupSwitcherComponent.new(group)
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "renders a link to switch group for budgets with two groups" do

View File

@@ -16,7 +16,7 @@ describe Budgets::Investments::FiltersComponent do
render_inline Budgets::Investments::FiltersComponent.new
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
end

View File

@@ -28,7 +28,7 @@ describe Budgets::SupportsInfoComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
describe "#total_supports" do

View File

@@ -13,7 +13,7 @@ describe Layout::LocaleSwitcherComponent do
it "doesn't render anything" do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
end

View File

@@ -33,7 +33,7 @@ describe Layout::SocialComponent do
render_inline Layout::SocialComponent.new
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
end
end

View File

@@ -13,7 +13,7 @@ describe Layout::TopLinksComponent do
it "does not render when no content block is defined" do
render_inline Layout::TopLinksComponent.new
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
end
end

View File

@@ -22,7 +22,7 @@ describe MachineLearning::CommentsSummaryComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "is not displayed when the machine learning feature is disabled" do
@@ -30,7 +30,7 @@ describe MachineLearning::CommentsSummaryComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "is not displayed when there's no summary" do
@@ -38,6 +38,6 @@ describe MachineLearning::CommentsSummaryComponent do
render_inline MachineLearning::CommentsSummaryComponent.new(commentable)
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
end

View File

@@ -13,7 +13,7 @@ describe SDG::Goals::HelpPageComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "renders content when the feature is enabled" do

View File

@@ -14,7 +14,7 @@ describe SDG::Goals::PlainTagListComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "does not render when the SDG process feature is disabled" do

View File

@@ -14,7 +14,7 @@ describe SDG::Goals::TagListComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "does not render when the SDG process feature is disabled" do
@@ -22,7 +22,7 @@ describe SDG::Goals::TagListComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "renders a list of goals" do

View File

@@ -13,7 +13,7 @@ describe SDG::Goals::TargetsComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "renders tabs panel" do

View File

@@ -15,7 +15,7 @@ describe SDG::RelatedListSelectorComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "does not render when the SDG process feature is disabled" do
@@ -23,7 +23,7 @@ describe SDG::RelatedListSelectorComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "renders related_sdg_list field" do

View File

@@ -27,7 +27,7 @@ describe SDG::TagListComponent do
render_inline SDG::TagListComponent.new(record)
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
context "when linkable is false" do

View File

@@ -18,7 +18,7 @@ describe SDG::Targets::PlainTagListComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "does not render when the SDG process feature is disabled" do
@@ -26,7 +26,7 @@ describe SDG::Targets::PlainTagListComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "renders a list of targets" do

View File

@@ -18,7 +18,7 @@ describe SDG::Targets::TagListComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "does not render when the SDG process feature is disabled" do
@@ -26,7 +26,7 @@ describe SDG::Targets::TagListComponent do
render_inline component
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "renders a list of targets" do

View File

@@ -82,13 +82,13 @@ describe Shared::BannerComponent do
render_inline Shared::BannerComponent.new("debates")
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
end
it "does not render anything given nil" do
render_inline Shared::BannerComponent.new(nil)
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
end

View File

@@ -4,13 +4,13 @@ describe Shared::LinkListComponent do
it "renders nothing with an empty list" do
render_inline Shared::LinkListComponent.new
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "returns nothing with a list of nil elements" do
render_inline Shared::LinkListComponent.new(nil, nil)
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
it "generates a list of links" do

View File

@@ -42,6 +42,6 @@ describe Shared::TagListComponent do
it "is not rendered when there are no tags" do
render_inline Shared::TagListComponent.new(Proposal.new, limit: nil)
expect(page.native.inner_html).to be_empty
expect(page).not_to be_rendered
end
end

View File

@@ -0,0 +1,13 @@
RSpec::Matchers.define :be_rendered do
match do |page|
!page.native.inner_html.empty?
end
failure_message_when_negated do |page|
if page.has_css?("body")
"expected page not to be rendered, but was rendered with #{page.find("body").native.inner_html}"
else
"expected page not to be rendered, but was rendered with #{page.native.inner_html}"
end
end
end