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/smart-answers
https://github.com/alphagov/smart-answers
test/unit/format_capture_helper_test.rb
Ruby
mit
179
main
3,207
require_relative "../test_helper" module SmartAnswer class FormatCaptureHelperTest < ActiveSupport::TestCase setup do mock_actionview_class = Class.new do def content_for(name, content = nil, _options = {}, &_block) @content_for ||= {} if content @content_for[name] =...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/list_validator_test.rb
Ruby
mit
179
main
1,559
require "test_helper" class ListValidatorTest < ActiveSupport::TestCase context "#all_valid?" do setup do @list_validator = ListValidator.new(%i[a b c d]) end should "returns true if list is valid" do assert @list_validator.all_valid?(%i[a b]) end should "returns false if list conte...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/date_range_test.rb
Ruby
mit
179
main
16,527
require_relative "../test_helper" module SmartAnswer class DateRangeTest < ActiveSupport::TestCase context "when range is built with begins_on & ends_on" do setup do @date_range = DateRange.new(begins_on: Date.parse("2000-01-01"), ends_on: Date.parse("2000-01-07")) end should "begin on...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/question_presenter_test.rb
Ruby
mit
179
main
5,997
require_relative "../test_helper" module SmartAnswer class QuestionPresenterTest < ActiveSupport::TestCase setup do @question = Question::Base.new(nil, :question_name?) @renderer = stub("renderer") @presenter = QuestionPresenter.new(@question, nil, nil, renderer: @renderer) end test ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/method_invocations_parser_test.rb
Ruby
mit
179
main
5,396
require_relative "../test_helper" require "ast/sexp" require "method_source" module SmartAnswer class MethodInvocationsParserTest < ActiveSupport::TestCase include AST::Sexp context "method with no arguments" do setup do mod = Module.new do def method_with_no_args; end # rubocop:dis...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/node_test.rb
Ruby
mit
179
main
7,177
require_relative "../test_helper" module SmartAnswer class NodeTest < ActiveSupport::TestCase setup do @flow = Flow.build @node = Node.new(@flow, "node-name") @load_path = FlowRegistry.instance.load_path end test "#template_directory returns the path to the templates based on the class...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/outcome_test.rb
Ruby
mit
179
main
399
require_relative "../test_helper" module SmartAnswer class OutcomeTest < ActiveSupport::TestCase setup do @outcome = Outcome.new(nil, "node-name") end context "#transition" do should "raise InvalidTransition exception so app responds with 404 Not Found" do assert_raises(InvalidTransi...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/money_question_presenter_test.rb
Ruby
mit
179
main
1,427
require_relative "../test_helper" module SmartAnswer class MoneyQuestionPresenterTest < ActiveSupport::TestCase setup do @question = Question::Base.new(nil, :question_name?) @renderer = stub("renderer") @presenter = MoneyQuestionPresenter.new(@question, nil, nil, renderer: @renderer) end ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/date_helper_test.rb
Ruby
mit
179
main
963
require_relative "../test_helper" require_relative "../../lib/smart_answer/date_helper" module SmartAnswer class DateHelperTest < ActiveSupport::TestCase include DateHelper context "next_saturday" do should "return the following saturday for a provided date" do assert_equal Date.parse("2012 Ma...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/year_question_test.rb
Ruby
mit
179
main
4,485
require_relative "../test_helper" require "ostruct" module SmartAnswer class YearQuestionTest < ActiveSupport::TestCase def setup @initial_state = State.new(:example) end context "#parse_input" do setup do @question = Question::Year.new(nil, :example) end context "when s...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/session_response_store_test.rb
Ruby
mit
179
main
2,081
require_relative "../test_helper" class SessionResponseStoreTest < ActiveSupport::TestCase context "#all" do should "return hash of keys and responses for flow" do session = { "flow" => { "key" => "value", "key2" => "value2" } } response_store = SessionResponseStore.new(flow_name: "flow", session:) ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/state_resolver_test.rb
Ruby
mit
179
main
7,801
require_relative "../test_helper" module SmartAnswer class StateResolverTest < ActiveSupport::TestCase setup do @flow = SmartAnswer::Flow.build do additional_parameters %w[c d] setup do self.e = :f end radio :x do option :yes option :no ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/start_node_presenter_test.rb
Ruby
mit
179
main
2,644
require_relative "../test_helper" module SmartAnswer class StartNodePresenterTest < ActiveSupport::TestCase setup do start_node = Node.new(nil, :start_node_name) @renderer = stub("renderer") @presenter = StartNodePresenter.new(start_node, nil, nil, renderer: @renderer) end test "render...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/year_range_test.rb
Ruby
mit
179
main
2,567
require_relative "../test_helper" module SmartAnswer class YearRangeTest < ActiveSupport::TestCase context "not including the 29th Feb of a leap year" do setup do @year_range = YearRange.new(begins_on: Date.parse("2000-03-01")) end should "begin on begins_on date" do assert_equ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/salary_question_presenter_test.rb
Ruby
mit
179
main
1,234
require_relative "../test_helper" module SmartAnswer class SalaryQuestionPresenterTest < ActiveSupport::TestCase setup do @question = Question::Salary.new(nil, :question_name?) @renderer = stub("renderer") @presenter = SalaryQuestionPresenter.new(@question, nil, nil, renderer: @renderer) e...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/checkbox_question_presenter_test.rb
Ruby
mit
179
main
3,260
require_relative "../test_helper" module SmartAnswer class CheckboxQuestionPresenterTest < ActiveSupport::TestCase setup do @question = Question::Checkbox.new(nil, :question_name?) @question.option(:option1) @question.option(:option2) @question.option(:option3) @renderer = stub("re...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/radio_with_intro_question_presenter_test.rb
Ruby
mit
179
main
659
require_relative "../test_helper" module SmartAnswer class RadioWithIntroQuestionPresenterTest < ActiveSupport::TestCase setup do @question = Question::RadioWithIntro.new(nil, :question_name?) @renderer = stub("renderer") @presenter = RadioWithIntroQuestionPresenter.new(@question, nil, nil, ren...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/salary_test.rb
Ruby
mit
179
main
777
require_relative "../test_helper" module SmartAnswer class SalaryTest < ActiveSupport::TestCase test "Can convert monthly to weekly salary" do monthly = Salary.new("520", "month") expected_weekly = SmartAnswer::Money.new("120") assert_equal expected_weekly, monthly.per_week end test "C...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/question_base_test.rb
Ruby
mit
179
main
2,151
require_relative "../test_helper" class QuestionBaseTest < ActiveSupport::TestCase setup do @question = SmartAnswer::Question::Base.new(nil, :example_question) end context "#on_response" do should "not allow multiple definitions of on_response" do assert_raises(RuntimeError, "Multiple on_response ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/radio_question_test.rb
Ruby
mit
179
main
1,927
require_relative "../test_helper" module SmartAnswer class RadioQuestionTest < ActiveSupport::TestCase test "Can add options as keys" do q = Question::Radio.new(nil, :example) do option :yes option :no end assert_equal %w[yes no], q.option_keys end test "Can add option...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/link_checker_test.rb
Ruby
mit
179
main
1,592
require "test_helper" require "gds_api/test_helpers/link_checker_api" class LinkCheckerTest < ActiveSupport::TestCase include GdsApi::TestHelpers::LinkCheckerApi def url @url ||= "http://example.com" end def text @text ||= %(There is a link <a href="#{url}">here</a>) end def link_checker @li...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/method_missing_object_test.rb
Ruby
mit
179
main
1,866
require_relative "../test_helper" class MethodMissingObjectTest < ActiveSupport::TestCase setup do @object = MethodMissingObject.new(:method_one) end should "allow call to unknown method" do @object.method_two end should "use method name as description" do assert_equal "method_one", @object.des...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/checkbox_question_test.rb
Ruby
mit
179
main
3,490
require_relative "../test_helper" module SmartAnswer class CheckboxQuestionTest < ActiveSupport::TestCase context "specifying options" do should "be able to specify options, and retreive them in the order specified" do q = Question::Checkbox.new(nil, :something) do option :red o...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/world_location_test.rb
Ruby
mit
179
main
8,146
require_relative "../test_helper" class WorldLocationTest < ActiveSupport::TestCase context "loading all locations" do should "load locations and construct an instance for each one" do @location_slugs = %w[the-shire rivendel rohan lorien gondor arnor mordor] stub_worldwide_api_has_locations(@location...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/radio_question_presenter_test.rb
Ruby
mit
179
main
1,669
require_relative "../test_helper" module SmartAnswer class RadioQuestionPresenterTest < ActiveSupport::TestCase setup do @question = Question::Radio.new(nil, :question_name?) @question.option(:option1) @question.option(:option2) @question.option(:option3) @renderer = stub("renderer...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/country_select_question_test.rb
Ruby
mit
179
main
2,676
require_relative "../test_helper" module SmartAnswer class CountrySelectQuestionTest < ActiveSupport::TestCase context "using the worldwide API data" do setup do stub_worldwide_api_has_locations(%w[afghanistan british-antarctic-territory denmark the-gambia holy-see united-kingdom vietnam]) ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/erb_renderer_test.rb
Ruby
mit
179
main
5,820
require_relative "../test_helper" module SmartAnswer class ErbRendererTest < ActiveSupport::TestCase test "can render a template" do erb_template = %{<%= text_for(:key) { "content" } %>} with_erb_template_file("template-name", erb_template) do |erb_template_directory| renderer = ErbRenderer.n...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/money_test.rb
Ruby
mit
179
main
3,073
require_relative "../test_helper" module SmartAnswer class MoneyTest < ActiveSupport::TestCase test "Can compare money with money" do two = SmartAnswer::Money.new("2") assert SmartAnswer::Money.new("2") == two assert SmartAnswer::Money.new("3") > two assert SmartAnswer::Money.new("1") < t...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/salary_question_test.rb
Ruby
mit
179
main
1,249
require_relative "../test_helper" require "ostruct" module SmartAnswer class SalaryQuestionTest < ActiveSupport::TestCase def setup @initial_state = State.new(:example) end test "Treats input as weekly Salary by default" do q = Question::Salary.new(nil, :example) do on_response do |r...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/flow_registry_test.rb
Ruby
mit
179
main
952
require_relative "../test_helper" module SmartAnswer class FlowRegistryTest < ActiveSupport::TestCase setup { require_fixture_flows } def registry(options = {}) FlowRegistry.new(options.merge(smart_answer_load_path: File.expand_path("../fixtures/flows", __dir__))) end test "Can load a flow fr...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/date_question_test.rb
Ruby
mit
179
main
9,733
require_relative "../test_helper" require "ostruct" module SmartAnswer class DateQuestionTest < ActiveSupport::TestCase def setup @initial_state = State.new(:example) end context "#parse_input" do setup do @question = Question::Date.new(nil, :example) end context "when s...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/flow_presenter_test.rb
Ruby
mit
179
main
5,612
require_relative "../test_helper" class FlowPresenterTest < ActiveSupport::TestCase include Rails.application.routes.url_helpers def flow_registry SmartAnswer::FlowRegistry.instance end setup do @flow = SmartAnswer::Flow.build do name "flow-name" value_question :first_question_key do ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/broken_link_report_test.rb
Ruby
mit
179
main
4,112
require "test_helper" require "minitest/autorun" class BrokenLinkReportTest < ActiveSupport::TestCase def path # Defaulting path to only radio-sample flow to limit scope of most tests (simpler and faster) @path ||= Rails.root.join "test/fixtures/flows/radio_sample_flow" end def broken_link_report @b...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/node_presenter_test.rb
Ruby
mit
179
main
1,268
require "test_helper" class NodePresenterTest < ActiveSupport::TestCase def node OpenStruct.new(name: :foo_bar, slug: "foo-bar", view_template_path: "view") end def node_presenter @node_presenter ||= NodePresenter.new(node, nil) end context "#node_name" do should "return node name" do ass...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/postcode_question_test.rb
Ruby
mit
179
main
1,107
require_relative "../test_helper" module SmartAnswer class PostcodeQuestionTest < ActiveSupport::TestCase def setup @initial_state = State.new(:example) @question = Question::Postcode.new(nil, :example) do on_response do |response| self.my_postcode = response end ne...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/graph_presenter_test.rb
Ruby
mit
179
main
1,415
require_relative "../test_helper" module SmartAnswer class GraphPresenterTest < ActiveSupport::TestCase setup do setup_fixture_flows @flow = GraphFlow.build @presenter = GraphPresenter.new(@flow) end teardown do teardown_fixture_flows end test "presents labels of graph f...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/date_of_birth_test.rb
Ruby
mit
179
main
1,573
require_relative "../test_helper" module SmartAnswer class DateOfBirthTest < ActiveSupport::TestCase setup do @today = Date.parse("2015-05-15") travel_to(@today) end context "when birthday has not yet occurred in this year" do setup do @dob = DateOfBirth.new(@today - 50.years +...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/query_parameters_response_store_test.rb
Ruby
mit
179
main
475
require_relative "../test_helper" class QueryParametersResponseStoreTest < ActiveSupport::TestCase context "#new" do should "not store parameters unless specified key" do responses = { k: "v", k2: "v2", k3: "v3" } response_store = QueryParametersResponseStore.new( query_parameters: responses,...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/worldwide_organisation_test.rb
Ruby
mit
179
main
4,599
require_relative "../test_helper" class WorldwideOrganisationTest < ActiveSupport::TestCase context ".for_location" do should "instantiates WorldwideOrganisation objects using data from the API" do organisations_data = [ { "title" => "organisation-1-title", "base_path" => "/world/organisations/orga...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/working_days_test.rb
Ruby
mit
179
main
3,346
require_relative "../test_helper" require "working_days" class WorkingDaysTest < ActiveSupport::TestCase setup do WebMock.stub_request(:get, WorkingDays::BANK_HOLIDAYS_URL) .to_return(body: File.open(fixture_file("bank_holidays.json"))) end context "adding working days" do should "add the given nu...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/state_pension_date_query_test.rb
Ruby
mit
179
main
93,650
require_relative "../../lib/state_pension_date_query" require_relative "../test_helper" class StatePensionDateQueryTest < ActiveSupport::TestCase context "when female, born between 1 January 1890 and 5 April 1950" do should "return state pension date 60 years from date of birth" do assert_equal StatePensio...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/outcome_presenter_test.rb
Ruby
mit
179
main
3,064
require_relative "../test_helper" module SmartAnswer class OutcomePresenterTest < ActiveSupport::TestCase setup do outcome = Outcome.new(nil, :outcome_name) @renderer = stub("renderer") @presenter = OutcomePresenter.new(outcome, nil, nil, renderer: @renderer) end test "renderer is cons...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/next_node_block_test.rb
Ruby
mit
179
main
3,070
require_relative "../test_helper" module SmartAnswer module Question class PermittedNodeKeyTest < ActiveSupport::TestCase context "key constructed with nil" do setup do @key = NextNodeBlock::PermittedNodeKey.new(nil) end should "be nil" do assert @key.nil? ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/year_question_presenter_test.rb
Ruby
mit
179
main
1,207
require_relative "../test_helper" module SmartAnswer class YearQuestionPresenterTest < ActiveSupport::TestCase setup do @question = Question::Year.new(nil, :question_name?) @renderer = stub("renderer") @presenter = YearQuestionPresenter.new(@question, nil, nil, renderer: @renderer) end ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/value_question_test.rb
Ruby
mit
179
main
4,165
require_relative "../test_helper" require "ostruct" module SmartAnswer class ValueQuestionTest < ActiveSupport::TestCase setup do @initial_state = State.new(:example) end should "save value as a String by default" do q = Question::Value.new(nil, :example) do on_response do |response|...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/flow_test.rb
Ruby
mit
179
main
6,977
require_relative "../test_helper" class FlowTest < ActiveSupport::TestCase test "Can set the name" do s = SmartAnswer::Flow.build do name "sweet-or-savoury" end assert_equal "sweet-or-savoury", s.name end test "can set response store type" do smart_answer = SmartAnswer::Flow.build do ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/response_store_test.rb
Ruby
mit
179
main
1,926
require_relative "../test_helper" class ResponseStoreTest < ActiveSupport::TestCase context "#all" do should "return hash of keys and responses for flow" do responses = { "key" => "value", "key2" => "value2" } response_store = ResponseStore.new(responses:) assert_equal responses, response_stor...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/content_item_presenter_test.rb
Ruby
mit
179
main
2,061
require_relative "../test_helper" require "govuk_schemas/assert_matchers" module SmartAnswer class ContentItemPresenterPresenterTest < ActiveSupport::TestCase include GovukSchemas::AssertMatchers setup do setup_fixture_flows @flow = SmartAnswer::FlowRegistry.instance.find("bridge-of-death") ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/money_question_test.rb
Ruby
mit
179
main
861
require_relative "../test_helper" require "ostruct" module SmartAnswer class MoneyQuestionTest < ActiveSupport::TestCase def setup @initial_state = State.new(:example) end test "Value saved as a Money instance" do q = Question::Money.new(nil, :example) do on_response do |response| ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/state_test.rb
Ruby
mit
179
main
2,501
require_relative "../test_helper" module SmartAnswer class StateTest < ActiveSupport::TestCase context "transitioning to a new state" do should "not modify the existing state" do old_state = State.new(:state2) old_state.accepted_responses = { state1: "answer" } old_state.freeze ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/date_question_presenter_test.rb
Ruby
mit
179
main
1,222
require_relative "../test_helper" module SmartAnswer class DateQuestionPresenterTest < ActiveSupport::TestCase setup do @question = Question::Date.new(nil, :question_name?) @renderer = stub("renderer") @presenter = DateQuestionPresenter.new(@question, nil, nil, renderer: @renderer) end ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/state_pension_date_test.rb
Ruby
mit
179
main
3,013
require_relative "../../lib/state_pension_date" require_relative "../test_helper" class StatePensionDateTest < ActiveSupport::TestCase context "#born_in_range" do setup do @pension_date = StatePensionDate.new(:female, Date.parse("6 April 1950"), Date.parse("5 May 1950"), Date.parse("6 May 2010")) end ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/question_with_options_presenter_test.rb
Ruby
mit
179
main
1,454
require_relative "../test_helper" module SmartAnswer class QuestionWithOptionsPresenterTest < ActiveSupport::TestCase setup do @renderer = stub("renderer") @renderer.stubs(:option).with("option_one").returns("option-one-text") @renderer.stubs(:option).with("option_two").returns({ label: "optio...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/formatting_helper_test.rb
Ruby
mit
179
main
2,952
require_relative "../test_helper" module SmartAnswer class FormattingHelperTest < ActiveSupport::TestCase include FormattingHelper test "#format_money accepts large formatted values" do assert_equal "£1,234.56", format_money("1,234.56") assert_equal "-£1,234.56", format_money("-1,234.56") en...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/year_range_with_fixed_start_date_test.rb
Ruby
mit
179
main
2,042
require_relative "../test_helper" module SmartAnswer class YearRangeWithFixedStartDateTest < ActiveSupport::TestCase context "with a tax year" do setup do @tax_year = YearRangeWithFixedStartDate.new("6 April") end context "when tax year is built for specified year" do setup do ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/value_question_presenter_test.rb
Ruby
mit
179
main
594
require_relative "../test_helper" module SmartAnswer class ValueQuestionPresenterTest < ActiveSupport::TestCase setup do @question = Question::Base.new(nil, :question_name?) @renderer = stub("renderer") @presenter = ValueQuestionPresenter.new(@question, nil, nil, renderer: @renderer) end ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/services/content_item_syncer_test.rb
Ruby
mit
179
main
933
require "test_helper" class ContentItemSyncerTest < ActiveSupport::TestCase context "#sync" do setup do setup_fixture_flows content_id = SecureRandom.uuid @flow = SmartAnswer::FlowRegistry.instance.find("bridge-of-death") @flow.content_id(content_id) @draft_request = stub_publishin...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/services/content_block_detector_test.rb
Ruby
mit
179
main
3,549
require "test_helper" class ContentBlockDetectorTest < ActiveSupport::TestCase setup do @flow = mock("flow") @flow.stubs(:name).returns("example") @flow_class = mock("flow_class") @flow_class.stubs(:to_s).returns("ExampleFlow") @flow.stubs(:class).returns(@flow_class) @flow_file = "/path/to/...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/services/content_item_retriever_test.rb
Ruby
mit
179
main
3,111
require "test_helper" class ContentItemRetrieverTest < ActiveSupport::TestCase setup do @slug = "example-smart-answer" @content_store_response = { base_path: "/#{@slug}", content_id: "c22fa786-6c0d-4e38-a82f-c8ca341f9260", title: "Example Smart Answer", links: { organisations:...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/translator_links_test.rb
Ruby
mit
179
main
1,554
require_relative "../../test_helper" module SmartAnswer::Calculators class TranslatorLinksTest < ActiveSupport::TestCase context TranslatorLinks do setup do YAML.stubs(:load_file).returns( "spain" => "/government/publications/spain-list-of-lawyers", "switzerland" => "/government...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/rates_query_test.rb
Ruby
mit
179
main
3,572
require_relative "../../test_helper" module SmartAnswer::Calculators class RatesQueryTest < ActiveSupport::TestCase context "#rates" do setup do @test_rate = RatesQuery.from_file( "exact_date_rates", load_path: "test/fixtures/rates", ) end should "be 1 for 2...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/register_a_death_calculator_test.rb
Ruby
mit
179
main
1,791
require_relative "../../test_helper" module SmartAnswer module Calculators class RegisterADeathCalculatorTest < ActiveSupport::TestCase setup do @calculator = RegisterADeathCalculator.new @stub_rates_query = RatesQuery.stubs(:from_file).with("register_a_death") end context "fee...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/birth_calculator_test.rb
Ruby
mit
179
main
1,145
require_relative "../../test_helper" module SmartAnswer::Calculators class BirthCalculatorTest < ActiveSupport::TestCase context BirthCalculator do context "basic tests" do # Birth 22/12/12 # QW 02/09/12 - 08/09/12 # Employ start 17/03/12 context "birth 2012 Dec 22" do ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/plan_maternity_leave_test.rb
Ruby
mit
179
main
2,341
require_relative "../../test_helper" module SmartAnswer::Calculators class PlanMaternityLeaveTest < ActiveSupport::TestCase context PlanMaternityLeave do setup do @due_date = "2013-01-02" @start_date = "2012-12-19" # 2 weeks @calculator = PlanMaternityLeave.new(due_date: @due_date) ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/child_benefit_tax_calculator_test.rb
Ruby
mit
179
main
45,352
require_relative "../../test_helper" module SmartAnswer::Calculators class ChildBenefitTaxCalculatorTest < ActiveSupport::TestCase context ChildBenefitTaxCalculator do context "validations" do context "#valid_number_of_children?" do should "be valid when there are less than 30 children" d...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/consulate_data_query_test.rb
Ruby
mit
179
main
756
require_relative "../../test_helper" module SmartAnswer::Calculators class ConsulateDataQueryTest < ActiveSupport::TestCase context ConsulateDataQuery do setup do @described_class = ConsulateDataQuery @query = @described_class.new end context "has_consulate?" do should ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/maternity_paternity_pay_leave_calculator_test.rb
Ruby
mit
179
main
11,418
require_relative "../../test_helper" module SmartAnswer module Calculators class MaternityPaternityPayLeaveCalculatorTest < ActiveSupport::TestCase setup do @due_date = Date.parse("2015-01-01") @calculator = MaternityPaternityPayLeaveCalculator.new @calculator.due_date = @due_date ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/workplace_pension_calculator_test.rb
Ruby
mit
179
main
2,065
require_relative "../../test_helper" module SmartAnswer::Calculators class WorkplacePensionCalculatorTest < ActiveSupport::TestCase context "enrollment data test" do should "(low) return 1 October 2015" do assert_equal "1 October 2015", WorkplacePensionCalculator.enrollment_date(38) end ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/state_pension_topup_calculator_test.rb
Ruby
mit
179
main
8,444
require_relative "../../test_helper" module SmartAnswer::Calculators class StatePensionTopupCalculatorTest < ActiveSupport::TestCase setup do @calculator = StatePensionTopupCalculator.new end context "lump_sum_amount" do should "be 8010 for age of 69" do assert_equal 8010, @calculato...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/holiday_entitlement_test.rb
Ruby
mit
179
main
89,331
require_relative "../../test_helper" module SmartAnswer::Calculators class HolidayEntitlementTest < ActiveSupport::TestCase setup do @calculator = HolidayEntitlement.new end context "calculate entitlement on days worked per week" do context "for a full leave year" do # /days-worked-p...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/paternity_adoption_pay_calculator_test.rb
Ruby
mit
179
main
3,668
require_relative "../../test_helper" module SmartAnswer::Calculators class PaternityAdoptionPayCalculatorTest < ActiveSupport::TestCase context PaternityAdoptionPayCalculator do context "#paternity_deadline" do context "placement date is on or before 5 April 2024" do setup do ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/adoption_pay_calculator_test.rb
Ruby
mit
179
main
11,090
require_relative "../../test_helper" module SmartAnswer::Calculators class AdoptionPayCalculatorTest < ActiveSupport::TestCase context AdoptionPayCalculator do context "test adoption table rate returned for weekly amounts in 2013/14" do setup do match_date = Date.parse("2 January 2014") ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/statutory_sick_pay_calculator_test.rb
Ruby
mit
179
main
52,505
require_relative "../../test_helper" module SmartAnswer module Calculators class StatutorySickPayCalculatorTest < ActiveSupport::TestCase context "period of incapacity for work" do context "qualifying_days" do should "return dates matching working days pattern" do pattern = %w...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/state_pension_through_partner_calculator_test.rb
Ruby
mit
179
main
14,583
require_relative "../../test_helper" module SmartAnswer::Calculators class StatePensionThroughPartnerCalculatorTest < ActiveSupport::TestCase setup do @calculator = StatePensionThroughPartnerCalculator.new end context "#lower_basic_state_pension_rate" do should "return the correct amount for...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/simplified_expenses_checker_calculator_test.rb
Ruby
mit
179
main
35,159
require_relative "../../test_helper" module SmartAnswer::Calculators class SimplifiedExpensesCheckerCalculatorTest < ActiveSupport::TestCase context "list of business expenses" do setup do @calculator = SimplifiedExpensesCheckerCalculator.new end context "when artibary expenses are cho...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/agricultural_holiday_entitlement_calculator_test.rb
Ruby
mit
179
main
2,614
require_relative "../../test_helper" module SmartAnswer::Calculators class AgriculturalHolidayEntitlementCalculatorTest < ActiveSupport::TestCase context AgriculturalHolidayEntitlementCalculator do setup do @calc = AgriculturalHolidayEntitlementCalculator.new end context "holiday_days" ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/commodity_code_calculator_test.rb
Ruby
mit
179
main
2,750
require_relative "../../test_helper" module SmartAnswer::Calculators class CommodityCodeCalculatorTest < ActiveSupport::TestCase context CommodityCodeCalculator do setup do @calculator = CommodityCodeCalculator.new({}) end should "load matrix data from file" do assert_equal Has...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/self_assessment_penalties_test.rb
Ruby
mit
179
main
20,812
require_relative "../../test_helper" module SmartAnswer::Calculators class SelfAssessmentPenaltiesTest < ActiveSupport::TestCase def setup @calculator = SmartAnswer::Calculators::SelfAssessmentPenalties.new( submission_method: "online", filing_date: Date.parse("2024-01-10"), payment...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/redundancy_calculator_test.rb
Ruby
mit
179
main
7,878
require_relative "../../test_helper" module SmartAnswer::Calculators class RedundancyCalculatorTest < ActiveSupport::TestCase context "Money formatting conforms to styleguide" do should "lop off trailing 00s" do assert_equal RedundancyCalculator.format_money(12.00), "12" end should "le...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/personal_allowance_rates_query_test.rb
Ruby
mit
179
main
628
require_relative "../../test_helper" module SmartAnswer::Calculators class MarriedCouplesAllowanceRatesQueryTest < ActiveSupport::TestCase setup do @query = RatesQuery.from_file("personal_allowance") end should "have all required rates defined for the current fiscal year" do %w[personal_allo...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/married_couple_allowance_calculator_test.rb
Ruby
mit
179
main
4,663
require_relative "../../test_helper" module SmartAnswer::Calculators class MarriedCouplesAllowanceCalculatorTest < ActiveSupport::TestCase setup do @income_limit = 27_000 @personal_allowance = 9000 end def calculator(stubbed_values = {}) calculator = MarriedCouplesAllowanceCalculator.n...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/check_building_safety_costs_calculator_test.rb
Ruby
mit
179
main
13,826
require_relative "../../test_helper" module SmartAnswer::Calculators class CheckBuildingSafetyCostsCalculatorTest < ActiveSupport::TestCase setup do @calculator = CheckBuildingSafetyCostsCalculator.new end context "#valid_percentage_owned?" do should "be valid if percentage owned is between ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/plan_adoption_leave_test.rb
Ruby
mit
179
main
3,296
require_relative "../../test_helper" module SmartAnswer::Calculators class PlanAdoptionLeaveTest < ActiveSupport::TestCase context PlanAdoptionLeave do setup do @calculator = PlanAdoptionLeave.new @calculator.match_date = Date.parse("2012-06-25") end context "formatted dates (s...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/student_finance_calculator_test.rb
Ruby
mit
179
main
30,263
require_relative "../../test_helper" module SmartAnswer module Calculators class StudentFinanceCalculatorTest < ActiveSupport::TestCase test "StudentFinanceCalculator is valid and setup properly" do calculator = StudentFinanceCalculator.new( course_start: "2025-2026", household_...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/register_a_death_rates_query_test.rb
Ruby
mit
179
main
742
require_relative "../../test_helper" module SmartAnswer::Calculators class RegisterADeathRatesQueryTest < ActiveSupport::TestCase setup do @rates_query = RatesQuery.from_file("register_a_death") end context "The current and last dates in the file" do setup do @rate_array = [ ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/minimum_wage_calculator_test.rb
Ruby
mit
179
main
23,475
require_relative "../../test_helper" module SmartAnswer::Calculators class MinimumWageCalculatorTest < ActiveSupport::TestCase setup do @calculator = MinimumWageCalculator.new(past_or_current_payment: "current_payment") end context "Initialisation" do should "reject invalid 'past_or_current_...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/uk_visa_calculator_test.rb
Ruby
mit
179
main
33,137
require_relative "../../test_helper" module SmartAnswer module Calculators class UkVisaCalculatorTest < ActiveSupport::TestCase context "#passport_country_in_eea?" do should "return true if passport_country is in list of EEA countries" do calculator = UkVisaCalculator.new calcul...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/state_pension_age_calculator_test.rb
Ruby
mit
179
main
13,130
require_relative "../../test_helper" module SmartAnswer::Calculators class StatePensionAgeCalculatorTest < ActiveSupport::TestCase context "#state_pension_date" do setup do @calculator = StatePensionAgeCalculator.new( gender: "male", dob: Date.parse("28 February 1961"), ) en...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/part_year_profit_tax_credits_calculator_test.rb
Ruby
mit
179
main
11,653
require_relative "../../test_helper" module SmartAnswer module Calculators class PartYearProfitTaxCreditsCalculatorTest < ActiveSupport::TestCase context "validation of stopped trading date" do setup do @calculator = PartYearProfitTaxCreditsCalculator.new @calculator.tax_credits...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/inheritance_tax_interest_calculator_test.rb
Ruby
mit
179
main
1,594
require_relative "../../test_helper" module SmartAnswer::Calculators class InheritanceTaxInterestCalculatorTest < ActiveSupport::TestCase def setup @calculator = SmartAnswer::Calculators::InheritanceTaxInterestCalculator.new( start_date: nil, end_date: nil, inheritance_tax_owed: 10_...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/inherits_someone_dies_without_will_calculator_test.rb
Ruby
mit
179
main
1,113
require "test_helper" module SmartAnswer::Calculators class InheritsSomeoneDiesWithoutWillCalculatorTest < ActiveSupport::TestCase def calculator @calculator ||= InheritsSomeoneDiesWithoutWillCalculator.new end def methods %i[ partner estate_over_250000 children ...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/passport_and_embassy_data_query_test.rb
Ruby
mit
179
main
1,548
require_relative "../../test_helper" module SmartAnswer::Calculators class PassportAndEmbassyDataQueryTest < ActiveSupport::TestCase context PassportAndEmbassyDataQuery do setup do @query = PassportAndEmbassyDataQuery.new end context "find_passport_data" do should "find passpor...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/state_pension_topup_data_query_test.rb
Ruby
mit
179
main
731
require_relative "../../test_helper" module SmartAnswer::Calculators class StatePensionTopupDataQueryTest < ActiveSupport::TestCase setup do StatePensionTopupDataQuery .stubs(:age_and_rates_data) .returns("age_and_rates" => { 100 => 127, 99 => 137 }) @query = StatePensionTopupDataQuer...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/maternity_pay_calculator_test.rb
Ruby
mit
179
main
29,670
require_relative "../../test_helper" require_relative "../../../lib/smart_answer/date_helper" module SmartAnswer::Calculators class MaternityPayCalculatorTest < ActiveSupport::TestCase include SmartAnswer::DateHelper context MaternityPayCalculator do context "due date 4 months in future" do se...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/vat_payment_deadlines_test.rb
Ruby
mit
179
main
7,115
require_relative "../../test_helper" module SmartAnswer::Calculators class VatPaymentDeadlinesTest < ActiveSupport::TestCase setup do WebMock.stub_request(:get, WorkingDays::BANK_HOLIDAYS_URL) .to_return(body: File.open(fixture_file("bank_holidays.json"))) end def new_calculator(date, paym...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/next_steps_for_your_business_calculator_test.rb
Ruby
mit
179
main
9,207
require_relative "../../test_helper" module SmartAnswer::Calculators class NextStepsForYourBusinessCalculatorTest < ActiveSupport::TestCase setup do @calculator = NextStepsForYourBusinessCalculator.new @rules = NextStepsForYourBusinessCalculator::RULES end context "RULES" do context "r...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/married_couples_allowance_rates_query_test.rb
Ruby
mit
179
main
478
require_relative "../../test_helper" module SmartAnswer::Calculators class MarriedCouplesAllowanceRatesQueryTest < ActiveSupport::TestCase setup do @query = RatesQuery.from_file("married_couples_allowance") end should "have all required rates defined for the current fiscal year" do %w[maximu...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/checks_benefits_financial_support_calculator_test.rb
Ruby
mit
179
main
54,077
require_relative "../../test_helper" module SmartAnswer::Calculators class CheckBenefitsFinancialSupportCalculatorTest < ActiveSupport::TestCase context CheckBenefitsFinancialSupportCalculator do setup do @calculator = CheckBenefitsFinancialSupportCalculator.new end context "#benefits_...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/calculators/paternity_pay_calculator_test.rb
Ruby
mit
179
main
8,345
require_relative "../../test_helper" module SmartAnswer::Calculators class PaternityPayCalculatorTest < ActiveSupport::TestCase context PaternityPayCalculator do context "#paydates_and_pay" do setup do due_date = Date.parse("1 May 2014") @calculator = PaternityPayCalculator.new(...
github
alphagov/smart-answers
https://github.com/alphagov/smart-answers
test/unit/tasks/publishing_api_rake_test.rb
Ruby
mit
179
main
6,198
require "test_helper" class PublishingApiRakeTest < ActiveSupport::TestCase context "publshing_api:sync_all" do setup { Rake::Task["publishing_api:sync_all"].reenable } should "sync all flows with ContentItemSyncer" do mock_syncer = mock("syncer") ContentItemSyncer.stubs(:new).returns(mock_synce...