hermod 2.5.3 → 2.7.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/freeagent-gem.yml +58 -0
  3. data/.github/workflows/reviewdog.yml +13 -0
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +23 -2
  6. data/README.md +1 -0
  7. data/hermod.gemspec +7 -6
  8. data/lib/hermod/validators/attributes.rb +1 -1
  9. data/lib/hermod/version.rb +1 -1
  10. data/lib/hermod/xml_section_builder.rb +2 -1
  11. data/spec/hermod/validators/allowed_values_spec.rb +5 -5
  12. data/spec/hermod/validators/attributes_spec.rb +3 -3
  13. data/spec/hermod/validators/base_spec.rb +3 -3
  14. data/spec/hermod/validators/non_negative_spec.rb +5 -5
  15. data/spec/hermod/validators/non_zero_spec.rb +5 -5
  16. data/spec/hermod/validators/range_spec.rb +6 -6
  17. data/spec/hermod/validators/regular_expression_spec.rb +5 -5
  18. data/spec/hermod/validators/type_checker_spec.rb +9 -9
  19. data/spec/hermod/validators/value_presence_spec.rb +3 -3
  20. data/spec/hermod/validators/whole_units_spec.rb +4 -4
  21. data/spec/hermod/xml_section_builder/date_node_spec.rb +3 -3
  22. data/spec/hermod/xml_section_builder/datetime_node_spec.rb +3 -3
  23. data/spec/hermod/xml_section_builder/integer_node_spec.rb +3 -3
  24. data/spec/hermod/xml_section_builder/monetary_node_spec.rb +12 -12
  25. data/spec/hermod/xml_section_builder/parent_node_spec.rb +1 -1
  26. data/spec/hermod/xml_section_builder/string_node_spec.rb +17 -17
  27. data/spec/hermod/xml_section_builder/yes_no_node_spec.rb +2 -2
  28. data/spec/hermod/xml_section_builder/yes_node_spec.rb +2 -2
  29. data/spec/hermod/xml_section_spec.rb +18 -18
  30. data/spec/hermod_spec.rb +1 -1
  31. metadata +24 -34
  32. data/Jenkinsfile +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11655ca6ff6106c5b0c0b16b32b1c4d61b6616203d99f0e52be5c692fe35f0ee
4
- data.tar.gz: a22120a1003ad6d6063776668f52e0f72a341344a739710c59504d1e96384ac2
3
+ metadata.gz: 25ef83e5f96c6113d09daac9754cad30bc9499a02013573ebced458a37eeae68
4
+ data.tar.gz: 57e1414e8e703819410bd3e41e51d7b8d4e6a3ee7f1fefe11cda04cac8c853c0
5
5
  SHA512:
6
- metadata.gz: 645ef183b5ba1dea6704f09aab30dbd25382750778ad912c7876db7f50fda09e87cb3c0e84bc0bbced7b12898af825992bb7050d0f3c7b6d899373383f221aef
7
- data.tar.gz: 74819f28ddc286e232d6fc31908cbad91aeb3f03cb9d4ed4e78b58cec2b8146e8e91d5285bf98305697226638f0763c169c71e1f5392496f5c993d975e7bb8c0
6
+ metadata.gz: f8bc3e4c9e2a63f07899eff3634d4936b5239ef8d1c37ef364c92a740b209cfd2a950230b0dd62c0c8f6b603cf3b8e0b55476ec42799b5ff62faf14d9f6f0a42
7
+ data.tar.gz: ee0d1d9b7d19f9db5b5d54b92ad282af123b166f4870284eb9a991f0f1285d876e4af42ed6241235ae14620b147eda7f5a003fde219c6b8a4f8d1f6ddc0cc55a
@@ -0,0 +1,58 @@
1
+ # Build, test and push gems to the FreeAgent registry.
2
+ # https://github.com/orgs/fac/packages?ecosystem=rubygems
3
+ # https://www.notion.so/freeagent/Internal-gems-5c8098501fcc48e4921be31aa9b4d495
4
+ name: FreeAgent Gem
5
+ on:
6
+ push:
7
+ branches: [master]
8
+ pull_request:
9
+
10
+ jobs:
11
+ # Install the bundle and run the gems test suite.
12
+ tests:
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: ruby/setup-ruby@v1 # .ruby-version
18
+ with:
19
+ bundler-cache: true # bundle install
20
+
21
+ - name: Test
22
+ run: bundle exec rake
23
+
24
+ # Builds that pass testing above, will trigger a build and push of the new
25
+ # gem version to the registry. If the version.rb has not been bumped since
26
+ # the last release, the push will no-op.
27
+ release:
28
+ needs: tests
29
+ runs-on: ubuntu-latest
30
+
31
+ steps:
32
+ - uses: fac/ruby-gem-setup-credentials-action@v2
33
+ with:
34
+ user: ""
35
+ key: rubygems
36
+ token: ${{ secrets.FAC_RUBYGEMS_KEY }}
37
+
38
+ # Build the gem package
39
+ - uses: actions/checkout@v2
40
+ - uses: ruby/setup-ruby@v1
41
+ with:
42
+ bundler-cache: true
43
+ - run: bundle exec rake build
44
+
45
+ # Release production gem version from default branch
46
+ - name: Release
47
+ if: github.ref == 'refs/heads/master'
48
+ uses: fac/ruby-gem-push-action@v2
49
+ with:
50
+ key: rubygems
51
+
52
+ # PR branch builds will release pre-release gems
53
+ - name: Pre-Release
54
+ if: github.ref != 'refs/heads/master'
55
+ uses: fac/ruby-gem-push-action@v2
56
+ with:
57
+ key: rubygems
58
+ pre-release: true
@@ -0,0 +1,13 @@
1
+ name: reviewdog
2
+ on: [pull_request]
3
+ jobs:
4
+ actionlint:
5
+ name: runner / actionlint
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - uses: actions/checkout@v3
9
+ - name: actionlint
10
+ uses: reviewdog/action-actionlint@v1
11
+ with:
12
+ fail_on_error: true
13
+ reporter: github-pr-review
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.3
1
+ 3.0.3
data/CHANGELOG.md CHANGED
@@ -6,8 +6,30 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
+ ### Fixed
10
+ - Added missing require in `Hermod::XmlSectionBuilder`
11
+ - Fixed deprecations in Minitest
9
12
 
