Skip to content

zamboni/validation_matcher

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Validation Matcher build status code climate

About

Use Rails 3 validation reflection to test validations.

URLs:

Installation

Add to your Gemfile and run the bundle command to install it.

gem 'validation_matcher'

Requires Ruby 1.9.2 or later.

Usage

class Foo < ActiveRecord::Base
  validates :field_a, presence: true
  validates :field_b, uniquness: true
  validates :field_c, presence: true, uniquness: {case_insensitive: false}
end

require 'spec_helper'

describe Foo do
  it { should validate(:presence).of(:field_a) }
  it { should validate(:presence).of(:field_b) }
  it { should validate(:presence).of(:field_c).with(case_insensitive: false) }
  it { should validate(:uniqueness).of(:field_b).with(options) }
end

About

Use reflection to spec ActiveModel validations

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%