Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
RSpec matcher for Kwalify
Ruby
branch: master

version 0.0.2

- updated documentation to yard
- added guard-yard
- switched to markdown
latest commit 2c358b823e
@pmenglund authored
Failed to load latest commit information.
lib version 0.0.2
spec initial commit of rspec-kwalify
.gitignore version 0.0.2
.travis.yml initial commit of rspec-kwalify
Gemfile version 0.0.2
Guardfile version 0.0.2
README.md version 0.0.2
Rakefile version 0.0.2
rspec-kwalify.gemspec version 0.0.2

README.md

RSpec-Kwalify travis-ci

RSpec-Kwalify is a custom RSpec matcher to help you use Kwalify, a yaml validation gem, in RSpec.

Instead of having tests like this:

it "should have 2 validation errors" do
  errors = validator.validate(load_yaml("empty.yml"))
  errors.size.should == 2
  errors.each do |error|
    error.is_a?(Kwalify::ValidationError).should be_true
  end
end

You can use the more readable

it "should have 2 errors" do
  validator.validate(asset("empty.yml")).should have_validation_error(2)
end

All you need to do is to add this to your Gemfile

group :development, :test do
  gem "rspec-kwalify"
end

Examples

it "should have 2 errors" do
  validator.validate(asset("empty.yml")).should have_error(2)
end

it "should have 'foo' key" do
  validator.validate(asset("empty.yml")).should have_error(/key 'foo:' is required/)
end

it "should have validation error" do
  validator.validate(asset("empty.yml")).should have_validation_error
end
Something went wrong with that request. Please try again.