Sha256: 221375bafbfa32140964fcfe4386c42fb5d48823f9d24e7e5220adf65cfb63dc

Contents?: true

Size: 1.13 KB

Versions: 40

Compression:

Stored size: 1.13 KB

Contents

# encoding: utf-8
require File.join(File.dirname(__FILE__), "../spec_helper.rb")

describe "Her::Model and ActiveModel::Validations" do
  context "validating attributes" do
    before do
      spawn_model "Foo::User" do
        attributes :fullname, :email
        validates_presence_of :fullname
        validates_presence_of :email
      end
    end

    it "validates attributes when calling #valid?" do
      user = Foo::User.new
      user.should_not be_valid
      user.errors.full_messages.should include("Fullname can't be blank")
      user.errors.full_messages.should include("Email can't be blank")
      user.fullname = "Tobias Fünke"
      user.email = "tobias@bluthcompany.com"
      user.should be_valid
    end
  end

  context "handling server errors" do
    before do
      spawn_model("Foo::Model") do
        def errors
          @response_errors
        end
      end

      class User < Foo::Model; end
      @spawned_models << :User
    end

    it "validates attributes when calling #valid?" do
      user = User.new(:_errors => ["Email cannot be blank"])
      user.errors.should include("Email cannot be blank")
    end
  end
end

Version data entries

40 entries across 40 versions & 4 rubygems

Version Path
test_track_rails_client-2.0.0 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-1.3.0 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-1.2.0 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-1.1.0 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-1.0.0 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.20 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.19 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.18 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.17 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.16 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.15 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.14 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.13 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.12 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.11 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.10 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.9 vendor/gems/her/spec/model/validations_spec.rb
test_track_rails_client-0.9.8 vendor/gems/her/spec/model/validations_spec.rb
her-0.8.2 spec/model/validations_spec.rb
her5-0.8.2 spec/model/validations_spec.rb