Sha256: 5f05e46ec1d0ec5ae0cf0195a6c880f03e44a970604f4c071b26af633a33ad0e
Contents?: true
Size: 1.25 KB
Versions: 3
Compression:
Stored size: 1.25 KB
Contents
require "test_helper" class ParseOptionTest < MiniTest::Spec Comment = Struct.new(:content, :user) User = Struct.new(:name) class CommentForm < TestForm property :content property :user, parse: false end let(:current_user) { User.new("Peter") } let(:form) { CommentForm.new(Comment.new, user: current_user) } it do form.user.must_equal current_user lorem = "Lorem ipsum dolor sit amet..." form.validate("content" => lorem, "user" => "not the current user") form.content.must_equal lorem form.user.must_equal current_user end describe "using ':parse' option doesn't override other ':deserialize' options" do class ArticleCommentForm < TestForm property :content property :article, deserializer: {instance: "Instance"} property :user, parse: false, deserializer: {instance: "Instance"} end it do ArticleCommentForm.definitions.get(:user)[:deserializer][:writeable].must_equal false ArticleCommentForm.definitions.get(:user)[:deserializer][:instance].must_equal "Instance" ArticleCommentForm.definitions.get(:article)[:deserializer][:writeable].must_equal true ArticleCommentForm.definitions.get(:article)[:deserializer][:instance].must_equal "Instance" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
reform-2.3.2 | test/parse_option_test.rb |
reform-2.3.1 | test/parse_option_test.rb |
reform-2.3.0.rc2 | test/parse_option_test.rb |