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 | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/components/step_by_step_nav_spec.rb | Ruby | mit | 89 | main | 12,529 | require "rails_helper"
describe "step nav", type: :view do
def component_name
"step_by_step_nav"
end
def stepnav
[
{
title: "Step 1",
optional: true,
contents: [
{
type: "paragraph",
text: "Step 1 paragraph",
},
{
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/components/image_card_spec.rb | Ruby | mit | 89 | main | 7,372 | require "rails_helper"
describe "ImageCard", type: :view do
def component_name
"image_card"
end
it "renders nothing when no link is provided" do
assert_empty render_component({})
end
it "shows an image" do
render_component(href: "#", image_src: "/moo.jpg", image_alt: "some meaningful alt text")... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/components/single_page_notification_button_spec.rb | Ruby | mit | 89 | main | 5,940 | require "rails_helper"
describe "Single page notification button", type: :view do
def component_name
"single_page_notification_button"
end
it "does not render without a base path" do
assert_empty render_component({})
end
it "renders with the correct markup if base path is present" do
render_com... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/components/button_spec.rb | Ruby | mit | 89 | main | 9,269 | require "rails_helper"
describe "Button", type: :view do
def component_name
"button"
end
it "no error if no parameters passed in" do
render_component({})
assert_select ".govuk-button"
end
it "renders the correct defaults" do
render_component(text: "Submit")
assert_select ".govuk-button[... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/components/layout_super_navigation_header_spec.rb | Ruby | mit | 89 | main | 5,573 | require "rails_helper"
describe "Super navigation header", type: :view do
def component_name
"layout_super_navigation_header"
end
it "renders the super navigation header" do
render_component({})
assert_select ".gem-c-layout-super-navigation-header", count: 1
end
it "has a nav element that is l... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/components/global_banner_spec.rb | Ruby | mit | 89 | main | 1,575 | require "rails_helper"
describe "Global banner", type: :view do
def component_name
"global_banner"
end
it "renders nothing without any options" do
assert_empty render_component({})
end
it "renders with minimum required options" do
render_component(title: "Look here you", banner_version: 1)
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/components/figure_spec.rb | Ruby | mit | 89 | main | 2,191 | require "rails_helper"
describe "Figure", type: :view do
def component_name
"figure"
end
it "fails to render a figure when no data is given" do
render_component({})
assert_select "figure", false, "Should not have drawn figure with no data passed through"
end
it "fails to render the component wh... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/components/panel_spec.rb | Ruby | mit | 89 | main | 1,385 | require "rails_helper"
describe "Panel", type: :view do
def component_name
"panel"
end
it "fails to render when no data is given" do
assert_raises do
render_component({})
end
end
it "renders a panel component with title and body" do
render_component(
title: "Application complete... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/components/organisation_logo_spec.rb | Ruby | mit | 89 | main | 4,280 | require "rails_helper"
describe "Organisation logo", type: :view do
def component_name
"organisation_logo"
end
it "error if no parameters passed in" do
assert_raises do
render_component({})
end
end
it "shows an organisation name" do
render_component(organisation: { name: "Organisation... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/components/glance_metric_spec.rb | Ruby | mit | 89 | main | 1,660 | require "rails_helper"
describe "Glance Metric", type: :view do
def component_name
"glance_metric"
end
let(:data) do
{
name: "Unique pageviews",
figure: "167",
measurement_explicit_label: "Million",
measurement_display_label: "m",
context: "This is in your top 10 items",
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/components/contextual_breadcrumbs_spec.rb | Ruby | mit | 89 | main | 9,677 | require "rails_helper"
describe "ContextualBreadcrumbs", type: :view do
def component_name
"contextual_breadcrumbs"
end
def example_document_for(schema_name, example_name)
GovukSchemas::Example.find(schema_name, example_name:)
end
def remove_mainstream_browse(content_item)
content_item["links"]... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/components/layout_footer_spec.rb | Ruby | mit | 89 | main | 13,632 | require "rails_helper"
describe "Layout footer", type: :view do
def component_name
"layout_footer"
end
it "renders the footer" do
render_component({})
assert_select ".govuk-footer"
end
it "renders the footer with meta links" do
render_component(
meta: {
items: [
{
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/support/components_helper.rb | Ruby | mit | 89 | main | 417 | module Helpers
module Components
def component_name
raise NotImplementedError, "Override this method in your test class"
end
def render_component(locals, &block)
if block_given?
render("govuk_publishing_components/components/#{component_name}", locals, &block)
else
rende... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/visual_regression_tests/all_components_spec.rb | Ruby | mit | 89 | main | 1,266 | require "rails_helper"
require "percy/capybara"
require "uri"
# rubocop:disable RSpec/NoExpectationExample
describe "visual regression test runner Percy", :visual_regression do
it "takes a screenshot of each component" do
# Freeze time for consistency
travel_to Time.zone.local(2020, 12, 1, 6, 0, 0)
skip... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/features/manifest_spec.rb | Ruby | mit | 89 | main | 365 | require "rails_helper"
describe "with `dartsass-rails`" do
it "includes `govuk_publishing_components_manifest.js`" do
expect(Rails.application.config.assets.precompile).to include("govuk_publishing_components_manifest.js")
expect(Rails.application.config.assets.precompile).not_to include("govuk_publishing_co... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/features/tabs_spec.rb | Ruby | mit | 89 | main | 869 | require "rails_helper"
describe "Tabs component", :capybara, :js do
scenario "Tabs load" do
given_i_visit_a_page_with_the_tabs_component
then_the_tabs_load
only_the_first_tab_is_selected
when_i_click_the_second_tab
then_only_the_second_tab_is_selected
end
def given_i_visit_a_page_with_the_ta... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/features/accordion_spec.rb | Ruby | mit | 89 | main | 2,088 | require "rails_helper"
describe "Accordion", :capybara, :js do
scenario "There is a page with the accordion rendered" do
given_i_visit_a_page_with_the_accordion_component
then_the_accordion_loads
when_i_click_the_first_accordion_section
then_the_accordion_opens
when_i_click_the_first_accordion_se... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/features/contextual_navigation_spec.rb | Ruby | mit | 89 | main | 17,677 | require "rails_helper"
describe "Contextual navigation", :capybara do
scenario "There's a step by step list" do
given_theres_a_page_with_a_step_by_step
and_i_visit_that_page
then_i_see_the_step_by_step
and_the_step_by_step_header
end
scenario "There's more than one step by step" do
given_the... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/features/step_nav_helper_spec.rb | Ruby | mit | 89 | main | 7,792 | require "rails_helper"
describe "Specimen usage of step by step navigation helpers", :capybara do
include GdsApi::TestHelpers::ContentStore
context "with no related step by step navigation journeys" do
before do
content_store_has_random_item(base_path: "/step-nav/vomit-comet", schema: "transaction", par... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/dummy/config/routes.rb | Ruby | mit | 89 | main | 1,139 | Rails.application.routes.draw do
if Rails.env.production?
constraints(host: "govuk-publishing-components.herokuapp.com") do
match "/(*path)" => redirect { |params, _req|
"https://components.publishing.service.gov.uk/#{params[:path]}"
},
via: ... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/dummy/config/application.rb | Ruby | mit | 89 | main | 1,670 | require_relative "boot"
require "action_controller/railtie"
require "action_view/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
require "terser"
require "dartsass-rails"
# In a heroku environment we don't have chrome and chromedriver available
# so loading these gems fails.
unless ENV["HEROKU"]
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/dummy/config/environments/production.rb | Ruby | mit | 89 | main | 3,472 | 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 | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/dummy/config/environments/test.rb | Ruby | mit | 89 | main | 1,780 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# 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 suit... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/dummy/config/environments/development.rb | Ruby | mit | 89 | main | 1,944 | 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 | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/dummy/config/initializers/dartsass.rb | Ruby | mit | 89 | main | 385 | APP_STYLESHEETS = {
"application.scss" => "application.css",
}.freeze
all_stylesheets = APP_STYLESHEETS.merge(GovukPublishingComponents::Config.component_guide_stylesheet)
Rails.application.config.dartsass.builds = all_stylesheets
Rails.application.config.dartsass.build_options << " --quiet-deps"
Rails.application.... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/dummy/app/lib/services.rb | Ruby | mit | 89 | main | 204 | require "gds_api/content_store"
module Services
def self.content_store
@content_store ||= GdsApi::ContentStore.new(
Plek.new.find("content-store"),
disable_cache: true,
)
end
end |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/dummy/app/controllers/welcome_controller.rb | Ruby | mit | 89 | main | 1,433 | class WelcomeController < ApplicationController
def contextual_navigation
@urls = {
"HMRC org page (no navigation)" => "/government/organisations/hm-revenue-customs",
"Mainstream browse page with related links" => "/complain-independent-case-examiner",
"Vehicles you can drive (with step by step)... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/dummy/lib/test_file_3.rb | Ruby | mit | 89 | main | 320 | # this is a test file used to check component auditing functionality
# shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
# button = GovukPublishingComponents::Presenters::ButtonHelper.new(local_assigns)
# brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand) |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components_spec.rb | Ruby | mit | 89 | main | 782 | require "spec_helper"
describe GovukPublishingComponents do
describe ".render" do
it "can render a component" do
rendered = described_class.render(
"govuk_publishing_components/components/button",
)
expect(rendered).to match(/<button/)
end
it "can pass the component options" d... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/locales_validation_spec.rb | Ruby | mit | 89 | main | 353 | ENV["RAILS_TRANSLATION_MANAGER_LOAD_ALL_PLURAL_RULES"] ||= "true"
require "rails_helper"
require "rails_translation_manager"
RSpec.describe "locales files" do
it "meets all locale validation requirements" do
checker = RailsTranslationManager::LocaleChecker.new("config/locales/*.yml")
expect(checker.validate... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/config_spec.rb | Ruby | mit | 89 | main | 717 | require "spec_helper"
describe GovukPublishingComponents::Config do
describe "#configure" do
it "configures the application" do
GovukPublishingComponents.configure do |config|
config.component_guide_title = "My component guide"
config.application_stylesheet = "custom_stylesheet"
con... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_organisations_spec.rb | Ruby | mit | 89 | main | 934 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::ContentBreadcrumbsBasedOnOrganisations do
subject(:content_breadcrumbs_based_on_organisations) { described_class.new(content_item) }
let(:content_item) { GovukSchemas::Example.find("corporate_information_page", example_name: "best-practic... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/content_item_spec.rb | Ruby | mit | 89 | main | 5,488 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::ContentItem do
describe "#parent_taxons" do
context "with a content item with taxons links" do
context "with a parent taxon with phase set to 'live'" do
let(:taxon) do
{
"content_id" => "cccc-dddd",
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/attachment_helper_spec.rb | Ruby | mit | 89 | main | 7,923 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::AttachmentHelper do
it "supports a hash with string keys" do
attachment = described_class.new("title" => "test", "url" => "test")
expect(attachment.title).to eq("test")
end
describe "#title" do
it "returns the title" do
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/intervention_helper_spec.rb | Ruby | mit | 89 | main | 3,814 | RSpec.describe GovukPublishingComponents::Presenters::InterventionHelper do
describe "Intervention helper" do
describe ".dismiss_link" do
it "returns the default dismiss query string" do
intervention_helper = described_class.new({})
default_dismiss_link = intervention_helper.dismiss_link
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/step_by_step_nav_helper_spec.rb | Ruby | mit | 89 | main | 5,721 | require "spec_helper"
require "action_view"
RSpec.describe GovukPublishingComponents::Presenters::StepByStepNavHelper do
include ActionView::Helpers::SanitizeHelper
describe "Step by step navigation helper" do
step_helper = described_class.new
it "generates step nav ids correctly" do
id = step_help... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons_spec.rb | Ruby | mit | 89 | main | 5,972 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::ContentBreadcrumbsBasedOnTaxons do
describe "Taxon breadcrumbs" do
it "can handle any valid content item" do
payload = GovukSchemas::RandomExample.for_schema(
frontend_schema: "taxon",
)
expect {
descri... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/html_publication_schema_spec.rb | Ruby | mit | 89 | main | 7,283 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::HtmlPublicationSchema do
describe "when SchemaOrg passed schema of type :html_publication" do
let(:page) { instance_double(GovukPublishingComponents::Presenters::Page, schema: :html_publication) }
let(:schema) { instance_double(descr... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/related_navigation_helper_spec.rb | Ruby | mit | 89 | main | 12,858 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::RelatedNavigationHelper do
def payload_for(schema, content_item, context = nil)
example = GovukSchemas::RandomExample.for_schema(frontend_schema: schema) do |payload|
payload.merge(content_item)
end
described_class.new(cont... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/breadcrumb_selector_spec.rb | Ruby | mit | 89 | main | 3,242 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::BreadcrumbSelector do
subject(:breadcrumb_selector) do
described_class.new(
content_item,
request,
prioritise_taxon_breadcrumbs,
disable_ga4,
)
end
let(:example) { %w[guide guide] }
let(:content_item) {... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/shared_helper_spec.rb | Ruby | mit | 89 | main | 2,573 | RSpec.describe GovukPublishingComponents::Presenters::SharedHelper do
describe "Shared component helper" do
after do
I18n.locale = :en
end
it "returns a default heading level" do
shared_helper = described_class.new({})
heading = shared_helper.get_heading_level
expect(heading).to e... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/contents_list_helper_spec.rb | Ruby | mit | 89 | main | 3,822 | require "spec_helper"
require "action_view"
RSpec.describe GovukPublishingComponents::Presenters::ContentsListHelper do
include ActionView::Helpers::SanitizeHelper
describe "Contents list helper" do
it "wraps a number and text in separate span elements" do
assert_split_number_and_text("1. Thing", "1.", ... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/contextual_navigation_spec.rb | Ruby | mit | 89 | main | 3,324 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::ContextualNavigation do
subject(:contextual_navigation) { described_class.new(content_item, request) }
let(:example) { %w[guide guide] }
let(:content_item) { example_document_for(example.first, example.second) }
let(:path) { content_i... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/select_with_search_helper_spec.rb | Ruby | mit | 89 | main | 2,341 | require "spec_helper"
require "action_view"
RSpec.describe GovukPublishingComponents::Presenters::SelectWithSearchHelper do
describe "Select with search helper" do
it "generates options for select" do
instance = described_class.new(
options: [
{
text: "Foo",
value:... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/organisation_logo_helper_spec.rb | Ruby | mit | 89 | main | 2,175 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::OrganisationLogoHelper do
describe "#logo_content" do
it "returns a basic image" do
logo = described_class.new({ organisation: { name: "org", image: { url: "img_url" } } })
expect(logo.logo_content).to eq('<img class="gem-c-o... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/layout_footer_helper_spec.rb | Ruby | mit | 89 | main | 1,759 | RSpec.describe GovukPublishingComponents::Presenters::LayoutFooterHelper do
describe "Footer helper" do
let(:navigation) do
[
{
items: [
{
href: "/help",
text: "Help",
},
],
},
]
end
let(:meta) do
{
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/big_number_helper_spec.rb | Ruby | mit | 89 | main | 1,262 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::BigNumberHelper do
it "sets default value_classes correctly" do
big = described_class.new({})
expect(big.value_classes).to eq(["gem-c-big-number__value"])
end
it "sets default value_classes correctly when there is a href but no ... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/devolved_nations_helper_spec.rb | Ruby | mit | 89 | main | 6,096 | RSpec.describe GovukPublishingComponents::Presenters::DevolvedNationsHelper do
describe "Devolved nations component helper" do
it "returns title text, which contains one nation, correctly" do
devolved_nations_helper = described_class.new(national_applicability: {
england: {
applicable: tru... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/button_helper_spec.rb | Ruby | mit | 89 | main | 7,948 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::ButtonHelper do
describe "margin bottom" do
it "sets default margin bottom of zero" do
button = described_class.new({})
expect(button.info_text_classes).to eq(%w[gem-c-button__info-text])
end
it "sets a margin bottom... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/component_wrapper_helper_spec.rb | Ruby | mit | 89 | main | 17,485 | RSpec.describe GovukPublishingComponents::Presenters::ComponentWrapperHelper do
describe "Component helper" do
it "accepts basic component attributes" do
args = {
id: "id",
data_attributes: {
module: "module",
},
aria: {
labelledby: "element",
},
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/public_layout_helper_spec.rb | Ruby | mit | 89 | main | 1,414 | RSpec.describe GovukPublishingComponents::Presenters::PublicLayoutHelper do
describe "Public layout helper" do
let(:input) do
[
{
title: "Column 1",
menu_contents: [
{
href: "/help",
text: "Help",
attributes: {
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/single_page_notification_button_helper_spec.rb | Ruby | mit | 89 | main | 3,078 | RSpec.describe GovukPublishingComponents::Presenters::SinglePageNotificationButtonHelper do
describe "Single page notification button helper" do
it "sets button location when input is valid" do
single_helper = described_class.new(button_location: "bottom")
expect(single_helper.button_location_is_valid... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors_spec.rb | Ruby | mit | 89 | main | 2,602 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::ContentBreadcrumbsBasedOnAncestors do
describe "#breadcrumbs" do
it "can handle any valid content item" do
payload = GovukSchemas::RandomExample.for_schema(frontend_schema: "guide")
expect { described_class.new(payload).brea... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/image_card_helper_spec.rb | Ruby | mit | 89 | main | 5,747 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::ImageCardHelper do
describe "#initialize" do
it "sets basic options" do
image = described_class.new({ href: "#href", image_src: "src", image_loading: "load", large: "large", two_thirds: "thirds", large_font_size_mobile: "mobile", h... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/pagination_helper_spec.rb | Ruby | mit | 89 | main | 9,116 | require "spec_helper"
require "action_view"
require "rails_helper"
RSpec.describe GovukPublishingComponents::Presenters::PaginationHelper do
describe "Pagination helper" do
describe "#has_links?" do
it "is false if nothing passed to the component" do
instance = described_class.new({})
expec... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/schema_org_spec.rb | Ruby | mit | 89 | main | 29,843 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::SchemaOrg do
describe "#structured_data" do
it "generates schema.org Articles" do
content_item = GovukSchemas::RandomExample.for_schema(frontend_schema: "answer") do |random_item|
random_item.merge(
"base_path" =>... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/checkboxes_helper_spec.rb | Ruby | mit | 89 | main | 11,644 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::CheckboxesHelper do
items = [
{
label: "Red",
value: "red_value",
},
{
label: "Blue",
value: "blue_value",
},
]
name = "The name of this thing"
describe "#initialize" do
it "does nothing if ... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation_spec.rb | Ruby | mit | 89 | main | 37,798 | require "spec_helper"
RSpec.describe GovukPublishingComponents::Presenters::PageWithStepByStepNavigation do
let(:content_item) do
payload_for(
"guide",
"links" => {
"part_of_step_navs" => [
{
"api_path": "/api/content/learn-to-drive-a-car",
"base_path": "/lea... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/middleware/ga4_optimise_middleware_spec.rb | Ruby | mit | 89 | main | 2,772 | require "govuk_publishing_components/middleware/ga4_optimise"
describe GovukPublishingComponents::Middleware::Ga4Optimise do
subject(:ga4_optimise_middleware) { described_class.new(app) }
let(:env) { Rack::MockRequest.env_for }
let(:app) { ->(_env) { ActionDispatch::Response.create(200, { "content-type" => cont... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/app_helpers/brand_helper_spec.rb | Ruby | mit | 89 | main | 674 | require "spec_helper"
RSpec.describe GovukPublishingComponents::AppHelpers::BrandHelper do
describe "Brand helper" do
it "returns nothing if no brand is specified" do
brand = described_class.new(nil)
expect(brand.brand_class).to be_nil
expect(brand.border_color_class).to be_nil
expect(br... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/app_helpers/table_helper_spec.rb | Ruby | mit | 89 | main | 2,870 | require "rails_helper"
RSpec.describe GovukPublishingComponents::AppHelpers::TableHelper do
describe ".helper" do
let(:view_context) { GovukPublishingComponents::ApplicationController.new.view_context }
it "returns HTML for a table" do
table = described_class.helper(view_context) { |_builder| }
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs_spec.rb | Ruby | mit | 89 | main | 2,611 | require "spec_helper"
RSpec.describe GovukPublishingComponents::AppHelpers::TaxonBreadcrumbs do
describe "Taxon breadcrumbs" do
it "can handle any valid content item" do
payload = GovukSchemas::RandomExample.for_schema(
frontend_schema: "taxon",
)
expect {
described_class.new(p... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/lib/govuk_publishing_components/app_helpers/environment_spec.rb | Ruby | mit | 89 | main | 1,018 | require "spec_helper"
RSpec.describe GovukPublishingComponents::AppHelpers::Environment do
describe ".current_acceptance_environment" do
it "returns development by default" do
expect(environment_name_for(nil)).to eql("development")
expect(environment_name_for("something-else")).to eql("development")
... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/component_guide/component_example_accessibility_criteria_spec.rb | Ruby | mit | 89 | main | 999 | require "rails_helper"
describe "Component examples with accessibility criteria", :capybara do
it "shows the accessibility acceptance criteria as HTML" do
visit "/component-guide/test_component"
within ".component-accessibility-criteria" do
expect(page).to have_selector("h3", text: "Accessibility acce... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/component_guide/audit_comparer_spec.rb | Ruby | mit | 89 | main | 19,427 | require "rails_helper"
require_relative "../../app/models/govuk_publishing_components/audit_comparer"
describe "Comparing data from an application with the components" do
gem = {
gem_found: true,
name: "govuk_publishing_components",
component_code: [
"component one",
"component two",
"c... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/component_guide/component_audit_spec.rb | Ruby | mit | 89 | main | 215 | require "rails_helper"
describe "Component audit page", :capybara do
it "renders the audit page" do
visit "/component-guide/audit"
expect(page).to have_title "Component audit - Component Guide"
end
end |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/component_guide/audit_applications_spec.rb | Ruby | mit | 89 | main | 8,888 | require "rails_helper"
require_relative "../../app/models/govuk_publishing_components/audit_applications"
describe "Auditing the components in applications" do
it "returns correct information" do
path = File.join(Dir.pwd, "/spec/dummy")
application = GovukPublishingComponents::AuditApplications.new(path, "an... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/component_guide/component_example_accessibility_testing_spec.rb | Ruby | mit | 89 | main | 2,159 | require "rails_helper"
describe "Component example with automated testing", :capybara, :js do
it "has accessibility testing hooks" do
visit "/component-guide/test_component"
expect(page).to have_selector('[data-module="test-a11y"]')
end
it "runs automated accessibility testing tools" do
visit "/comp... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/component_guide/applications_page_spec.rb | Ruby | mit | 89 | main | 6,526 | require "rails_helper"
require_relative "../../app/models/govuk_publishing_components/applications_page"
describe "The applications status page" do
fake_app = "application"
fake_gemfile = "
govspeak (10.6.5)
govuk_publishing_components (>= 43)
govuk_ab_testing (3.0.0)
govuk_publishing_components ... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/component_guide/component_example_spec.rb | Ruby | mit | 89 | main | 6,949 | require "rails_helper"
describe "Component example", :capybara do
it "illustrates how to use the component" do
visit "/component-guide/test_component"
expect(body).to include("How to call this component")
expect(page).to have_content('<%= render "components/test_component", {} %>')
end
it "includes... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/component_guide/component_preview_spec.rb | Ruby | mit | 89 | main | 2,414 | require "rails_helper"
describe "Component preview", :capybara do
it "shows all component examples on a page without header or footer" do
visit "/component-guide/test_component_with_params/preview"
expect(page).to have_selector(".govuk-template--rebranded")
expect(page).to have_selector(".govuk-width-con... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/component_guide/component_index_spec.rb | Ruby | mit | 89 | main | 5,632 | require "rails_helper"
describe "Component guide index", :capybara do
# Load ordering test can only fail if run as the first test in suite
# https://github.com/rails/rails/issues/12168
it "renders using gem layout not app layout after viewing a page on the application" do
visit "/test"
expect(page).to ha... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | spec/component_guide/audit_components_spec.rb | Ruby | mit | 89 | main | 5,097 | require "rails_helper"
require_relative "../../app/models/govuk_publishing_components/audit_components"
describe "Auditing the components in the gem" do
it "fails gracefully if the gem is not found" do
path = File.join(File.dirname(__FILE__), "not/a/real/directory")
gem = GovukPublishingComponents::AuditComp... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | config/routes.rb | Ruby | mit | 89 | main | 533 | GovukPublishingComponents::Engine.routes.draw do
get "/audit" => "audit#show", as: :audit
get "/applications" => "applications_page#show", as: :apps
root to: "component_guide#index", as: :component_guide
get ":component/preview" => "component_guide#preview", as: :component_preview_all
get ":component/:example... |
github | alphagov/govuk_publishing_components | https://github.com/alphagov/govuk_publishing_components | config/initializers/assets.rb | Ruby | mit | 89 | main | 1,152 | return unless Rails.application.config.respond_to?(:assets)
# Include the govuk_publishing_components manifest into list of assets to
# be pre-compiled. This allows that the same Sprockets manifest to be used 0
# with Sprockets 3 and 4 without applications needing to manually require it.
#
# In future we may want appl... |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | roundtrip.gemspec | Ruby | mit | 89 | master | 1,192 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'roundtrip/version'
Gem::Specification.new do |gem|
gem.name = "roundtrip"
gem.version = Roundtrip::VERSION
gem.authors = ["Dotan Nahum"]
gem.email =... |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | config.ru | Ruby | mit | 89 | master | 200 | $:<< 'lib'
require 'roundtrip'
Roundtrip.options[:redis] = { :host => 'localhost' }
Roundtrip.options[:statsd] = { :host => 'localhost', :port => 8125 }
require 'roundtrip/web'
run Roundtrip::Web |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | examples/ruby_httparty.rb | Ruby | mit | 89 | master | 477 | require 'httparty'
#
# run Roundtrip on localhost:9292 (default rack).
#
resp = HTTParty.post 'http://localhost:9292/trips', :body => { :route => 'invoicing' }
# carry this ID around with you.
id = resp["id"]
HTTParty.patch "http://localhost:9292/trips/#{id}", :body => { :checkpoint => 'generate.pdf' }
HTTParty.pat... |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | spec/spec_helper.rb | Ruby | mit | 89 | master | 206 | $: << File.expand_path('../lib', File.dirname(__FILE__))
require 'rr'
require 'roundtrip'
require 'minitest/autorun'
require 'timecop'
class MiniTest::Unit::TestCase
include RR::Adapters::MiniTest
end |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | spec/roundtrip/trip_spec.rb | Ruby | mit | 89 | master | 534 | require 'spec_helper'
require 'roundtrip/trip'
module Roundtrip
describe Trip do
describe "::generate" do
it "should generate with a random ID if none given" do
t1 = Trip.generate("foo")
t2 = Trip.generate("foo", :invalid_option => 'poo')
t1.route.must_equal "foo"
t1.id.won... |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | spec/roundtrip/core_spec.rb | Ruby | mit | 89 | master | 3,394 | require 'spec_helper'
require 'roundtrip/core'
module Roundtrip
describe Core do
let(:trip_id) { 'C0FFEEBABE' }
let(:trip) do
Trip.new(trip_id, 'prod', Time.now)
end
describe "#start" do
it "should start" do
mock(Roundtrip::Trip).generate('prod', {}){ trip }
store = Obje... |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | spec/roundtrip/metrics/statsd_spec.rb | Ruby | mit | 89 | master | 1,137 | require 'spec_helper'
require 'roundtrip/metrics/statsd'
require 'timecop'
module Roundtrip
describe Metrics::Statsd do
it "should time checkpoints" do
trip = Trip.new('trip', 'prod', Time.at(1354366786.0090559))
statsd = Object.new
mock(statsd).timing("prod.invoice.created", 2789)
metri... |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | spec/roundtrip/store/redis_spec.rb | Ruby | mit | 89 | master | 2,390 | require 'spec_helper'
require 'roundtrip/store/redis'
require 'redis'
require 'redis/namespace'
require 'timecop'
# dirty test. requires running a local redis
# todo: check how redis rb does its tests. (and how integrates with travis-ci)
module Roundtrip
describe Store::Redis do
before do
@redis = ::Red... |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | lib/roundtrip.rb | Ruby | mit | 89 | master | 200 | require "roundtrip/version"
module Roundtrip
def self.options
@options ||= {}
end
end
require 'roundtrip/trip'
require 'roundtrip/core'
require 'roundtrip/store'
require 'roundtrip/metrics' |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | lib/roundtrip/web.rb | Ruby | mit | 89 | master | 2,501 | require 'roundtrip'
require 'roundtrip/store/redis'
require 'roundtrip/metrics/statsd'
require 'sinatra'
require 'json'
require 'atom'
# XXX
# put on heroku
# change url to be provider based at admin
# set up configuration for redis to one of the test instances
# check cross-cycle
#
class Roundtrip::Web < Sinatra::B... |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | lib/roundtrip/core.rb | Ruby | mit | 89 | master | 1,242 | require 'roundtrip/trip'
class Roundtrip::Core
def initialize(store, metrics=Roundtrip::Metrics::Null.new)
@store = store
@metrics = metrics
end
def start(route, opts={})
must_be_present! route
t = Roundtrip::Trip.generate(route, opts)
@store.add(t)
t
end
def checkpoint(id, at)
... |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | lib/roundtrip/cli.rb | Ruby | mit | 89 | master | 421 | require 'roundtrip'
require 'thor'
require 'roundtrip/store/redis'
class Roundtrip::CLI < Thor
desc "start [ROUTE]", "starts a new trip on a given route"
def start(route)
t = core.start(route)
say t.to_h
end
desc "end [TRIP_ID]", "ends a trip"
def end(trip_id)
t = core.end(trip_id)
say t.to... |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | lib/roundtrip/trip.rb | Ruby | mit | 89 | master | 691 | require 'securerandom'
require 'time'
class Roundtrip::Trip
attr_accessor :id, :route, :started_at, :checkpoints
def initialize(id, route, started_at)
self.id = id
self.route = route
self.started_at = started_at
self.checkpoints = []
end
def to_json(*a)
to_h.to_json(*a)
end
def to_... |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | lib/roundtrip/metrics/statsd.rb | Ruby | mit | 89 | master | 321 | require 'statsd'
class Roundtrip::Metrics::Statsd
def initialize(opts={:statsd => {:host => 'localhost', :port => 8125}})
@statsd =opts[:statsd][:connection] || ::Statsd.new(opts[:statsd][:host], opts[:statsd][:port])
end
def time(route, event, time)
@statsd.timing("#{route}.#{event}", time)
end
end |
github | jondot/roundtrip | https://github.com/jondot/roundtrip | lib/roundtrip/store/redis.rb | Ruby | mit | 89 | master | 1,522 | require 'roundtrip/store'
require 'redis'
class Roundtrip::Store::Redis
def initialize(opts={:redis => {:host => 'localhost'}})
@conn = opts[:redis][:connection] || Redis.new(opts[:redis])
end
def get(id)
blob = @conn.get(trip_key(id))
trip = Marshal.load(blob) if blob
if trip
trip.check... |
github | perplexes/m2r | https://github.com/perplexes/m2r | Rakefile | Ruby | mit | 89 | master | 521 | #!/usr/bin/env rake
require 'bundler/gem_tasks'
require 'rake/testtask'
Rake::TestTask.new('test:unit') do |test|
test.pattern = 'test/unit/*_test.rb'
test.libs << 'lib' << 'test'
end
Rake::TestTask.new('test:acceptance') do |test|
test.pattern = 'test/acceptance/*_test.rb'
test.libs << 'lib' << 'test'
end
... |
github | perplexes/m2r | https://github.com/perplexes/m2r | m2r.gemspec | Ruby | mit | 89 | master | 1,644 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/m2r/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Colin Curtin", "Pradeep Elankumaran", "Pawel Pacana", "Robert Pankowecki"]
gem.email = ["colin.t.curtin+m2r@gmail.com", "pawel.pacana+m2r@gmail.com", "robert.pankow... |
github | perplexes/m2r | https://github.com/perplexes/m2r | Vagrantfile | Ruby | mit | 89 | master | 467 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |multi|
multi.vm.define :m2r do |config|
config.vm.box = "m2r"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.host_name = "m2r.local"
config.vm.network :hostonly, "172.26.66.100"
config.vm.share_folder ... |
github | perplexes/m2r | https://github.com/perplexes/m2r | example/uploading.ru | Ruby | mit | 89 | master | 974 | # Running this example:
#
# m2sh load -config mongrel2.conf
# bundle exec foreman start
#
# Browse now to http://localhost:6767/uploading to see the effect.
#
# This example is not threadsafe !
$stdout.sync = true
$stderr.sync = true
require 'rack'
require 'pathname'
use Rack::ContentLength
size = 0
app = Proc.n... |
github | perplexes/m2r | https://github.com/perplexes/m2r | example/http_0mq.rb | Ruby | mit | 89 | master | 1,517 | # An example handler from the Mongrel2 manual. You can spin up many
# of these, Mongrel2 will then round-robin requests to each one.
#
# Running this example:
#
# m2sh load -config mongrel2.conf
# bundle exec foreman start
#
# Browse now to http://localhost:6767/handler to see the effect.
$stdout.sync = true
$stde... |
github | perplexes/m2r | https://github.com/perplexes/m2r | example/lobster.ru | Ruby | mit | 89 | master | 311 | # An example of running Rack application.
#
# Running this example:
#
# m2sh load -config mongrel2.conf
# bundle exec foreman start
#
# Browse now to http://localhost:6767/rack to see the effect.
$stdout.sync = true
$stderr.sync = true
require 'rack/lobster'
use Rack::ContentLength
run Rack::Lobster.new |
github | perplexes/m2r | https://github.com/perplexes/m2r | lib/m2r.rb | Ruby | mit | 89 | master | 1,480 | require 'ffi-rzmq'
require 'json'
require 'tnetstring'
require 'thread'
# Allows you to easily interact with Mongrel2 webserver from
# your ruby code.
# @api public
module M2R
class << self
# Sets ZMQ context used by M2R to create sockets
# @param [ZMQ::Context] value Context to by used by M2R
# @see #z... |
github | perplexes/m2r | https://github.com/perplexes/m2r | lib/rack/handler/mongrel2.rb | Ruby | mit | 89 | master | 1,453 | require 'rack/handler'
require 'm2r/rack_handler'
require 'securerandom'
require 'ostruct'
module Rack
module Handler
class Mongrel2
DEFAULT_OPTIONS = {
'recv_addr' => 'tcp://127.0.0.1:9997',
'send_addr' => 'tcp://127.0.0.1:9996',
'sender_id' => SecureRandom.uuid
}
def ... |
github | perplexes/m2r | https://github.com/perplexes/m2r | lib/m2r/connection.rb | Ruby | mit | 89 | master | 2,800 | module M2R
# Connection for exchanging data with mongrel2
class Connection
class Error < StandardError
attr_accessor :errno
def signal?
errno == ZMQ::EINTR
end
end
# @param [ZMQ::Socket] request_socket socket for receiving requests
# from Mongrel2
# @param [ZMQ::Sock... |
github | perplexes/m2r | https://github.com/perplexes/m2r | lib/m2r/parser.rb | Ruby | mit | 89 | master | 1,094 | require 'm2r/request'
module M2R
# Mongrel2 Request Parser
# @api public
class Parser
# Parse Mongrel2 request received via ZMQ message
#
# @param [String] msg Monrel2 Request message formatted according to rules
# of creating it described it m2 manual.
# @return [Request]
#
# @api ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.