Browse files

version 0.0.2

- updated documentation to yard
- added guard-yard
- switched to markdown
  • Loading branch information...
1 parent 37e4abe commit 2c358b823e86851e962875f77b2004de20dfc3c5 @pmenglund committed Apr 18, 2012
Showing with 85 additions and 22 deletions.
  1. +2 −0 .gitignore
  2. +3 −0 Gemfile
  3. +5 −0 Guardfile
  4. +44 −0 README.md
  5. +0 −15 README.textile
  6. +5 −0 Rakefile
  7. +23 −4 lib/rspec-kwalify.rb
  8. +1 −1 lib/rspec-kwalify/version.rb
  9. +2 −2 rspec-kwalify.gemspec
View
2 .gitignore
@@ -1,4 +1,6 @@
*.gem
.bundle
+.yardoc/*
Gemfile.lock
+doc/*
pkg/*
View
3 Gemfile
@@ -2,9 +2,12 @@ source :rubygems
gemspec
group :development do
+ gem "yard"
+ gem "rdiscount"
gem "guard"
gem "guard-bundler"
gem "guard-rspec"
+ gem "guard-yard"
gem "ruby_gntp"
gem "ruby-debug19"
end
View
5 Guardfile
@@ -9,3 +9,8 @@ guard :rspec, :version => 2, :cli => "--color --format nested --fail-fast" do
watch(%r{^spec/.+_spec\.rb})
watch(%r{^lib/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
end
+
+guard :yard do
+ watch("README.md")
+ watch("lib")
+end
View
44 README.md
@@ -0,0 +1,44 @@
+# RSpec-Kwalify [ ![travis-ci](https://secure.travis-ci.org/pmenglund/rspec-kwalify.png?branch=master "travis-ci") ](http://travis-ci.org/pmenglund/rspec-kwalify "Travis-CI")
+
+[RSpec-Kwalify](https://github.com/pmenglund/rspec-kwalify) is a custom RSpec matcher to help you use [Kwalify](http://www.kuwata-lab.com/kwalify/ruby/users-guide.html), a [yaml](http://yaml.org/) validation [gem](http://rubygems.org/), in RSpec.
+
+Instead of having tests like this:
+<pre>
+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
+</pre>
+
+You can use the more readable
+<pre>
+it "should have 2 errors" do
+ validator.validate(asset("empty.yml")).should have_validation_error(2)
+end
+</pre>
+
+All you need to do is to add this to your `Gemfile`
+<pre>
+group :development, :test do
+ gem "rspec-kwalify"
+end
+</pre>
+
+## Examples
+
+<pre>
+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
+</pre>
View
15 README.textile
@@ -1,15 +0,0 @@
-h1. RSpec-Kwalify "!https://secure.travis-ci.org/pmenglund/rspec-kwalify.png?branch=master!":http://travis-ci.org/pmenglund/rspec-kwalify
-
-RSpec matchers to help you use Kwalify in RSpec
-
-h1. Examples
-
-<pre>
- it "should have 2 errors" do
- validator.validate(asset("empty.yml")).should have_error(2)
- end
-
- it "should have validation error" do
- validator.validate(asset("empty.yml")).should have_validation_error
- end
-</pre>
View
5 Rakefile
@@ -1,9 +1,14 @@
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
+require 'yard'
task :default => [:spec]
desc "run rspec tests"
RSpec::Core::RakeTask.new do |task|
task.rspec_opts = "--format documentation --color"
end
+
+YARD::Rake::YardocTask.new do |task|
+ task.options = %w[--markup markdown]
+end
View
27 lib/rspec-kwalify.rb
@@ -4,6 +4,7 @@
module RSpec
module Kwalify
+ # @author Martin Englund
class HaveError
def initialize(error, base_error=::Kwalify::BaseError)
@error = error
@@ -43,14 +44,32 @@ def failure_message_for_should
end
end
-# have_error error of type Kwalify::BaseError
-# have_error(Fixnum) number of errors
-# have_error(Regexp) error with a message matching
+# @overload have_error
+# Matches if it has an error that `is_a?` [Kwalify::BaseError]
+# @return [RSpec::Kwalify::HaveError]
+# @overload have_error(count)
+# Matches if the number of errors is equal to `count`
+# @param [Fixnum] count
+# @return [RSpec::Kwalify::HaveError]
+# @overload have_error(regexp)
+# Matches if the error message matches the regexp
+# @param [Regexp] regexp
+# @return [RSpec::Kwalify::HaveError]
def have_error(error=nil)
RSpec::Kwalify::HaveError.new(error)
end
-# have_validation_error
+# @overload have_validation_error
+# Matches if it has an error that `is_a?` [Kwalify::ValidationError]
+# @return [RSpec::Kwalify::HaveError]
+# @overload have_validation_error(count)
+# Matches if the number of errors is equal to `count`
+# @param [Fixnum] count
+# @return [RSpec::Kwalify::HaveError]
+# @overload have_validation_error(regexp)
+# Matches if the error message matches the regexp
+# @param [Regexp] regexp
+# @return [RSpec::Kwalify::HaveError]
def have_validation_error(error=nil)
RSpec::Kwalify::HaveError.new(error, ::Kwalify::ValidationError)
end
View
2 lib/rspec-kwalify/version.rb
@@ -1,5 +1,5 @@
module RSpec
module Kwalify
- VERSION = "0.0.1"
+ VERSION = "0.0.2"
end
end
View
4 rspec-kwalify.gemspec
@@ -7,9 +7,9 @@ Gem::Specification.new do |s|
s.version = RSpec::Kwalify::VERSION
s.authors = ["Martin Englund"]
s.email = ["martin@englund.nu"]
- s.homepage = ""
+ s.homepage = "https://github.com/pmenglund/rspec-kwalify"
s.summary = %q{rspec matchers for kwalify}
- s.description = %q{rspec matchers for kwalify}
+ s.description = %q{rspec matchers for kwalify to help you validate yaml files}
s.rubyforge_project = "rspec-kwalify"

0 comments on commit 2c358b8

Please sign in to comment.