Sha256: 237c59c12135d0104104201514e159e97ba3879d37fb55766127dff3418da2d9
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
require 'test_helper' class JsonColumnTest < ActiveSupport::TestCase test "it loads Schemas as Yml/yaml file" do assert Schemas::Json.is_a? Module end test "it loads Schemas as json file" do assert Schemas::Jbson.is_a? Module end test "it raise an error when schema file does not exist" do assert_raise RuntimeError do Schemas::Jsonsdas end end test "dummy app has a json column and a testmodel AR class" do assert TestModel.new.is_a? TestModel assert TestModel.new.respond_to? :json end test "gette for columns provided" do assert TestModel.new.respond_to? :json end test "JsonColumn load their schema from infered module" do assert TestModel.new.json._schema == Schemas::Json.schema end test "JsonColumn can receive Hash to change but stay of type JsonColumn" do t = TestModel.new t.json = {a: 42} assert t.json.is_a? JsonColumn::JsonColumnObject end test "Jsoncolumn change are saved to database" do t = TestModel.new t.json = {a: 42} t.save assert t.reload.json.to_s == HashWithIndifferentAccess[{"a": 42}].to_s end test "JsonColumn may be an array" do t = DModel.new assert t.arr.is_a? JsonColumn::JsonColumnArray t.arr << {fsdfsd: "LKj"} t.save(:validate => false) assert t.reload.arr == [{fsdfsd: "LKj"}] end test "it can validate with the right schema" do t = DModel.new assert t.arr.is_a? JsonColumn::JsonColumnArray t.arr << {fsdfsd: "LKj"} assert t.save t.arr << {ponctuality: "LKj"} refute t.valid? end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
json_column-0.6.6 | test/json_column_test.rb |
json_column-0.6.5 | test/json_column_test.rb |