Skip to content
No description or website provided.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib/validation_matchers
spec
.gitignore
.rspec
README.rdoc
validation_matchers.gemspec

README.rdoc

Validation Matchers

RSpec matchers for testing ActiveModel custom validations in isolation from your application's models

Install

From the command line

gem install validation_matchers

Using bundler

gem "validation_matchers", "~> 0.1.0"

Usage

Currently we support testing subclasses of ActiveModel::EachValidator.

Use the gem in your specs by including ValidationMatchers::ActiveModel. You will get access to “pass_validate_each” and “fail_validate_each” methods.

Example

require 'validation_matchers/active_model' 

describe MyActiveModelValidator do
  include ValidationMatchers::ActiveModel
  subject { MyActiveModelValidator.new({:attributes=>{}}) }

  it "allows a valid value" do
    subject.should pass_validate_each(:attr, "valid value") 
  end

  it "rejects an invalid value" do
    subject.should fail_validate_each(:attr, "some bad value") 
  end
end
Something went wrong with that request. Please try again.