10
- ##[2.5.3] - 2019-11-01
13
+ ### Removed
14
+ - Remove unused bad_attributes attr_reader on `Hermod::Validators::Attributes`
15
+
16
+ ### Changed
17
+ - Updated development dependencies
18
+
19
+ ## [2.6.2] - 2022-01-10
20
+ ### Changed
21
+ - Remove the upper limit on the activesupport version
22
+
23
+ ## [2.6.1] - 2020-10-22
24
+ ## Added
25
+ - Changelog updates
26
+
27
+ ## [2.6.0] - 2020-10-22
28
+ ## Added
29
+ - Update libxml-ruby to version ~> 3.2
30
+ - Update ruby-version to 2.7.1
31
+
32
+ ## [2.5.3] - 2019-11-01
11
33
  ### Added
12
34
  - Link wiki to the readme file.
13
35
 
@@ -32,4 +54,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
32
54
 
33
55
  ## [1.0.0] - Unknown
34
56
  There were a number of "releases" that were made prior to this point. However, we have no good details of what was included in which release
35
-
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Hermod
2
2
 
3
+ [![Gem](https://github.com/fac/hermod/actions/workflows/freeagent-gem.yml/badge.svg)](https://github.com/fac/hermod/actions/workflows/freeagent-gem.yml)
3
4
  [![Code
4
5
  Climate](https://codeclimate.com/github/fac/hermod/badges/gpa.svg)](https://codeclimate.com/github/fac/hermod)
5
6
  [![Build Status](https://travis-ci.org/fac/hermod.svg?branch=master)](https://travis-ci.org/fac/hermod)
data/hermod.gemspec CHANGED
@@ -22,16 +22,17 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.required_ruby_version = ">= 2.0.0"
24
24
 
25
- spec.add_runtime_dependency "libxml-ruby", "~> 2.7", ">= 2.7.0"
26
- spec.add_runtime_dependency "activesupport", "> 3.2", "< 7"
25
+ spec.add_runtime_dependency "libxml-ruby", "~> 3.2"
26
+ spec.add_runtime_dependency "activesupport", "> 3.2"
27
27
 
28
28
  spec.add_development_dependency "bundler", "~> 2.0"
29
- spec.add_development_dependency "rake", "~> 11.1"
30
- spec.add_development_dependency "minitest", "~> 5.3"
31
- spec.add_development_dependency "minitest-reporters", "~> 1.0", ">= 1.0.16"
32
- spec.add_development_dependency "nokogiri", "~> 1.5"
29
+ spec.add_development_dependency "rake", "13.0.1"
30
+ spec.add_development_dependency "minitest", "~> 5.15"
31
+ spec.add_development_dependency "minitest-reporters", ">= 1.0.16", "~> 1.5"
32
+ spec.add_development_dependency "nokogiri", "~> 1.13"
33
33
 
34
34
  spec.metadata = {
35
+ "allowed_push_host" => "https://rubygems.org",
35
36
  "bug_tracker_uri" => "https://github.com/fac/hermod/issues",
36
37
  "changelog_uri" => "https://github.com/fac/hermod/blob/master/CHANGELOG.md",
37
38
  "source_code_uri" => "https://github.com/fac/hermod",
@@ -4,7 +4,7 @@ module Hermod
4
4
  module Validators
5
5
  # Checks the attributes are in a list of allowed attributes
6
6
  class Attributes < Base
7
- attr_reader :allowed_attributes, :bad_attributes
7
+ attr_reader :allowed_attributes
8
8
 
9
9
  # Public: Sets up the list of allowed attributes
10
10
  def initialize(allowed_attributes)
@@ -1,3 +1,3 @@
1
1
  module Hermod
2
- VERSION = "2.5.3"
2
+ VERSION = "2.7.0-rc.1"
3
3
  end
@@ -1,7 +1,8 @@
1
- require 'bigdecimal'
2
1
  require 'active_support'
3
2
  require 'active_support/core_ext/string/inflections'
4
3
  require 'active_support/core_ext/object/blank'
4
+ require 'bigdecimal'
5
+ require 'date'
5
6
 
6
7
  require 'hermod/xml_node'
7
8
  require 'hermod/input_mutator'
@@ -8,17 +8,17 @@ module Hermod
8
8
  end
9
9
 
10
10
  it "permits values in the list" do
11
- subject.valid?("Cat", {}).must_equal true
11
+ expect(subject.valid?("Cat", {})).must_equal true
12
12
  end
13
13
 
14
14
  it "allows blank values" do
15
- subject.valid?("", {}).must_equal true
16
- subject.valid?(nil, {}).must_equal true
15
+ expect(subject.valid?("", {})).must_equal true
16
+ expect(subject.valid?(nil, {})).must_equal true
17
17
  end
18
18
 
19
19
  it "raises an error for values not in the list" do
20
- ex = proc { subject.valid?("Albatross", {}) }.must_raise InvalidInputError
21
- ex.message.must_equal "must be one of Antelope, Bear, Cat, Dog, or Elephant, not Albatross"
20
+ ex = expect { subject.valid?("Albatross", {}) }.must_raise InvalidInputError
21
+ expect(ex.message).must_equal "must be one of Antelope, Bear, Cat, Dog, or Elephant, not Albatross"
22
22
  end
23
23
  end
24
24
  end
@@ -8,12 +8,12 @@ module Hermod
8
8
  end
9
9
 
10
10
  it "permits attributes in the list" do
11
- subject.valid?(nil, {species: "Felis catus", genus: "Felis"}).must_equal true
11
+ expect(subject.valid?(nil, {species: "Felis catus", genus: "Felis"})).must_equal true
12
12
  end
13
13
 
14
14
  it "raises an error for attributes not in the list" do
15
- ex = proc { subject.valid?(nil, {phylum: "Chordata"}) }.must_raise InvalidInputError
16
- ex.message.must_equal "has attributes it doesn't accept: phylum"
15
+ ex = expect { subject.valid?(nil, {phylum: "Chordata"}) }.must_raise InvalidInputError
16
+ expect(ex.message).must_equal "has attributes it doesn't accept: phylum"
17
17
  end
18
18
  end
19
19
  end
@@ -8,7 +8,7 @@ module Hermod
8
8
  end
9
9
 
10
10
  it "doesn't implement a test" do
11
- proc { subject.valid?(nil, {}) }.must_raise NotImplementedError
11
+ expect { subject.valid?(nil, {}) }.must_raise NotImplementedError
12
12
  end
13
13
 
14
14
  it "has a default error message" do
@@ -17,8 +17,8 @@ module Hermod
17
17
  false
18
18
  end
19
19
  end
20
- ex = proc { TestValidator.new.valid?(nil, {}) }.must_raise InvalidInputError
21
- ex.message.must_equal "is invalid"
20
+ ex = expect { TestValidator.new.valid?(nil, {}) }.must_raise InvalidInputError
21
+ expect(ex.message).must_equal "is invalid"
22
22
  end
23
23
  end
24
24
  end
@@ -8,20 +8,20 @@ module Hermod
8
8
  end
9
9
 
10
10
  it "allows positive values" do
11
- subject.valid?(1, {}).must_equal true
11
+ expect(subject.valid?(1, {})).must_equal true
12
12
  end
13
13
 
14
14
  it "allows zero values" do
15
- subject.valid?(0, {}).must_equal true
15
+ expect(subject.valid?(0, {})).must_equal true
16
16
  end
17
17
 
18
18
  it "allows blank values" do
19
- subject.valid?(nil, {}).must_equal true
19
+ expect(subject.valid?(nil, {})).must_equal true
20
20
  end
21
21
 
22
22
  it "raises an error for negative values" do
23
- ex = proc { subject.valid?(-1, {}) }.must_raise InvalidInputError
24
- ex.message.must_equal "cannot be negative"
23
+ ex = expect { subject.valid?(-1, {}) }.must_raise InvalidInputError
24
+ expect(ex.message).must_equal "cannot be negative"
25
25
  end
26
26
  end
27
27
  end
@@ -8,20 +8,20 @@ module Hermod
8
8
  end
9
9
 
10
10
  it "allows positive values" do
11
- subject.valid?(1, {}).must_equal true
11
+ expect(subject.valid?(1, {})).must_equal true
12
12
  end
13
13
 
14
14
  it "allows negative values" do
15
- subject.valid?(-1, {}).must_equal true
15
+ expect(subject.valid?(-1, {})).must_equal true
16
16
  end
17
17
 
18
18
  it "allows blank values" do
19
- subject.valid?(nil, {}).must_equal true
19
+ expect(subject.valid?(nil, {})).must_equal true
20
20
  end
21
21
 
22
22
  it "raises an error for zero values" do
23
- ex = proc { subject.valid?(0, {}) }.must_raise InvalidInputError
24
- ex.message.must_equal "cannot be zero"
23
+ ex = expect { subject.valid?(0, {}) }.must_raise InvalidInputError
24
+ expect(ex.message).must_equal "cannot be zero"
25
25
  end
26
26
  end
27
27
  end
@@ -8,21 +8,21 @@ module Hermod
8
8
  end
9
9
 
10
10
  it "allows values in the range" do
11
- subject.valid?(1, {}).must_equal true
12
- subject.valid?(7, {}).must_equal true
11
+ expect(subject.valid?(1, {})).must_equal true
12
+ expect(subject.valid?(7, {})).must_equal true
13
13
  end
14
14
 
15
15
  it "allows blank values" do
16
- subject.valid?(nil, {}).must_equal true
16
+ expect(subject.valid?(nil, {})).must_equal true
17
17
  end
18
18
 
19
19
  it "raises an error for values outwith the range" do
20
- ex = proc { subject.valid?(0, {}) }.must_raise InvalidInputError
21
- ex.message.must_equal "must be between 1 and 7"
20
+ ex = expect { subject.valid?(0, {}) }.must_raise InvalidInputError
21
+ expect(ex.message).must_equal "must be between 1 and 7"
22
22
  end
23
23
 
24
24
  it "can also take a min and max as arguments" do
25
- Range.new(1, 7).valid?(3, {}).must_equal true
25
+ expect(Range.new(1, 7).valid?(3, {})).must_equal true
26
26
  end
27
27
  end
28
28
  end
@@ -8,17 +8,17 @@ module Hermod
8
8
  end
9
9
 
10
10
  it "allows values that match the pattern" do
11
- subject.valid?("AB123456C", {}).must_equal true
11
+ expect(subject.valid?("AB123456C", {})).must_equal true
12
12
  end
13
13
 
14
14
  it "allows blank values" do
15
- subject.valid?("", {}).must_equal true
16
- subject.valid?(nil, {}).must_equal true
15
+ expect(subject.valid?("", {})).must_equal true
16
+ expect(subject.valid?(nil, {})).must_equal true
17
17
  end
18
18
 
19
19
  it "raises an error for values that don't match the pattern" do
20
- ex = proc { subject.valid?("fish", {}) }.must_raise InvalidInputError
21
- ex.message.must_equal "\"fish\" does not match /\\A[A-Z]{2} [0-9]{6} [A-D]\\z/x"
20
+ ex = expect { subject.valid?("fish", {}) }.must_raise InvalidInputError
21
+ expect(ex.message).must_equal "\"fish\" does not match /\\A[A-Z]{2} [0-9]{6} [A-D]\\z/x"
22
22
  end
23
23
  end
24
24
  end
@@ -5,27 +5,27 @@ module Hermod
5
5
  describe TypeChecker do
6
6
  it "uses a default block that checks the value is an instance of the given class" do
7
7
  checker = TypeChecker.new(Integer)
8
- checker.valid?(1, {}).must_equal true
9
- proc { checker.valid?(1.0, {}) }.must_raise InvalidInputError
8
+ expect(checker.valid?(1, {})).must_equal true
9
+ expect { checker.valid?(1.0, {}) }.must_raise InvalidInputError
10
10
  end
11
11
 
12
12
  it "allows you to give a block to be more discerning" do
13
13
  checker = TypeChecker.new(Integer) { |val| val > 0 }
14
- checker.valid?(5, {}).must_equal true
15
- proc { checker.valid?(-2, {}) }.must_raise InvalidInputError
14
+ expect(checker.valid?(5, {})).must_equal true
15
+ expect { checker.valid?(-2, {}) }.must_raise InvalidInputError
16
16
  end
17
17
 
18
18
  it "ignores blank values" do
19
19
  checker = TypeChecker.new(Integer)
20
- checker.valid?(nil, {}).must_equal true
20
+ expect(checker.valid?(nil, {})).must_equal true
21
21
  end
22
22
 
23
23
  it "gives the correct message" do
24
- ex = proc { TypeChecker.new(Integer).valid?(1.0, {}) }.must_raise InvalidInputError
25
- ex.message.must_equal "must be an integer"
24
+ ex = expect { TypeChecker.new(Integer).valid?(1.0, {}) }.must_raise InvalidInputError
25
+ expect(ex.message).must_equal "must be an integer"
26
26
 
27
- ex = proc { TypeChecker.new(Float).valid?(1, {}) }.must_raise InvalidInputError
28
- ex.message.must_equal "must be a float"
27
+ ex = expect { TypeChecker.new(Float).valid?(1, {}) }.must_raise InvalidInputError
28
+ expect(ex.message).must_equal "must be a float"
29
29
  end
30
30
  end
31
31
  end
@@ -8,12 +8,12 @@ module Hermod
8
8
  end
9
9
 
10
10
  it "allows values that are present" do
11
- subject.valid?(1, {}).must_equal true
11
+ expect(subject.valid?(1, {})).must_equal true
12
12
  end
13
13
 
14
14
  it "raises an error for missing values" do
15
- ex = proc { subject.valid?(nil, {}) }.must_raise InvalidInputError
16
- ex.message.must_equal "isn't optional but no value was provided"
15
+ ex = expect { subject.valid?(nil, {}) }.must_raise InvalidInputError
16
+ expect(ex.message).must_equal "isn't optional but no value was provided"
17
17
  end
18
18
  end
19
19
  end
@@ -8,16 +8,16 @@ module Hermod
8
8
  end
9
9
 
10
10
  it "allows values that are in whole units" do
11
- subject.valid?(1.0, {}).must_equal true
11
+ expect(subject.valid?(1.0, {})).must_equal true
12
12
  end
13
13
 
14
14
  it "allows blank values" do
15
- subject.valid?(nil, {}).must_equal true
15
+ expect(subject.valid?(nil, {})).must_equal true
16
16
  end
17
17
 
18
18
  it "raises an error for values with a fractional componant" do
19
- ex = proc { subject.valid?(3.1415, {}) }.must_raise InvalidInputError
20
- ex.message.must_equal "must be in whole units"
19
+ ex = expect { subject.valid?(3.1415, {}) }.must_raise InvalidInputError
20
+ expect(ex.message).must_equal "must be in whole units"
21
21
  end
22
22
  end
23
23
  end
@@ -16,16 +16,16 @@ module Hermod
16
16
  end
17
17
 
18
18
  it "should format the date with the given date string" do
19
- value_of_node("DateOfBirth").must_equal "1988-08-13"
19
+ expect(value_of_node("DateOfBirth")).must_equal "1988-08-13"
20
20
  end
21
21
 
22
22
  it "should raise an error if given something that isn't a date" do
23
- proc { subject.anniversary "yesterday" }.must_raise InvalidInputError
23
+ expect { subject.anniversary "yesterday" }.must_raise InvalidInputError
24
24
  end
25
25
 
26
26
  it "should ignore blank dates if the date is optional" do
27
27
  subject.anniversary nil
28
- nodes("Anniversary").must_be_empty
28
+ expect(nodes("Anniversary")).must_be_empty
29
29
  end
30
30
  end
31
31
  end
@@ -16,16 +16,16 @@ module Hermod
16
16
  end
17
17
 
18
18
  it "should format the datetime with the given format string" do
19
- value_of_node("Published").must_equal "2015-03-14 12:30:56"
19
+ expect(value_of_node("Published")).must_equal "2015-03-14 12:30:56"
20
20
  end
21
21
 
22
22
  it "should raise an error if given something that isn't a date" do
23
- proc { subject.redacted "yesterday" }.must_raise InvalidInputError
23
+ expect { subject.redacted "yesterday" }.must_raise InvalidInputError
24
24
  end
25
25
 
26
26
  it "should ignore blank dates if the date is optional" do
27
27
  subject.redacted nil
28
- nodes("Redacted").must_be_empty
28
+ expect(nodes("Redacted")).must_be_empty
29
29
  end
30
30
  end
31
31
  end
@@ -14,15 +14,15 @@ module Hermod
14
14
 
15
15
  it "should accept a valid number" do
16
16
  subject.day_of_the_week 7
17
- value_of_node("DayOfTheWeek").must_equal "7"
17
+ expect(value_of_node("DayOfTheWeek")).must_equal "7"
18
18
  end
19
19
 
20
20
  it "should raise an error if the number is above the maximum" do
21
- proc { subject.day_of_the_week 8 }.must_raise InvalidInputError
21
+ expect { subject.day_of_the_week 8 }.must_raise InvalidInputError
22
22
  end
23
23
 
24
24
  it "should raise an error if the number is below the minimum" do
25
- proc { subject.day_of_the_week 0 }.must_raise InvalidInputError
25
+ expect { subject.day_of_the_week 0 }.must_raise InvalidInputError
26
26
  end
27
27
  end
28
28
  end
@@ -20,44 +20,44 @@ module Hermod
20
20
  end
21
21
 
22
22
  it "should format values with the provided format string" do
23
- value_of_node("Pay").must_equal "123.45"
23
+ expect(value_of_node("Pay")).must_equal "123.45"
24
24
  end
25
25
 
26
26
  it "should not include optional nodes if they're zero" do
27
- number_of_nodes("Tax").must_equal 0
27
+ expect(number_of_nodes("Tax")).must_equal 0
28
28
  end
29
29
 
30
30
  it "should use xml_name as the node name if provided" do
31
31
  subject.ni 100
32
- number_of_nodes("NI").must_equal 1
32
+ expect(number_of_nodes("NI")).must_equal 1
33
33
  end
34
34
 
35
35
  it "should raise an error if given a negative number for a field that cannot be negative" do
36
- ex = proc { subject.ni -100 }.must_raise InvalidInputError
37
- ex.message.must_equal "ni cannot be negative"
36
+ ex = expect { subject.ni(-100) }.must_raise InvalidInputError
37
+ expect(ex.message).must_equal "ni cannot be negative"
38
38
  end
39
39
 
40
40
  it "should allow negative numbers for fields by default" do
41
41
  subject.pension(-100)
42
- value_of_node("Pension").must_equal "-100.00"
42
+ expect(value_of_node("Pension")).must_equal "-100.00"
43
43
  end
44
44
 
45
45
  it "should not allow decimal values for whole unit nodes" do
46
- ex = proc { subject.pension BigDecimal("12.34") }.must_raise InvalidInputError
47
- ex.message.must_equal "pension must be in whole units"
46
+ ex = expect { subject.pension BigDecimal("12.34") }.must_raise InvalidInputError
47
+ expect(ex.message).must_equal "pension must be in whole units"
48
48
  end
49
49
 
50
50
  it "should not allow zero for nodes that disallow it" do
51
- ex = proc { subject.student_loan 0 }.must_raise Hermod::InvalidInputError
52
- ex.message.must_equal "student_loan cannot be zero"
51
+ ex = expect { subject.student_loan 0 }.must_raise Hermod::InvalidInputError
52
+ expect(ex.message).must_equal "student_loan cannot be zero"
53
53
  end
54
54
 
55
55
  it "should treat blank nodes as zero nodes" do
56
56
  subject.ni nil
57
- value_of_node("NI").must_equal "0.00"
57
+ expect(value_of_node("NI")).must_equal "0.00"
58
58
 
59
59
  subject.tax nil
60
- nodes("Tax").must_be_empty
60
+ expect(nodes("Tax")).must_be_empty
61
61
  end
62
62
  end
63
63
  end
@@ -21,7 +21,7 @@ module Hermod
21
21
 
22
22
  it "should correctly wrap the inner XML" do
23
23
  expected = "<ParentXml>\n <InnerXml>\n <Inside>layered like an onion</Inside>\n </InnerXml>\n</ParentXml>"
24
- subject.to_xml.to_s.must_equal expected
24
+ expect(subject.to_xml.to_s).must_equal expected
25
25
  end
26
26
  end
27
27
  end
@@ -33,43 +33,43 @@ module Hermod
33
33
  end
34
34
 
35
35
  it "should set node contents correctly" do
36
- value_of_node("Greeting").must_equal "Hello"
36
+ expect(value_of_node("Greeting")).must_equal "Hello"
37
37
  end
38
38
 
39
39
  it "should allow values that pass the regex validation" do
40
40
  subject.title "Sir"
41
- value_of_node("Title").must_equal "Sir"
41
+ expect(value_of_node("Title")).must_equal "Sir"
42
42
  end
43
43
 
44
44
  it "should raise an error when the regex validation fails" do
45
- ex = proc { subject.title "Laird" }.must_raise InvalidInputError
46
- ex.message.must_equal %(title "Laird" does not match /\\ASir|Dame\\z/)
45
+ ex = expect { subject.title "Laird" }.must_raise InvalidInputError
46
+ expect(ex.message).must_equal %(title "Laird" does not match /\\ASir|Dame\\z/)
47
47
  end
48
48
 
49
49
  it "should require all non-optional nodes to have content" do
50
- ex = proc { subject.required "" }.must_raise InvalidInputError
51
- ex.message.must_equal "required isn't optional but no value was provided"
50
+ ex = expect { subject.required "" }.must_raise InvalidInputError
51
+ expect(ex.message).must_equal "required isn't optional but no value was provided"
52
52
  end
53
53
 
54
54
  it "should apply changes to the inputs if a input_mutator is provided" do
55
55
  subject.gender "Male"
56
- value_of_node("Gender").must_equal "M"
56
+ expect(value_of_node("Gender")).must_equal "M"
57
57
  end
58
58
 
59
59
  it "should allow input_mutators to access nodes the instance" do
60
60
  subject.mood "Hangry"
61
61
  subject.status "Eating cookies"
62
- value_of_node("Status").must_equal "Eating cookies furiously"
62
+ expect(value_of_node("Status")).must_equal "Eating cookies furiously"
63
63
  end
64
64
 
65
65
  it "should restrict values to those in the list of allowed values if such a list is provided" do
66
66
  subject.mood "Hangry"
67
- value_of_node("Mood").must_equal "Hangry"
67
+ expect(value_of_node("Mood")).must_equal "Hangry"
68
68
  end
69
69
 
70
70
  it "should raise an error if the value is not in the list of allowed values" do
71
- ex = proc { subject.mood "Jubilant" }.must_raise InvalidInputError
72
- ex.message.must_equal "mood must be one of Happy, Sad, or Hangry, not Jubilant"
71
+ ex = expect { subject.mood "Jubilant" }.must_raise InvalidInputError
72
+ expect(ex.message).must_equal "mood must be one of Happy, Sad, or Hangry, not Jubilant"
73
73
  end
74
74
 
75
75
  it "should be thread safe for validation" do
@@ -81,23 +81,23 @@ module Hermod
81
81
  subject1.mood "Hangry"
82
82
  end
83
83
 
84
- ex = proc { subject.mood "Jubilant" }.must_raise InvalidInputError
85
- ex.message.must_equal "mood must be one of Happy, Sad, or Hangry, not Jubilant"
84
+ ex = expect { subject.mood "Jubilant" }.must_raise InvalidInputError
85
+ expect(ex.message).must_equal "mood must be one of Happy, Sad, or Hangry, not Jubilant"
86
86
  end
87
87
 
88
88
  it "should use the given keys for attributes" do
89
89
  subject.title "Sir", masculine: "no"
90
- attributes_for_node("Title").keys.first.must_equal "Male"
91
- attributes_for_node("Title")["Male"].value.must_equal "no"
90
+ expect(attributes_for_node("Title").keys.first).must_equal "Male"
91
+ expect(attributes_for_node("Title")["Male"].value).must_equal "no"
92
92
  end
93
93
 
94
94
  it "should raise an error if given an attribute that isn't expected" do
95
- proc { subject.title "Sir", knight: "yes" }.must_raise InvalidInputError
95
+ expect { subject.title "Sir", knight: "yes" }.must_raise InvalidInputError
96
96
  end
97
97
 
98
98
  it "should not include empty, optional nodes" do
99
99
  subject.name ""
100
- nodes("Name").must_be_empty
100
+ expect(nodes("Name")).must_be_empty
101
101
  end
102
102
  end
103
103
  end
@@ -16,7 +16,7 @@ module Hermod
16
16
  end
17
17
 
18
18
  it "should include the node with yes as the contents" do
19
- value_of_node("Awesome").must_equal "yes"
19
+ expect(value_of_node("Awesome")).must_equal "yes"
20
20
  end
21
21
  end
22
22
 
@@ -28,7 +28,7 @@ module Hermod
28
28
  end
29
29
 
30
30
  it "should include the node with no as the contents" do
31
- value_of_node("Awesome").must_equal "no"
31
+ expect(value_of_node("Awesome")).must_equal "no"
32
32
  end
33
33
  end
34
34
  end
@@ -16,7 +16,7 @@ module Hermod
16
16
  end
17
17
 
18
18
  it "should include the node with yes as the contents" do
19
- value_of_node("Awesome").must_equal "yes"
19
+ expect(value_of_node("Awesome")).must_equal "yes"
20
20
  end
21
21
  end
22
22
 
@@ -28,7 +28,7 @@ module Hermod
28
28
  end
29
29
 
30
30
  it "should not include the node" do
31
- number_of_nodes("Awesome").must_equal 0
31
+ expect(number_of_nodes("Awesome")).must_equal 0
32
32
  end
33
33
  end
34
34
  end
@@ -21,7 +21,7 @@ module Hermod
21
21
  end
22
22
 
23
23
  it "should use the class name as the XML node name" do
24
- subject.to_xml.name.must_equal "UnnamedXML"
24
+ expect(subject.to_xml.name).must_equal "UnnamedXML"
25
25
  end
26
26
  end
27
27
 
@@ -31,7 +31,7 @@ module Hermod
31
31
  end
32
32
 
33
33
  it "should use the class name as the XML node name" do
34
- subject.to_xml.name.must_equal "Testing"
34
+ expect(subject.to_xml.name).must_equal "Testing"
35
35
  end
36
36
  end
37
37
 
@@ -44,11 +44,11 @@ module Hermod
44
44
  end
45
45
 
46
46
  it "formats dates in yyyy-mm-dd form" do
47
- value_of_node("Birthday").must_equal("1988-08-13")
47
+ expect(value_of_node("Birthday")).must_equal("1988-08-13")
48
48
  end
49
49
 
50
50
  it "formats money to two decimal places" do
51
- value_of_node("Allowance").must_equal("20.00")
51
+ expect(value_of_node("Allowance")).must_equal("20.00")
52
52
  end
53
53
  end
54
54
 
@@ -63,32 +63,32 @@ module Hermod
63
63
  end
64
64
 
65
65
  it "should order nodes by the order they were defined when the class was built" do
66
- node_by_index(0).name.must_equal "First"
67
- node_by_index(0).content.must_equal "alpha"
66
+ expect(node_by_index(0).name).must_equal "First"
67
+ expect(node_by_index(0).content).must_equal "alpha"
68
68
 
69
- node_by_index(1).name.must_equal "Repeated"
70
- node_by_index(1).content.must_equal "beta"
69
+ expect(node_by_index(1).name).must_equal "Repeated"
70
+ expect(node_by_index(1).content).must_equal "beta"
71
71
 
72
- node_by_index(-1).name.must_equal "Last"
73
- node_by_index(-1).content.must_equal "epsilon"
72
+ expect(node_by_index(-1).name).must_equal "Last"
73
+ expect(node_by_index(-1).content).must_equal "epsilon"
74
74
  end
75
75
 
76
76
  it "should order nodes called multiple times in the order they were called" do
77
- node_by_index(1).name.must_equal "Repeated"
78
- node_by_index(1).content.must_equal "beta"
77
+ expect(node_by_index(1).name).must_equal "Repeated"
78
+ expect(node_by_index(1).content).must_equal "beta"
79
79
 
80
- node_by_index(2).name.must_equal "Repeated"
81
- node_by_index(2).content.must_equal "gamma"
80
+ expect(node_by_index(2).name).must_equal "Repeated"
81
+ expect(node_by_index(2).content).must_equal "gamma"
82
82
  end
83
83
 
84
84
  it "should order nodes at XML generation time, not at call time" do
85
85
  subject.repeated "delta"
86
86
 
87
- node_by_index(-2).name.must_equal "Repeated"
88
- node_by_index(-2).content.must_equal "delta"
87
+ expect(node_by_index(-2).name).must_equal "Repeated"
88
+ expect(node_by_index(-2).content).must_equal "delta"
89
89
 
90
- node_by_index(-1).name.must_equal "Last"
91
- node_by_index(-1).content.must_equal "epsilon"
90
+ expect(node_by_index(-1).name).must_equal "Last"
91
+ expect(node_by_index(-1).content).must_equal "epsilon"
92
92
  end
93
93
  end
94
94
  end
data/spec/hermod_spec.rb CHANGED
@@ -2,6 +2,6 @@ require 'minitest_helper'
2
2
 
3
3
  describe Hermod do
4
4
  it "should have a version number" do
5
- Hermod::VERSION.wont_be_nil
5
+ expect(Hermod::VERSION).wont_be_nil
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hermod
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.3
4
+ version: 2.7.0.pre.rc.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Mills
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-01 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libxml-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 2.7.0
20
17
  - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '2.7'
19
+ version: '3.2'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 2.7.0
30
24
  - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '2.7'
26
+ version: '3.2'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: activesupport
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -37,9 +31,6 @@ dependencies:
37
31
  - - ">"
38
32
  - !ruby/object:Gem::Version
39
33
  version: '3.2'
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: '7'
43
34
  type: :runtime
44
35
  prerelease: false
45
36
  version_requirements: !ruby/object:Gem::Requirement
@@ -47,9 +38,6 @@ dependencies:
47
38
  - - ">"
48
39
  - !ruby/object:Gem::Version
49
40
  version: '3.2'
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: '7'
53
41
  - !ruby/object:Gem::Dependency
54
42
  name: bundler
55
43
  requirement: !ruby/object:Gem::Requirement
@@ -68,64 +56,64 @@ dependencies:
68
56
  name: rake
69
57
  requirement: !ruby/object:Gem::Requirement
70
58
  requirements:
71
- - - "~>"
59
+ - - '='
72
60
  - !ruby/object:Gem::Version
73
- version: '11.1'
61
+ version: 13.0.1
74
62
  type: :development
75
63
  prerelease: false
76
64
  version_requirements: !ruby/object:Gem::Requirement
77
65
  requirements:
78
- - - "~>"
66
+ - - '='
79
67
  - !ruby/object:Gem::Version
80
- version: '11.1'
68
+ version: 13.0.1
81
69
  - !ruby/object:Gem::Dependency
82
70
  name: minitest
83
71
  requirement: !ruby/object:Gem::Requirement
84
72
  requirements:
85
73
  - - "~>"
86
74
  - !ruby/object:Gem::Version
87
- version: '5.3'
75
+ version: '5.15'
88
76
  type: :development
89
77
  prerelease: false
90
78
  version_requirements: !ruby/object:Gem::Requirement
91
79
  requirements:
92
80
  - - "~>"
93
81
  - !ruby/object:Gem::Version
94
- version: '5.3'
82
+ version: '5.15'
95
83
  - !ruby/object:Gem::Dependency
96
84
  name: minitest-reporters
97
85
  requirement: !ruby/object:Gem::Requirement
98
86
  requirements:
99
- - - "~>"
100
- - !ruby/object:Gem::Version
101
- version: '1.0'
102
87
  - - ">="
103
88
  - !ruby/object:Gem::Version
104
89
  version: 1.0.16
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '1.5'
105
93
  type: :development
106
94
  prerelease: false
107
95
  version_requirements: !ruby/object:Gem::Requirement
108
96
  requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: '1.0'
112
97
  - - ">="
113
98
  - !ruby/object:Gem::Version
114
99
  version: 1.0.16
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.5'
115
103
  - !ruby/object:Gem::Dependency
116
104
  name: nokogiri
117
105
  requirement: !ruby/object:Gem::Requirement
118
106
  requirements:
119
107
  - - "~>"
120
108
  - !ruby/object:Gem::Version
121
- version: '1.5'
109
+ version: '1.13'
122
110
  type: :development
123
111
  prerelease: false
124
112
  version_requirements: !ruby/object:Gem::Requirement
125
113
  requirements:
126
114
  - - "~>"
127
115
  - !ruby/object:Gem::Version
128
- version: '1.5'
116
+ version: '1.13'
129
117
  description: |-
130
118
  A Ruby library for talking to the HMRC Government Gateway.
131
119
  This provides a builder for creating classes that can generate the XML needed complete with type information and
@@ -136,13 +124,14 @@ executables: []
136
124
  extensions: []
137
125
  extra_rdoc_files: []
138
126
  files:
127
+ - ".github/workflows/freeagent-gem.yml"
128
+ - ".github/workflows/reviewdog.yml"
139
129
  - ".gitignore"
140
130
  - ".ruby-version"
141
131
  - ".travis.yml"
142
132
  - CHANGELOG.md
143
133
  - Gemfile
144
134
  - Guardfile
145
- - Jenkinsfile
146
135
  - LICENSE
147
136
  - README.md
148
137
  - Rakefile
@@ -194,6 +183,7 @@ homepage: https://github.com/fac/hermod
194
183
  licenses:
195
184
  - Apache License, Version 2.0
196
185
  metadata:
186
+ allowed_push_host: https://rubygems.org
197
187
  bug_tracker_uri: https://github.com/fac/hermod/issues
198
188
  changelog_uri: https://github.com/fac/hermod/blob/master/CHANGELOG.md
199
189
  source_code_uri: https://github.com/fac/hermod
@@ -209,11 +199,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
199
  version: 2.0.0
210
200
  required_rubygems_version: !ruby/object:Gem::Requirement
211
201
  requirements:
212
- - - ">="
202
+ - - ">"
213
203
  - !ruby/object:Gem::Version
214
- version: '0'
204
+ version: 1.3.1
215
205
  requirements: []
216
- rubygems_version: 3.0.3
206
+ rubygems_version: 3.2.32
217
207
  signing_key:
218
208
  specification_version: 4
219
209
  summary: A Ruby library for talking to the HMRC Government Gateway.
data/Jenkinsfile DELETED
@@ -1,11 +0,0 @@
1
- #!groovy
2
-
3
- @Library('freeagent') _
4
-
5
- freeagentGem(
6
- node: 'smartos',
7
- slack: [channel: '#tax-eng-ci'],
8
- remote: "https://rubygems.org",
9
- key: "rubygems",
10
- pushTag: true,
11
- forcePush: true )