hermod 2.6.2 → 2.7.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/reviewdog.yml +2 -2
- data/CHANGELOG.md +14 -4
- data/hermod.gemspec +3 -3
- data/lib/hermod/validators/attributes.rb +1 -1
- data/lib/hermod/version.rb +1 -1
- data/lib/hermod/xml_section_builder.rb +2 -1
- data/spec/hermod/validators/allowed_values_spec.rb +5 -5
- data/spec/hermod/validators/attributes_spec.rb +3 -3
- data/spec/hermod/validators/base_spec.rb +3 -3
- data/spec/hermod/validators/non_negative_spec.rb +5 -5
- data/spec/hermod/validators/non_zero_spec.rb +5 -5
- data/spec/hermod/validators/range_spec.rb +6 -6
- data/spec/hermod/validators/regular_expression_spec.rb +5 -5
- data/spec/hermod/validators/type_checker_spec.rb +9 -9
- data/spec/hermod/validators/value_presence_spec.rb +3 -3
- data/spec/hermod/validators/whole_units_spec.rb +4 -4
- data/spec/hermod/xml_section_builder/date_node_spec.rb +3 -3
- data/spec/hermod/xml_section_builder/datetime_node_spec.rb +3 -3
- data/spec/hermod/xml_section_builder/integer_node_spec.rb +3 -3
- data/spec/hermod/xml_section_builder/monetary_node_spec.rb +12 -12
- data/spec/hermod/xml_section_builder/parent_node_spec.rb +1 -1
- data/spec/hermod/xml_section_builder/string_node_spec.rb +17 -17
- data/spec/hermod/xml_section_builder/yes_no_node_spec.rb +2 -2
- data/spec/hermod/xml_section_builder/yes_node_spec.rb +2 -2
- data/spec/hermod/xml_section_spec.rb +18 -18
- data/spec/hermod_spec.rb +1 -1
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25ef83e5f96c6113d09daac9754cad30bc9499a02013573ebced458a37eeae68
|
4
|
+
data.tar.gz: 57e1414e8e703819410bd3e41e51d7b8d4e6a3ee7f1fefe11cda04cac8c853c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8bc3e4c9e2a63f07899eff3634d4936b5239ef8d1c37ef364c92a740b209cfd2a950230b0dd62c0c8f6b603cf3b8e0b55476ec42799b5ff62faf14d9f6f0a42
|
7
|
+
data.tar.gz: ee0d1d9b7d19f9db5b5d54b92ad282af123b166f4870284eb9a991f0f1285d876e4af42ed6241235ae14620b147eda7f5a003fde219c6b8a4f8d1f6ddc0cc55a
|
@@ -5,9 +5,9 @@ jobs:
|
|
5
5
|
name: runner / actionlint
|
6
6
|
runs-on: ubuntu-latest
|
7
7
|
steps:
|
8
|
-
- uses: actions/checkout@
|
8
|
+
- uses: actions/checkout@v3
|
9
9
|
- name: actionlint
|
10
|
-
uses: reviewdog/action-actionlint@v1
|
10
|
+
uses: reviewdog/action-actionlint@v1
|
11
11
|
with:
|
12
12
|
fail_on_error: true
|
13
13
|
reporter: github-pr-review
|
data/CHANGELOG.md
CHANGED
@@ -6,20 +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
|
-
|
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
|
11
21
|
- Remove the upper limit on the activesupport version
|
12
22
|
|
13
|
-
##[2.6.1] - 2020-10-22
|
23
|
+
## [2.6.1] - 2020-10-22
|
14
24
|
## Added
|
15
25
|
- Changelog updates
|
16
26
|
|
17
|
-
##[2.6.0] - 2020-10-22
|
27
|
+
## [2.6.0] - 2020-10-22
|
18
28
|
## Added
|
19
29
|
- Update libxml-ruby to version ~> 3.2
|
20
30
|
- Update ruby-version to 2.7.1
|
21
31
|
|
22
|
-
##[2.5.3] - 2019-11-01
|
32
|
+
## [2.5.3] - 2019-11-01
|
23
33
|
### Added
|
24
34
|
- Link wiki to the readme file.
|
25
35
|
|
data/hermod.gemspec
CHANGED
@@ -27,9 +27,9 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_development_dependency "bundler", "~> 2.0"
|
29
29
|
spec.add_development_dependency "rake", "13.0.1"
|
30
|
-
spec.add_development_dependency "minitest", "~> 5.
|
31
|
-
spec.add_development_dependency "minitest-reporters", "
|
32
|
-
spec.add_development_dependency "nokogiri", "~> 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
35
|
"allowed_push_host" => "https://rubygems.org",
|
@@ -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
|
7
|
+
attr_reader :allowed_attributes
|
8
8
|
|
9
9
|
# Public: Sets up the list of allowed attributes
|
10
10
|
def initialize(allowed_attributes)
|
data/lib/hermod/version.rb
CHANGED
@@ -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 =
|
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 =
|
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
|
-
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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
|
-
|
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
|
-
|
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 =
|
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 =
|
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 =
|
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 =
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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
|
-
|
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
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hermod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
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: 2022-
|
11
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libxml-ruby
|
@@ -72,48 +72,48 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '5.
|
75
|
+
version: '5.15'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '5.
|
82
|
+
version: '5.15'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: minitest-reporters
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.0'
|
90
87
|
- - ">="
|
91
88
|
- !ruby/object:Gem::Version
|
92
89
|
version: 1.0.16
|
90
|
+
- - "~>"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '1.5'
|
93
93
|
type: :development
|
94
94
|
prerelease: false
|
95
95
|
version_requirements: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
|
-
- - "~>"
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: '1.0'
|
100
97
|
- - ">="
|
101
98
|
- !ruby/object:Gem::Version
|
102
99
|
version: 1.0.16
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '1.5'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: nokogiri
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '1.
|
109
|
+
version: '1.13'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: '1.
|
116
|
+
version: '1.13'
|
117
117
|
description: |-
|
118
118
|
A Ruby library for talking to the HMRC Government Gateway.
|
119
119
|
This provides a builder for creating classes that can generate the XML needed complete with type information and
|
@@ -199,9 +199,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
199
|
version: 2.0.0
|
200
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
201
|
requirements:
|
202
|
-
- - "
|
202
|
+
- - ">"
|
203
203
|
- !ruby/object:Gem::Version
|
204
|
-
version:
|
204
|
+
version: 1.3.1
|
205
205
|
requirements: []
|
206
206
|
rubygems_version: 3.2.32
|
207
207
|
signing_key:
|