Sha256: 568fdc4b35f66baa49487be5fd68c18f09cacffb51be9318d34db75b44cab63c
Contents?: true
Size: 1.84 KB
Versions: 4
Compression:
Stored size: 1.84 KB
Contents
require "strong_json" describe StrongJSON::Type::Base do describe "#test" do context ":prohibited" do let (:type) { StrongJSON::Type::Base.new(:prohibited) } it "rejects number" do expect(type.test(123)).to be_falsey end end context ":number" do let (:type) { StrongJSON::Type::Base.new(:number) } it "accepts integer" do expect(type.test(123)).to be_truthy end it "accepts float" do expect(type.test(3.14)).to be_truthy end it "rejects string" do expect(type.test("string")).to be_falsey end end context ":string" do let (:type) { StrongJSON::Type::Base.new(:string) } it "accepts string" do expect(type.test("string")).to be_truthy end end context ":any" do let (:type) { StrongJSON::Type::Base.new(:any) } it "accepts string" do expect(type.test("string")).to be_truthy end it "accepts number" do expect(type.test(2.71828)).to be_truthy end end context ":boolean" do let (:type) { StrongJSON::Type::Base.new(:boolean) } it "accepts true" do expect(type.test(true)).to be_truthy end it "accepts false" do expect(type.test(false)).to be_truthy end it "rejects nil" do expect(type.test(nil)).to be_falsey end end context ":numeric" do let (:type) { StrongJSON::Type::Base.new(:numeric) } it "accepts number" do expect(type.test(123)).to be_truthy end it "accepts number format string" do expect(type.test("123")).to be_truthy end it "rejects non numeric format string" do expect(type.test("test")).to be_falsey end it "rejects boolean" do expect(type.test(true)).to be_falsey end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
strong_json-0.0.4 | spec/basetype_spec.rb |
strong_json-0.0.3 | spec/basetype_spec.rb |
strong_json-0.0.2 | spec/basetype_spec.rb |
strong_json-0.0.1 | spec/basetype_spec.rb |