diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ca716f..91e7836 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,8 +31,7 @@ jobs: strategy: fail-fast: false matrix: - # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' - ruby: ['3.0', 3.1, 3.2] + ruby: [3.1, 3.2, 3.3] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.ruby-version b/.ruby-version index eca690e..0aec50e 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.0.5 +3.1.4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 51415ae..197eeca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Unreleased + +* Drop support for Ruby 3.0. The minimum required Ruby version is now 3.1.4. +* Add support for Ruby 3.3. + # 4.7.0 * Update `json-schema` dependency. diff --git a/govuk_schemas.gemspec b/govuk_schemas.gemspec index d42546d..a514815 100644 --- a/govuk_schemas.gemspec +++ b/govuk_schemas.gemspec @@ -27,5 +27,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rspec", "~> 3.4" spec.add_development_dependency "rubocop-govuk", "4.14.0" - spec.required_ruby_version = ">= 3.0" + spec.required_ruby_version = ">= 3.1.4" end diff --git a/lib/govuk_schemas/random_example.rb b/lib/govuk_schemas/random_example.rb index 9791ccc..1131217 100644 --- a/lib/govuk_schemas/random_example.rb +++ b/lib/govuk_schemas/random_example.rb @@ -33,7 +33,7 @@ class RandomExample # @return [GovukSchemas::RandomExample] def initialize(schema:, seed: nil) @schema = schema - @random_generator = RandomSchemaGenerator.new(schema: schema, seed: seed) + @random_generator = RandomSchemaGenerator.new(schema:, seed:) end # Returns a new `GovukSchemas::RandomExample` object. @@ -58,7 +58,7 @@ def initialize(schema:, seed: nil) # the new payload. The new payload is then validated. (optional) def self.for_schema(schema_key_value, &block) schema = GovukSchemas::Schema.find(schema_key_value) - GovukSchemas::RandomExample.new(schema: schema).payload(&block) + GovukSchemas::RandomExample.new(schema:).payload(&block) end # Return a content item merged with a hash and with the excluded fields removed. diff --git a/lib/govuk_schemas/schema.rb b/lib/govuk_schemas/schema.rb index fe7109d..22ccd62 100644 --- a/lib/govuk_schemas/schema.rb +++ b/lib/govuk_schemas/schema.rb @@ -31,7 +31,7 @@ def self.all(schema_type: "*") # @param schema_type [String] The type: frontend, publisher, notification or links # @return [Hash] a JSON schema as a hash def self.random_schema(schema_type:) - all(schema_type: schema_type).values.sample + all(schema_type:).values.sample end # Return all schema names diff --git a/spec/lib/random_example_spec.rb b/spec/lib/random_example_spec.rb index d636b8f..48e4316 100644 --- a/spec/lib/random_example_spec.rb +++ b/spec/lib/random_example_spec.rb @@ -21,21 +21,21 @@ GovukSchemas::Schema.all.each do |file_path, schema| it "generates valid content for schema #{file_path}" do # This will raise an informative error if an invalid schema is generated. - GovukSchemas::RandomExample.new(schema: schema).payload + GovukSchemas::RandomExample.new(schema:).payload end end it "returns the same output if a seed is detected" do schema = GovukSchemas::Schema.random_schema(schema_type: "frontend") - first_payload = GovukSchemas::RandomExample.new(schema: schema, seed: 777).payload - second_payload = GovukSchemas::RandomExample.new(schema: schema, seed: 777).payload + first_payload = GovukSchemas::RandomExample.new(schema:, seed: 777).payload + second_payload = GovukSchemas::RandomExample.new(schema:, seed: 777).payload expect(first_payload).to eql(second_payload) end it "can customise the payload" do schema = GovukSchemas::Schema.random_schema(schema_type: "frontend") - example = GovukSchemas::RandomExample.new(schema: schema).payload do |hash| + example = GovukSchemas::RandomExample.new(schema:).payload do |hash| hash.merge("base_path" => "/some-base-path") end @@ -46,7 +46,7 @@ schema = GovukSchemas::Schema.random_schema(schema_type: "frontend") expect { - GovukSchemas::RandomExample.new(schema: schema).payload do |hash| + GovukSchemas::RandomExample.new(schema:).payload do |hash| hash["base_path"] = "/some-base-path" end }.to raise_error(GovukSchemas::InvalidContentGenerated) @@ -56,7 +56,7 @@ schema = GovukSchemas::Schema.random_schema(schema_type: "frontend") expect { - GovukSchemas::RandomExample.new(schema: schema).payload do |hash| + GovukSchemas::RandomExample.new(schema:).payload do |hash| hash.merge("base_path" => nil) end }.to raise_error(GovukSchemas::InvalidContentGenerated) diff --git a/spec/lib/random_schema_generator_spec.rb b/spec/lib/random_schema_generator_spec.rb index f49d373..52e9809 100644 --- a/spec/lib/random_schema_generator_spec.rb +++ b/spec/lib/random_schema_generator_spec.rb @@ -12,8 +12,8 @@ }, }, } - generator1 = GovukSchemas::RandomSchemaGenerator.new(schema: schema) - generator2 = GovukSchemas::RandomSchemaGenerator.new(schema: schema) + generator1 = GovukSchemas::RandomSchemaGenerator.new(schema:) + generator2 = GovukSchemas::RandomSchemaGenerator.new(schema:) expect(generator1.payload).not_to eq(generator2.payload) end @@ -31,7 +31,7 @@ }, } - generator = GovukSchemas::RandomSchemaGenerator.new(schema: schema) + generator = GovukSchemas::RandomSchemaGenerator.new(schema:) expect(generator.payload.keys).to include("my_field") end @@ -52,7 +52,7 @@ }, } - generator = GovukSchemas::RandomSchemaGenerator.new(schema: schema) + generator = GovukSchemas::RandomSchemaGenerator.new(schema:) expect(generator.payload.keys).to include("my_field") end @@ -77,7 +77,7 @@ }, } - generator = GovukSchemas::RandomSchemaGenerator.new(schema: schema) + generator = GovukSchemas::RandomSchemaGenerator.new(schema:) expect(generator.payload.keys).to include("my_field") end @@ -105,7 +105,7 @@ ], } - generator = GovukSchemas::RandomSchemaGenerator.new(schema: schema) + generator = GovukSchemas::RandomSchemaGenerator.new(schema:) expect(generator.payload["my_enum"]).to eq("a") expect(generator.payload.keys).to include("my_field") @@ -121,7 +121,7 @@ "maxItems" => 5, } - generator = GovukSchemas::RandomSchemaGenerator.new(schema: schema) + generator = GovukSchemas::RandomSchemaGenerator.new(schema:) # These stubs are to ensure determinism in the random array value # generation. @@ -143,7 +143,7 @@ "maxItems" => 3, } - generator = GovukSchemas::RandomSchemaGenerator.new(schema: schema) + generator = GovukSchemas::RandomSchemaGenerator.new(schema:) expect { generator.payload } .to raise_error "Failed to create a unique array item after 300 attempts"