New Upstream Snapshot - ruby-schash
Ready changes
Summary
Merged new upstream version: 0.1.2+git20150803.1.ee2ab09 (was: 0.1.2).
Resulting package
Built on 2023-01-20T05:29 (took 2m35s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-snapshots ruby-schash
Lintian Result
Diff
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 0cb6eeb..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-/.bundle/
-/.yardoc
-/Gemfile.lock
-/_yardoc/
-/coverage/
-/doc/
-/pkg/
-/spec/reports/
-/tmp/
diff --git a/README.md b/README.md
index da829da..d931726 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Schash [![Build Status](https://travis-ci.org/ryotarai/schash.svg?branch=master)](https://travis-ci.org/ryotarai/schash)
+# Schash [![Build Status](https://travis-ci.org/ryotarai/schash.svg?branch=master)](https://travis-ci.org/ryotarai/schash) [![Gem Version](https://badge.fury.io/rb/schash.svg)](http://badge.fury.io/rb/schash)
Pronounciation: the same as "squash"
diff --git a/debian/changelog b/debian/changelog
index 9f53bb1..5262d62 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-ruby-schash (0.1.2-2) UNRELEASED; urgency=medium
+ruby-schash (0.1.2+git20150803.1.ee2ab09-1) UNRELEASED; urgency=medium
[ Utkarsh Gupta ]
* Add salsa-ci.yml
@@ -11,8 +11,9 @@ ruby-schash (0.1.2-2) UNRELEASED; urgency=medium
Repository-Browse.
* Update Vcs-* headers from URL redirect.
* Use canonical URL in Vcs-Git.
+ * New upstream snapshot.
- -- Utkarsh Gupta <guptautkarsh2102@gmail.com> Tue, 13 Aug 2019 07:25:48 +0530
+ -- Utkarsh Gupta <guptautkarsh2102@gmail.com> Fri, 20 Jan 2023 05:27:40 -0000
ruby-schash (0.1.2-1) unstable; urgency=low
diff --git a/spec/schash_spec.rb b/spec/schash_spec.rb
new file mode 100644
index 0000000..d3f3012
--- /dev/null
+++ b/spec/schash_spec.rb
@@ -0,0 +1,106 @@
+require 'spec_helper'
+
+describe Schash::Validator do
+ let(:schema) do
+ proc do
+ {
+ data: {
+ string: string,
+ not_string: string,
+ words: array_of(string),
+ not_array: array_of(string),
+ required_missing: string,
+ optional_missing: optional(string),
+ optional_type_error: optional(string),
+ numeric: numeric,
+ not_numeric: numeric,
+ hash: {
+ required_missing: string,
+ },
+ array_of_hash: array_of({
+ required_missing: string,
+ }),
+ boolean: boolean,
+ not_boolean: boolean,
+ match: match(/^pattern$/),
+ not_match: match(/^pattern$/)
+ }
+ }
+ end
+ end
+ subject { described_class.new(&schema) }
+
+ describe "#validate" do
+ context "with invalid data" do
+ it "returns errors" do
+ errors = subject.validate({
+ data: {
+ string: "string",
+ not_string: 1,
+ words: [1],
+ not_array: 1,
+ optional_type_error: 1,
+ numeric: 1,
+ not_numeric: "not numeric",
+ hash: {
+ },
+ array_of_hash: [{}],
+ boolean: true,
+ not_boolean: "string",
+ match: "pattern",
+ not_match: "not match pattern"
+ },
+ })
+
+ expected = [
+ [
+ ["data", "not_string"],
+ "is not String",
+ ],
+ [
+ ["data", "words", 0],
+ "is not String",
+ ],
+ [
+ ["data", "not_array"],
+ "is not an array",
+ ],
+ [
+ ["data", "required_missing"],
+ "is required but missing",
+ ],
+ [
+ ["data", "optional_type_error"],
+ "is not String",
+ ],
+ [
+ ["data", "not_numeric"],
+ "is not Numeric",
+ ],
+ [
+ ["data", "hash", "required_missing"],
+ "is required but missing",
+ ],
+ [
+ ["data", "array_of_hash", 0, "required_missing"],
+ "is required but missing",
+ ],
+ [
+ ["data", "not_boolean"],
+ "is not any of TrueClass, FalseClass",
+ ],
+ [
+ ["data", "not_match"],
+ "does not match /^pattern$/",
+ ]
+ ]
+
+ expect(errors.size).to eq(expected.size)
+ errors.each_with_index do |error, i|
+ expect(error.position).to eq(expected[i][0])
+ expect(error.message).to eq(expected[i][1])
+ end
+ end
+ end
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..a14747f
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,2 @@
+$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
+require 'schash'