Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ruby/engine/embedded_help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,8 @@ def self.glob(pattern, _flags = 0, flags: _flags, base: nil, sort: true)
override_args_extglob = true

flags = flags | File::FNM_EXTGLOB if override_args_extglob
# Without this 'path/**/*.rb' will match 'path/sub/file.rb' but not 'path/file.rb', cf #5546
flags = flags | File::FNM_PATHNAME
Comment on lines +670 to +671

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't be fooled by the amount of code change, massive pain to diagnose and fix.

<broken record>We should drop the embedded shenanigans!</broken record>

result = []
pattern_array.each do |pattern|

Expand Down
26 changes: 26 additions & 0 deletions src/cli/test/test_embedded_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,30 @@ def test_json_schemer
assert(!schemer.valid?({ 'abc' => 10 }))
end

def test_json_schema
require 'json-schema'

schema = {
"type" => "object",
"required" => ["a"],
"properties" => {
"a" => {
"type" => "integer"
}
}
}

data_valid = { "a" => 5 }
JSON::Validator.validate(schema, data_valid)

data_invalid = { "a" => "taco" }

error = assert_raises(JSON::Schema::ValidationError) do
# "The property '#/a' of type String did not match the following type: integer"
JSON::Validator.validate!(schema, data_invalid)
end
assert_match(/The property '#\/a' of type string did not match the following type: integer/, error.message)

end
Comment on lines +245 to +269

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @shorowit pointed out, a test is an excellent idea...

Before fix

  1) Error:
EmbeddedRuby_Test#test_json_schema:
NoMethodError: undefined method `validate' for nil:NilClass
    :/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/schema/validator.rb:25:in `block in validate'
    :/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/schema/validator.rb:23:in `each'
    :/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/schema/validator.rb:23:in `validate'
    :/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/schema.rb:32:in `validate'
    :/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/validator.rb:115:in `validate'
    :/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/validator.rb:259:in `validate!'
    :/ruby/3.2.0/gems/json-schema-4.3.1/lib/json-schema/validator.rb:243:in `validate'
    /home/julien/Software/Others/OpenStudio/src/cli/test/test_embedded_ruby.rb:259:in `test_json_schema'


end
Loading