source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/start_button_helpers.rb | Ruby | mit | 188 | main | 347 | module Examples
module StartButtonHelpers
def start_button_normal
<<~START_BUTTON
= govuk_start_button(text: "Start now", href: "#")
START_BUTTON
end
def start_button_as_button
<<~START_BUTTON
= govuk_start_button(text: "Start now", href: "#", as_button: true)
STAR... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/accordion_helpers.rb | Ruby | mit | 188 | main | 848 | module Examples
module AccordionHelpers
def accordion_normal
<<~ACCORDION
= govuk_accordion do |accordion|
- accordion.with_section(heading_text: "One") { tag.p("One content") }
- accordion.with_section(heading_text: "Two") { tag.p("Two content") }
- accordion.with_se... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/breadcrumbs_helpers.rb | Ruby | mit | 188 | main | 1,956 | module Examples
module BreadcrumbsHelpers
def breadcrumbs_normal
<<~BREADCRUMBS
= govuk_breadcrumbs(breadcrumbs: breadcrumbs)
BREADCRUMBS
end
def breadcrumbs_that_collapse_on_mobile
<<~BREADCRUMBS
= govuk_breadcrumbs(breadcrumbs: breadcrumbs, collapse_on_mobile: true)
... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/common_options_helpers.rb | Ruby | mit | 188 | main | 534 | module Examples
module CommonOptionsHelpers
def inset_text_with_classes
<<~LINK
= govuk_inset_text(classes: "govuk-!-font-weight-bold")
| Some strong text
LINK
end
def inset_text_with_html_attributes
<<~LINK
= govuk_inset_text(html_attributes: { lang: "en-GB",
... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/visually_hidden_helpers.rb | Ruby | mit | 188 | main | 471 | module Examples
module VisuallyHiddenHelpers
def visually_hidden_text_via_argument
<<~SNIPPET
p Regular text
= govuk_visually_hidden("This content is visually hidden")
p More regular text
SNIPPET
end
def visually_hidden_text_via_block
<<~SNIPPET
p Regul... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/tabs_helpers.rb | Ruby | mit | 188 | main | 493 | module Examples
module TabsHelpers
def tabs_normal
<<~TABS
= govuk_tabs do |tabs|
- tabs.with_tab(label: "Text", text: "This was set using a text argument")
- tabs.with_tab(label: "Inline block") { "This was set using an inline block of content" }
- tabs.with_tab(label:... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/service_navigation_helpers.rb | Ruby | mit | 188 | main | 3,799 | module Examples
module ServiceNavigationHelpers
def service_navigation_with_only_service_name
<<~SNIPPET
= govuk_service_navigation(service_name: "My new service", service_url: "#")
SNIPPET
end
def service_navigation_with_a_current_page
<<~SNIPPET
= govuk_service_navigat... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/exit_this_page_helpers.rb | Ruby | mit | 188 | main | 1,047 | module Examples
module BreadcrumbsHelpers
def exit_this_page_normal
<<~EXIT_THIS_PAGE
= govuk_exit_this_page
EXIT_THIS_PAGE
end
def exit_this_page_custom_link_and_text
<<~EXIT_THIS_PAGE
= govuk_exit_this_page(text: "Leave this page", redirect_url: "https://www.bbc.co.uk/... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/warning_text_helpers.rb | Ruby | mit | 188 | main | 455 | module Examples
module WarningTextHelpers
def warning_text_normal
<<~WARNING_TEXT
= govuk_warning_text(text: "You can be fined up to £5,000 if you do not register.")
WARNING_TEXT
end
def warning_text_with_custom_icon_fallback_text
<<~WARNING_TEXT
= govuk_warning_text(ico... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/panel_helpers.rb | Ruby | mit | 188 | main | 437 | module Examples
module PanelHelpers
def panel_normal
<<~PANEL
= govuk_panel(title_text: "Application complete",
text: "You will soon receive an email confirmation.")
PANEL
end
def panel_with_block
<<~PANEL
= govuk_panel(title_text: "Application comp... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/cookie_banner_helpers.rb | Ruby | mit | 188 | main | 745 | module Examples
module CookieBannerHelpers
def cookie_banner_normal
<<~COOKIE_BANNER
= govuk_cookie_banner do |cb|
- cb.with_message(heading_text: "Cookies on this service") do |m|
- m.with_action { govuk_button_link_to("Accept additional cookies", "#") }
- m.with_a... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/title_with_error_prefix_helpers.rb | Ruby | mit | 188 | main | 646 | require 'ostruct'
module Examples
module TitleWithErrorPrefixHelpers
def title_containing_error
<<~TITLE_WITH_ERROR_PREFIX
= title_with_error_prefix("Personal details", error: true)
TITLE_WITH_ERROR_PREFIX
end
def title_not_containing_error
<<~TITLE_WITH_ERROR_PREFIX
= ... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/inset_text_helpers.rb | Ruby | mit | 188 | main | 411 | module Examples
module InsetTextHelpers
def inset_text_normal
<<~INSET_TEXT
= govuk_inset_text(text: "One line of inset text")
INSET_TEXT
end
def inset_text_block
<<~INSET_TEXT
= govuk_inset_text do
p
| Multiple lines of inset text
ul
... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/link_helpers.rb | Ruby | mit | 188 | main | 2,535 | module Examples
module LinkHelpers
def govuk_link_to_normal
%(= govuk_link_to 'A regular hyperlink', '#')
end
def govuk_link_to_new_tab
<<~NEW_TAB
p.govuk-body
= govuk_link_to('A link with the default new tab text',
'#',
new_tab: true)
p.govu... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/notification_banner_helpers.rb | Ruby | mit | 188 | main | 1,436 | module Examples
module NotificationBannerHelpers
def notification_banner_normal
<<~NOTIFICATION_BANNER
= govuk_notification_banner(title_text: "Important", text: "You have 7 days left to send your application.")
NOTIFICATION_BANNER
end
def notification_banner_block
<<~NOTIFICATI... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/footer_helpers.rb | Ruby | mit | 188 | main | 3,971 | module Examples
module FooterHelpers
def footer_normal
<<~FOOTER
= govuk_footer
FOOTER
end
def footer_with_meta_items
<<~FOOTER
= govuk_footer(meta_items_title: "Helpful links", meta_items: meta_items)
FOOTER
end
def footer_meta_items
<<~FOOTER_META_... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/task_list_helpers.rb | Ruby | mit | 188 | main | 4,078 | module Examples
module TaskListHelpers
def default_task_list
<<~SNIPPET
h2.govuk-heading-m About you
= govuk_task_list(id_prefix: "about-you") do |task_list|
- task_list.with_item(title: "Personal details", href: '#', status: "Completed")
- task_list.with_item(title: "Con... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/tag_helpers.rb | Ruby | mit | 188 | main | 344 | module Examples
module TagHelpers
def tag_normal
<<~TAG
= govuk_tag(text: "Completed")
TAG
end
def tag_colours
<<~TAG
- %w(Grey Green Teal Blue Light-blue Red Purple Magenta Orange Yellow).each do |colour|
= govuk_tag(text: colour, colour: colour.downcase)
... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/table_helpers.rb | Ruby | mit | 188 | main | 8,246 | module Examples
module TableHelpers
def table_normal
<<~TABLE
= govuk_table do |table|
- table.with_caption(size: 'm', text: 'List of Pokémon')
- table.with_head do |head|
- head.with_row do |row|
- row.with_cell(text: 'Name')
- row.with_c... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/back_link_helpers.rb | Ruby | mit | 188 | main | 444 | module Examples
module BackLinkHelpers
def back_link_normal
<<~BACK_LINK_NORMAL
= govuk_back_link(href: "/")
BACK_LINK_NORMAL
end
def back_link_custom
<<~BACK_LINK_NORMAL
= govuk_back_link(href: "/", text: "Return")
BACK_LINK_NORMAL
end
def back_link_inver... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/section_break_helpers.rb | Ruby | mit | 188 | main | 322 | module Examples
module SectionBreakHelpers
def section_break_visible
<<~SECTION_BREAK
= govuk_section_break(visible: true)
SECTION_BREAK
end
def section_break_visible_xl
<<~SECTION_BREAK
= govuk_section_break(visible:true, size: "xl")
SECTION_BREAK
end
end
en... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/details_helpers.rb | Ruby | mit | 188 | main | 989 | module Examples
module DetailsHelpers
def details_normal
<<~DETAILS
= govuk_details(summary_text: summary_text, text: text)
DETAILS
end
def details_normal_arguments
<<~DETAILS_DATA
{
summary_text: "Help with nationality",
text: "We need to know your n... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/skip_link_helpers.rb | Ruby | mit | 188 | main | 551 | module Examples
module SkipLinkHelpers
def skip_link_normal
<<~SKIP_LINK
#{skip_link_instructions}
= govuk_skip_link
SKIP_LINK
end
def skip_link_with_custom_href_and_text
<<~SKIP_LINK
#{skip_link_instructions}
= govuk_skip_link(href: "#some-other-id", t... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/pagination_helpers.rb | Ruby | mit | 188 | main | 2,118 | require 'pagy'
# We need this here because the pagy helpers we're using to build
# links expect a Rack request.
module Pagy::UrlHelpers
def request
OpenStruct.new(GET: {}, session: nil, host: "https://somesite/", format: OpenStruct.new(html?: true))
end
end
module Examples
module PaginationHelpers
def p... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/summary_list_helpers.rb | Ruby | mit | 188 | main | 5,860 | module Examples
module SummaryListHelpers
def summary_list_normal
<<~SUMMARY_LIST
= govuk_summary_list do |summary_list|
- summary_list.with_row do |row|
- row.with_key { 'Aardvark' }
- row.with_value { 'The aardvark is vaguely pig-like in appearance' }
... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/phase_banner_helpers.rb | Ruby | mit | 188 | main | 753 | module Examples
module PhaseBannerHelpers
def phase_banner_normal
<<~PHASE_BANNER
= govuk_phase_banner(tag: { text: "Alpha" }, text: "This is a new service – your feedback will help us to improve it. ")
PHASE_BANNER
end
def phase_banner_with_block
<<~PHASE_BANNER
= govuk... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | guide/lib/examples/list_helpers.rb | Ruby | mit | 188 | main | 1,051 | module Examples
module ListHelpers
def govuk_list_plain
<<~EXAMPLE
= govuk_list [govuk_link_to("News", "#"), govuk_link_to("Publications", "#")]
EXAMPLE
end
def govuk_list_bullet
<<~EXAMPLE
= govuk_list ["apples", "oranges", "pears"], type: :bullet
EXAMPLE
end
... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/spec_helper.rb | Ruby | mit | 188 | main | 3,392 | require 'pry'
require 'pry-byebug'
require 'view_component/test_helpers'
require 'simplecov'
require 'action_controller'
require 'action_controller/test_case'
require File.expand_path("dummy/config/environment", __dir__)
if ENV.fetch('SIMPLECOV') { '1' } == '1'
SimpleCov.add_filter('spec/dummy')
SimpleCov.start
e... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/helpers/govuk_components_helper_spec.rb | Ruby | mit | 188 | main | 4,833 | require 'spec_helper'
class HelperComponentMapping
attr_reader :helper_method, :klass, :args, :kwargs, :css_matcher, :block
def initialize(helper_method:, klass:, args:, kwargs:, css_matcher:, block: nil)
@helper_method = helper_method
@klass = klass
@args = args
@kwargs = ... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/helpers/govuk_list_helper_spec.rb | Ruby | mit | 188 | main | 3,326 | require 'spec_helper'
RSpec.describe "govuk_list", type: 'helper' do
include ActionView::Context
include ActionView::Helpers
context "when given an array" do
context "with no type specified" do
subject { govuk_list(%w[apples pears]) }
it "generates an unordered list with no bullets" do
... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/helpers/govuk_rails_compatible_link_helper_spec.rb | Ruby | mit | 188 | main | 13,265 | require 'spec_helper'
RSpec.describe(GovukRailsCompatibleLinkHelper, type: 'helper') do
include ActionView::Helpers::UrlHelper
include ActionView::Context
include GovukRailsCompatibleLinkHelper
let(:text) { 'Menu' }
let(:url) { '/stuff/menu/' }
let(:args) { [text, url] }
let(:kwargs) { {} }
describe ... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/helpers/govuk_skip_link_helper_spec.rb | Ruby | mit | 188 | main | 2,613 | require 'spec_helper'
RSpec.describe(GovukSkipLinkHelper, type: 'helper') do
include ActionView::Context
include ActionView::Helpers::UrlHelper
let(:custom_link_text) { 'Get straight to the important stuff' }
let(:custom_href) { '#skip-link-target' }
let(:default_href) { '#main-content' }
let(:default_li... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/helpers/govuk_exit_this_page_link_helper_spec.rb | Ruby | mit | 188 | main | 1,270 | require 'spec_helper'
RSpec.describe(GovukExitThisPageLinkHelper, type: 'helper') do
include ActionView::Helpers::UrlHelper
let(:kwargs) { {} }
subject { govuk_exit_this_page_link(**kwargs) }
specify "renders an 'Exit this page' link to BBC Weather" do
expect(subject).to have_tag("a", text: "Exit this pa... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/helpers/govuk_back_to_top_link_helper_spec.rb | Ruby | mit | 188 | main | 764 | require 'spec_helper'
RSpec.describe(GovukBackToTopLinkHelper, type: 'helper') do
include ActionView::Helpers::UrlHelper
include ActionView::Context
describe '#govuk_back_to_top_link' do
subject { govuk_back_to_top_link }
let(:expected_classes) { %w(govuk-link govuk-link--no-visited-state) }
it "re... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/helpers/govuk_visually_hidden_helper_spec.rb | Ruby | mit | 188 | main | 1,191 | require 'spec_helper'
RSpec.describe(GovukVisuallyHiddenHelper, type: 'helper') do
include ActionView::Context
include ActionView::Helpers::UrlHelper
describe '#govuk_visually_hidden' do
context 'when text is blank' do
subject { govuk_visually_hidden("") }
it { is_expected.to be_nil }
end
... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/helpers/govuk_link_helper_spec.rb | Ruby | mit | 188 | main | 26,636 | require 'spec_helper'
INVALID_BUTTON_COMBINATIONS = [
{ warning: true, inverse: true },
{ warning: true, secondary: true },
{ secondary: true, inverse: true },
{ secondary: true, inverse: true, warning: true },
].freeze
INVALID_LINK_COMBINATIONS = [
{ text_colour: true, inverse: true },
{ muted: true, inv... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/helpers/title_with_error_prefix_helper_spec.rb | Ruby | mit | 188 | main | 1,151 | require 'spec_helper'
RSpec.describe(TitleWithErrorPrefixHelper, type: 'helper') do
describe '#title_with_error_prefix' do
context 'when there is an error' do
subject { title_with_error_prefix('What is their name?', error: true) }
it 'should include the Error: prefix' do
expect(subject).to e... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/table_component_spec.rb | Ruby | mit | 188 | main | 24,106 | require 'spec_helper'
RSpec.describe(GovukComponent::TableComponent, type: :component) do
let(:id) { 'important-table' }
let(:component_css_class) { 'govuk-table' }
let(:caption_text) { "What a nice table" }
let(:kwargs) { { id: } }
subject! do
render_inline(GovukComponent::TableComponent.new(**kwargs)... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/section_break_component_spec.rb | Ruby | mit | 188 | main | 2,153 | require "spec_helper"
RSpec.describe GovukComponent::SectionBreakComponent, type: :component do
let(:component_css_class) { "govuk-section-break" }
let(:kwargs) { {} }
it_behaves_like "a component that accepts custom classes"
it_behaves_like "a component that accepts custom HTML attributes"
it_behaves_like ... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/service_navigation_component_spec.rb | Ruby | mit | 188 | main | 15,367 | require 'spec_helper'
RSpec.describe(GovukComponent::ServiceNavigationComponent, type: :component) do
let(:component_css_class) { 'govuk-service-navigation' }
let(:service_name) { nil }
let(:service_url) { nil }
let(:navigation_items) { [] }
let(:current_path) { nil }
let(:navigation_id) { nil }
let(:in... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/breadcrumbs_component_spec.rb | Ruby | mit | 188 | main | 3,556 | require 'spec_helper'
RSpec.describe(GovukComponent::BreadcrumbsComponent, type: :component) do
let(:breadcrumbs) do
{
"Home" => "/level-one",
"Products" => "/level-two",
"Lighting" => "/level-three",
"Anglepoise Desk Lamp" => nil
}
end
let... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/task_list_component_spec.rb | Ruby | mit | 188 | main | 14,413 | require 'spec_helper'
RSpec.describe(GovukComponent::TaskListComponent, type: :component) do
let(:component_css_class) { 'govuk-task-list' }
let(:id_prefix) { nil }
let(:kwargs) { { id_prefix: }.compact }
let(:list_item_one_kwargs) { { title: "One", status: "in progress" } }
let(:list_item_two_kwargs) { { ti... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/pagination_component_spec.rb | Ruby | mit | 188 | main | 16,696 | require 'spec_helper'
RSpec.describe(GovukComponent::PaginationComponent, type: :component) do
let(:count) { 30 }
let(:limit) { 5 }
let(:size) { [1, 2, 2, 1] }
let(:defaults) { { count:, limit:, size: } }
let(:current_page) { 2 }
let(:pagy) { Pagy.new(page: current_page, **defaults) }
let(:component_css_... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/accordion_component_spec.rb | Ruby | mit | 188 | main | 8,598 | require 'spec_helper'
RSpec.describe(GovukComponent::AccordionComponent, type: :component) do
let(:id) { 'fancy-accordion' }
let(:component_css_class) { 'govuk-accordion' }
let(:sections) do
{
'section 1' => 'first section content',
'section 2' => 'second section content',
'section 3' => '... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/tab_component_spec.rb | Ruby | mit | 188 | main | 5,234 | require 'spec_helper'
RSpec.describe(GovukComponent::TabComponent, type: :component) do
let(:title) { 'My favourite tabs' }
let(:label) { 'A tab' }
let(:component_css_class) { 'govuk-tabs' }
let(:tabs) do
{
'tab 1' => 'first tab content',
'tab 2' => 'second tab content',
'tab 3' => 'thir... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/header_component_spec.rb | Ruby | mit | 188 | main | 6,671 | require 'spec_helper'
RSpec.describe(GovukComponent::HeaderComponent, type: :component) do
let(:component_css_class) { 'govuk-header' }
let(:product_name) { 'Order an amazing ID' }
let(:logotype) { 'OMG.UK' }
let(:homepage_url) { 'https://omg.uk/bbq' }
let(:all_kwargs) do
{ homepage_url:, }
end
let(... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/details_component_spec.rb | Ruby | mit | 188 | main | 3,211 | require 'spec_helper'
RSpec.describe(GovukComponent::DetailsComponent, type: :component) do
let(:component_css_class) { 'govuk-details' }
let(:summary_text) { 'The new Ribwich' }
let(:text) { 'Now without lettuce' }
let(:kwargs) { { summary_text:, text: } }
it_behaves_like 'a component that accepts custom c... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/cookie_banner_component_spec.rb | Ruby | mit | 188 | main | 6,130 | require "spec_helper"
RSpec.describe(GovukComponent::CookieBannerComponent, type: :component) do
let(:component_css_class) { 'govuk-cookie-banner' }
let(:kwargs) { {} }
subject! do
render_inline(described_class.new(**kwargs))
end
specify "renders a cookie banner div with the default attributes" do
... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/panel_component_spec.rb | Ruby | mit | 188 | main | 3,917 | require 'spec_helper'
RSpec.describe(GovukComponent::PanelComponent, type: :component) do
let(:component_css_class) { 'govuk-panel' }
let(:title_text) { 'Springfield' }
let(:text) { 'A noble spirit embiggens the smallest man' }
let(:kwargs) { { title_text:, text: } }
it_behaves_like 'a component that accep... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/inset_text_component_spec.rb | Ruby | mit | 188 | main | 1,587 | require 'spec_helper'
RSpec.describe(GovukComponent::InsetTextComponent, type: :component) do
let(:component_css_class) { 'govuk-inset-text' }
let(:text) { 'Bake him away, toys.' }
let(:kwargs) { { text: } }
it_behaves_like 'a component that accepts custom classes'
it_behaves_like 'a component that accepts... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/footer_component_spec.rb | Ruby | mit | 188 | main | 12,715 | require 'spec_helper'
RSpec.describe(GovukComponent::FooterComponent, type: :component) do
let(:component_css_class) { "govuk-footer" }
let(:custom_content) { "The quick brown fox" }
let(:heading_text) { "Some title" }
let(:kwargs) { {} }
let(:meta_items_title) { 'Useful things' }
let(:meta_licence) { 'MIT... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/summary_list_card_component_spec.rb | Ruby | mit | 188 | main | 4,066 | require 'spec_helper'
RSpec.describe(GovukComponent::SummaryListComponent::CardComponent, type: :component) do
let(:component_css_class) { 'govuk-summary-list' }
let(:rows) do
[
# row 1
{
key: {
text: "Name",
classes: "row-1-custom-key-class",
html_attributes: ... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/notification_banner_component_spec.rb | Ruby | mit | 188 | main | 10,187 | require 'spec_helper'
RSpec.describe(GovukComponent::NotificationBannerComponent, type: :component) do
let(:component_css_class) { 'govuk-notification-banner' }
let(:title) { 'A notification banner' }
let(:kwargs) { { title_text: title, text: "something" } }
describe 'slot arguments' do
let(:slot) { :hea... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/start_button_component_spec.rb | Ruby | mit | 188 | main | 2,534 | require 'spec_helper'
RSpec.describe(GovukComponent::StartButtonComponent, type: :component) do
let(:component_css_class) { 'govuk-button--start' }
let(:text) { 'Department for Education' }
let(:href) { 'https://www.gov.uk/government/organisations/department-for-education' }
let(:as_button) { false }
let(:kw... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/tag_component_spec.rb | Ruby | mit | 188 | main | 2,708 | require 'spec_helper'
RSpec.describe(GovukComponent::TagComponent, type: :component) do
let(:text) { 'Alert' }
let(:kwargs) { { text: } }
let(:component_css_class) { 'govuk-tag' }
describe 'content' do
subject! { render_inline(GovukComponent::TagComponent.new(**kwargs)) }
specify 'renders strong elem... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/warning_text_component_spec.rb | Ruby | mit | 188 | main | 3,007 | require 'spec_helper'
RSpec.describe(GovukComponent::WarningTextComponent, type: :component) do
let(:component_css_class) { 'govuk-warning-text' }
let(:custom_icon_fallback_text) { 'Informative text goes here' }
let(:kwargs) { { text: } }
let(:text) { 'Some fancy warning' }
subject! { render_inline(GovukCom... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/summary_list_component_spec.rb | Ruby | mit | 188 | main | 23,102 | require 'spec_helper'
RSpec.describe(GovukComponent::SummaryListComponent, type: :component) do
let(:component_css_class) { 'govuk-summary-list' }
let(:action_link_text) { 'Something' }
let(:action_link_href) { '#anchor' }
let(:kwargs) { {} }
it_behaves_like 'a component that accepts custom classes'
it_... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/exit_this_page_component_spec.rb | Ruby | mit | 188 | main | 4,452 | require 'spec_helper'
RSpec.describe(GovukComponent::ExitThisPageComponent, type: :component) do
let(:component_css_class) { "govuk-exit-this-page" }
let(:kwargs) { {} }
subject! { render_inline(GovukComponent::ExitThisPageComponent.new(**kwargs)) }
specify "renders a div containing an 'Exit this page' link ... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/back_link_component_spec.rb | Ruby | mit | 188 | main | 2,053 | require 'spec_helper'
RSpec.describe(GovukComponent::BackLinkComponent, type: :component) do
let(:default_text) { 'Back' }
let(:href) { 'https://www.gov.uk/government/organisations/department-for-education' }
let(:kwargs) { { href: } }
let(:component_css_class) { 'govuk-back-link' }
subject! { render_inline... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/phase_banner_component_spec.rb | Ruby | mit | 188 | main | 2,122 | require 'spec_helper'
RSpec.describe(GovukComponent::PhaseBannerComponent, type: :component) do
let(:component_css_class) { "govuk-phase-banner" }
let(:phase) { 'Gamma' }
let(:text) { 'This is an experimental service – be cautious' }
let(:kwargs) { { tag: { text: phase }, text: } }
subject! { render_inline... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/exit_this_page_configuration_spec.rb | Ruby | mit | 188 | main | 4,346 | require 'spec_helper'
RSpec.describe(GovukComponent::ExitThisPageComponent, type: :component) do
describe 'configuration' do
after { Govuk::Components.reset! }
describe 'default_exit_this_page_text' do
let(:overridden_text) { 'Leave now' }
before do
Govuk::Components.configure do |confi... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/section_break_component_configuration_spec.rb | Ruby | mit | 188 | main | 1,200 | require 'spec_helper'
RSpec.describe(GovukComponent::SectionBreakComponent, type: :component) do
describe 'configuration' do
after { Govuk::Components.reset! }
describe 'default_section_break_visible' do
let(:overridden_visibility) { true }
before do
Govuk::Components.configure do |conf... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/back_link_component_configuration_spec.rb | Ruby | mit | 188 | main | 920 | require 'spec_helper'
RSpec.describe(GovukComponent::BackLinkComponent, type: :component) do
let(:href) { 'https://www.gov.uk/government/organisations/department-for-education' }
let(:kwargs) { { href: } }
let(:component_css_class) { 'govuk-back-link' }
describe 'configuration' do
after { Govuk::Component... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/summary_list_configuration_spec.rb | Ruby | mit | 188 | main | 2,815 | require 'spec_helper'
RSpec.describe(GovukComponent::SummaryListComponent, type: :component) do
describe 'configuration' do
after { Govuk::Components.reset! }
describe 'default_summary_list_borders' do
before do
Govuk::Components.configure do |config|
config.default_summary_list_bord... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/cookie_banner_component_configuration_spec.rb | Ruby | mit | 188 | main | 1,482 | require "spec_helper"
RSpec.describe(GovukComponent::CookieBannerComponent, type: :component) do
let(:component_css_class) { 'govuk-cookie-banner' }
describe "configuration" do
after { Govuk::Components.reset! }
describe "default_cookie_banner_aria_label" do
let(:overriden_aria_label) { "Biscuit fl... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/start_button_configuration_spec.rb | Ruby | mit | 188 | main | 943 | require 'spec_helper'
RSpec.describe(GovukComponent::StartButtonComponent, type: :component) do
describe 'configuration' do
before do
allow_any_instance_of(GovukComponent::StartButtonComponent)
.to(receive(:protect_against_forgery?).and_return(false))
end
after { Govuk::Components.reset! }... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/footer_component_configuration_spec.rb | Ruby | mit | 188 | main | 1,730 | require 'spec_helper'
RSpec.describe(GovukComponent::FooterComponent, type: :component) do
let(:selector) { "footer.govuk-footer .govuk-width-container .govuk-footer__meta" }
let(:kwargs) { {} }
describe 'configuration' do
after { Govuk::Components.reset! }
describe 'default footer component text and u... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/header_component_configuration_spec.rb | Ruby | mit | 188 | main | 748 | require 'spec_helper'
RSpec.describe(GovukComponent::HeaderComponent, type: :component) do
let(:kwargs) { {} }
describe 'configuration' do
after { Govuk::Components.reset! }
describe 'default_header_homepage_url' do
let(:overriddden_homepage_url) { "/some-page" }
before do
Govuk::Com... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/tag_component_configuration_spec.rb | Ruby | mit | 188 | main | 738 | require 'spec_helper'
RSpec.describe(GovukComponent::TagComponent, type: :component) do
let(:text) { 'Alert' }
let(:kwargs) { { text: } }
let(:component_css_class) { 'govuk-tag' }
let(:default_colour) { "green" }
describe 'configuration' do
after { Govuk::Components.reset! }
describe 'colours' do
... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/breadcrumbs_component_configuration_spec.rb | Ruby | mit | 188 | main | 1,957 | require 'spec_helper'
RSpec.describe(GovukComponent::BreadcrumbsComponent, type: :component) do
let(:href) { 'https://www.gov.uk/government/organisations/department-for-education' }
let(:link_text) { 'Organisations' }
let(:breadcrumbs) { { link_text => href } }
let(:kwargs) { { breadcrumbs: } }
let(:componen... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/pagination_component_configuration_spec.rb | Ruby | mit | 188 | main | 2,126 | require 'spec_helper'
RSpec.describe(GovukComponent::PaginationComponent, type: :component) do
let(:pagy) { Pagy.new(page: 2, count: 20, limit: 5, size: [1, 1, 1, 1]) }
let(:kwargs) { { pagy: } }
describe "configuration" do
after { Govuk::Components.reset! }
describe "default_pagination_landmark_label"... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/phase_banner_component_configuration_spec.rb | Ruby | mit | 188 | main | 1,153 | require 'spec_helper'
RSpec.describe(GovukComponent::PhaseBannerComponent, type: :component) do
describe "configuration" do
after { Govuk::Components.reset! }
describe 'default phase banner component tag and text' do
let(:overridden_default_tag) { 'Beta' }
let(:overridden_default_text) { 'Public... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/warning_text_component_configuration_spec.rb | Ruby | mit | 188 | main | 1,343 | require 'spec_helper'
RSpec.describe(GovukComponent::WarningTextComponent, type: :component) do
describe 'configuration' do
after { Govuk::Components.reset! }
let(:kwargs) { { text: "Something important" } }
describe 'default_warning_text_icon_fallback_text' do
let(:overridden_fallback_text) { "U... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/table_component_configuration_spec.rb | Ruby | mit | 188 | main | 1,286 | require 'spec_helper'
RSpec.describe(GovukComponent::TableComponent::CellComponent, type: :component) do
let(:text) { 'Content' }
let(:kwargs) { { text:, header: true, parent: 'tbody' } }
let(:component_css_class) { 'govuk-table__cell' }
describe 'configuration' do
describe 'disabling automatic scopes' do... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/govuk_component/configuration/notification_banner_component_configuration_spec.rb | Ruby | mit | 188 | main | 2,489 | require 'spec_helper'
RSpec.describe(GovukComponent::NotificationBannerComponent, type: :component) do
let(:kwargs) { { title_text: "Title text", text: "Test" } }
describe 'configuration' do
after { Govuk::Components.reset! }
describe 'default_notification_banner_title_id' do
let(:overridden_id) { ... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/shared/setup.rb | Ruby | mit | 188 | main | 218 | shared_context 'setup' do
let(:component_css_class_matcher) do
if component_css_class.blank?
nil
else
'.' + component_css_class
end
end
let(:html) { Nokogiri.parse(rendered_content) }
end |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/shared/a_component_with_a_slot_that_accepts_custom_html_attributes.rb | Ruby | mit | 188 | main | 671 | shared_examples 'a component with a slot that accepts custom html attributes' do
let(:custom_attributes) { { lang: "en-GB", style: "background-color: blue;" } }
subject! do
render_inline(described_class.send(:new, **kwargs)) do |component|
if content
component.send("with_#{slot}", html_attributes... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/shared/custom_matchers.rb | Ruby | mit | 188 | main | 500 | RSpec.configure do
RSpec::Matchers.define(:contain_svgs_with_viewBox_attributes) do
match do |element|
all_svgs = element.search("//xmlns:svg", "xmlns" => "http://www.w3.org/2000/svg")
svgs_with_viewbox = element.search("//xmlns:svg[@viewBox]", "xmlns" => "http://www.w3.org/2000/svg")
expect(al... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/shared/a_component_with_a_slot_that_accepts_custom_classes.rb | Ruby | mit | 188 | main | 574 | shared_examples 'a component with a slot that accepts custom classes' do
let(:custom_class) { 'purple-stripes' }
subject! do
render_inline(described_class.send(:new, **kwargs)) do |component|
if content
component.send("with_#{slot}", classes: custom_class, **slot_kwargs) { content.call }
el... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/shared/helpers.rb | Ruby | mit | 188 | main | 274 | shared_context 'helpers' do
let(:lookup_context) { ActionView::LookupContext.new(ActionController::Base.view_paths) }
let(:assigns) { {} }
let(:controller) { ActionController::Base.new }
let(:helper) { ActionView::Base.new(lookup_context, assigns, controller) }
end |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/shared/a_component_that_supports_custom_branding.rb | Ruby | mit | 188 | main | 1,524 | shared_examples 'a component that supports custom branding' do
let(:default_brand) { 'govuk' }
let(:custom_brand) { 'globex-corp' }
before do
Govuk::Components.configure do |conf|
conf.brand = custom_brand
end
end
after do
Govuk::Components.reset!
end
specify "should contain the custo... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/shared/a_component_that_accepts_custom_classes.rb | Ruby | mit | 188 | main | 1,215 | shared_examples 'a component that accepts custom classes' do
context 'when classes are supplied' do
before { render_inline(described_class.send(:new, **kwargs.merge(classes: custom_classes))) }
context 'as a string' do
let(:custom_classes) { 'yellow-spots black-text' }
specify 'the classes are p... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/components/shared/a_component_that_accepts_custom_html_attributes.rb | Ruby | mit | 188 | main | 864 | shared_examples 'a component that accepts custom HTML attributes' do
let(:custom_attributes) { { lang: "en-GB", style: "background-color: blue" } }
let(:updated_kwargs) { kwargs.deep_merge({ html_attributes: { lang: "en-GB", style: "background-color: blue" } }) }
subject! { render_inline(described_class.send(:ne... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/dummy/config/application.rb | Ruby | mit | 188 | main | 876 | require_relative 'boot'
require "rails"
require "action_controller/railtie"
require "action_view/railtie"
require "sprockets/railtie"
Bundler.require(*Rails.groups)
require "govuk/components"
module Sprockets
module Rails
def self.deprecator
@deprecator ||= ActiveSupport::Deprecation.new("4.0", "Sprocket... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/dummy/config/environments/development.rb | Ruby | mit | 188 | main | 2,416 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/dummy/config/environments/test.rb | Ruby | mit | 188 | main | 1,906 | # The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do
# Settings... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/dummy/config/environments/production.rb | Ruby | mit | 188 | main | 5,215 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web serve... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/dummy/db/schema.rb | Ruby | mit | 188 | main | 750 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
#... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | spec/dummy/lib/tasks/generate_examples.rake | Ruby | mit | 188 | main | 919 | desc "generate a static example useage page, suitable for publishing on githubpages"
task generate_examples_page: :environment do
STYLES_PATH = '/html/head/link'.freeze
JS_PATH = '/html/head/script'.freeze
html = DemosController.render :show
css = Rails.application.assets.find_asset('application.css').to_s
j... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | lib/govuk/components.rb | Ruby | mit | 188 | main | 205 | require "rails/engine"
require "view_component"
require "govuk/components/helpers/css_utilities"
require "govuk/components/engine"
require "html_attributes_utils"
require "pagy"
require "pagy/extras/size" |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | lib/govuk/components/engine.rb | Ruby | mit | 188 | main | 9,561 | require "rails/engine"
require "active_support/ordered_options"
module Govuk
module Components
class << self
class_attribute :config,
instance_predicate: false,
default: ActiveSupport::OrderedOptions.new
def inherited(klass) # :nodoc:
klass.config ... |
github | x-govuk/govuk-components | https://github.com/x-govuk/govuk-components | lib/govuk/components/helpers/css_utilities.rb | Ruby | mit | 188 | main | 801 | module Govuk
module Components
module Helpers
module CssUtilities
def combine_classes(default_classes, custom_classes)
converted_custom_classes = case custom_classes
when Array
custom_classes
... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | Gemfile | Ruby | mit | 188 | master | 1,527 | # frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Declare your gem"s dependencies in form_core.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :developm... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | Rakefile | Ruby | mit | 188 | master | 708 | # frozen_string_literal: true
begin
require "bundler/setup"
rescue LoadError
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
end
require "rdoc/task"
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = "rdoc"
rdoc.title = "FormCore"
rdoc.options << "--line-numbers"
rdoc.rdoc_fi... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | form_core.gemspec | Ruby | mit | 188 | master | 875 | # frozen_string_literal: true
$LOAD_PATH.push File.expand_path("lib", __dir__)
# Maintain your gem's version:
require "form_core/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "form_core"
s.version = FormCore::VERSION
s.authors = ["jasl"]
s.em... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | db/migrate/20170430190404_create_forms.rb | Ruby | mit | 188 | master | 209 | # frozen_string_literal: true
class CreateForms < ActiveRecord::Migration[5.1]
def change
create_table :forms do |t|
t.string :type, null: false, index: true
t.timestamps
end
end
end |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | db/migrate/20170430191336_create_fields.rb | Ruby | mit | 188 | master | 381 | # frozen_string_literal: true
class CreateFields < ActiveRecord::Migration[5.1]
def change
create_table :fields do |t|
t.string :name, null: false
t.integer :accessibility, null: false
t.text :validations
t.text :options
t.string :type, null: false, index: true
t.references :f... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | app/models/form_core/form.rb | Ruby | mit | 188 | master | 209 | # frozen_string_literal: true
module FormCore
class Form < ApplicationRecord
include FormCore::Concerns::Models::Form
self.table_name = "forms"
has_many :fields, dependent: :destroy
end
end |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | app/models/form_core/field.rb | Ruby | mit | 188 | master | 204 | # frozen_string_literal: true
module FormCore
class Field < ApplicationRecord
include FormCore::Concerns::Models::Field
self.table_name = "fields"
belongs_to :form, touch: true
end
end |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | lib/form_core.rb | Ruby | mit | 188 | master | 1,152 | # frozen_string_literal: true
require "form_core/engine"
require "form_core/errors"
require "form_core/coder"
require "form_core/coders/hash_coder"
require "form_core/coders/yaml_coder"
require "form_core/virtual_model"
require "form_core/concerns/models/form"
require "form_core/concerns/models/field"
module FormCo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.