test/reform_test.rb in reform-0.2.7 vs test/reform_test.rb in reform-1.0.0

- old
+ new

@@ -29,17 +29,17 @@ end class FieldsTest < MiniTest::Spec describe "#new" do it "accepts list of properties" do - fields = Reform::Fields.new([:name, :title]) + fields = Reform::Contract::Fields.new([:name, :title]) fields.name.must_equal nil fields.title.must_equal nil end it "accepts list of properties and values" do - fields = Reform::Fields.new(["name", "title"], "title" => "The Body") + fields = Reform::Contract::Fields.new(["name", "title"], "title" => "The Body") fields.name.must_equal nil fields.title.must_equal "The Body" end it "processes value syms" do @@ -56,15 +56,18 @@ let (:form) { SongForm.new(comp) } describe "::properties" do - it do + subject do Class.new(Reform::Form) do properties [:name, :title] - end.new(comp).to_hash.must_equal({"name"=>"Duran Duran", "title"=>"Rio"}) + end.new(comp) end + + it { subject.name.must_equal "Duran Duran" } + it { subject.title.must_equal "Rio" } end class SongForm < Reform::Form property :name property :title @@ -161,10 +164,12 @@ end end describe "#errors" do + before { form.validate({})} + it { form.errors.must_be_kind_of Reform::Form::Errors } it { form.errors.messages.must_equal({}) } it do @@ -250,11 +255,11 @@ form.validate("password" => "123", "password_confirmation" => "321") form.password.must_equal "123" form.password_confirmation.must_equal "321" - form.save + form.sync cred.password.must_equal "123" hash = {} form.save do |f, nested| hash = nested @@ -278,10 +283,10 @@ it do form.validate("country" => "Germany") # this usually won't change when submitting. form.country.must_equal "Germany" - form.save + form.sync loc.country.must_equal "Australia" # the writer wasn't called. hash = {} form.save do |f, nested| hash = nested \ No newline at end of file