rspec-kwalify 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,4 +1,6 @@
1
1
  *.gem
2
2
  .bundle
3
+ .yardoc/*
3
4
  Gemfile.lock
5
+ doc/*
4
6
  pkg/*
data/Gemfile CHANGED
@@ -2,9 +2,12 @@ source :rubygems
2
2
  gemspec
3
3
 
4
4
  group :development do
5
+ gem "yard"
6
+ gem "rdiscount"
5
7
  gem "guard"
6
8
  gem "guard-bundler"
7
9
  gem "guard-rspec"
10
+ gem "guard-yard"
8
11
  gem "ruby_gntp"
9
12
  gem "ruby-debug19"
10
13
  end
data/Guardfile CHANGED
@@ -9,3 +9,8 @@ guard :rspec, :version => 2, :cli => "--color --format nested --fail-fast" do
9
9
  watch(%r{^spec/.+_spec\.rb})
10
10
  watch(%r{^lib/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
11
11
  end
12
+
13
+ guard :yard do
14
+ watch("README.md")
15
+ watch("lib")
16
+ end
@@ -0,0 +1,44 @@
1
+ # 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")
2
+
3
+ [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.
4
+
5
+ Instead of having tests like this:
6
+ <pre>
7
+ it "should have 2 validation errors" do
8
+ errors = validator.validate(load_yaml("empty.yml"))
9
+ errors.size.should == 2
10
+ errors.each do |error|
11
+ error.is_a?(Kwalify::ValidationError).should be_true
12
+ end
13
+ end
14
+ </pre>
15
+
16
+ You can use the more readable
17
+ <pre>
18
+ it "should have 2 errors" do
19
+ validator.validate(asset("empty.yml")).should have_validation_error(2)
20
+ end
21
+ </pre>
22
+
23
+ All you need to do is to add this to your `Gemfile`
24
+ <pre>
25
+ group :development, :test do
26
+ gem "rspec-kwalify"
27
+ end
28
+ </pre>
29
+
30
+ ## Examples
31
+
32
+ <pre>
33
+ it "should have 2 errors" do
34
+ validator.validate(asset("empty.yml")).should have_error(2)
35
+ end
36
+
37
+ it "should have 'foo' key" do
38
+ validator.validate(asset("empty.yml")).should have_error(/key 'foo:' is required/)
39
+ end
40
+
41
+ it "should have validation error" do
42
+ validator.validate(asset("empty.yml")).should have_validation_error
43
+ end
44
+ </pre>
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
+ require 'yard'
3
4
 
4
5
  task :default => [:spec]
5
6
 
@@ -7,3 +8,7 @@ desc "run rspec tests"
7
8
  RSpec::Core::RakeTask.new do |task|
8
9
  task.rspec_opts = "--format documentation --color"
9
10
  end
11
+
12
+ YARD::Rake::YardocTask.new do |task|
13
+ task.options = %w[--markup markdown]
14
+ end
@@ -4,6 +4,7 @@ require "rspec-kwalify/version"
4
4
  module RSpec
5
5
  module Kwalify
6
6
 
7
+ # @author Martin Englund
7
8
  class HaveError
8
9
  def initialize(error, base_error=::Kwalify::BaseError)
9
10
  @error = error
@@ -43,14 +44,32 @@ module RSpec
43
44
  end
44
45
  end
45
46
 
46
- # have_error error of type Kwalify::BaseError
47
- # have_error(Fixnum) number of errors
48
- # have_error(Regexp) error with a message matching
47
+ # @overload have_error
48
+ # Matches if it has an error that `is_a?` [Kwalify::BaseError]
49
+ # @return [RSpec::Kwalify::HaveError]
50
+ # @overload have_error(count)
51
+ # Matches if the number of errors is equal to `count`
52
+ # @param [Fixnum] count
53
+ # @return [RSpec::Kwalify::HaveError]
54
+ # @overload have_error(regexp)
55
+ # Matches if the error message matches the regexp
56
+ # @param [Regexp] regexp
57
+ # @return [RSpec::Kwalify::HaveError]
49
58
  def have_error(error=nil)
50
59
  RSpec::Kwalify::HaveError.new(error)
51
60
  end
52
61
 
53
- # have_validation_error
62
+ # @overload have_validation_error
63
+ # Matches if it has an error that `is_a?` [Kwalify::ValidationError]
64
+ # @return [RSpec::Kwalify::HaveError]
65
+ # @overload have_validation_error(count)
66
+ # Matches if the number of errors is equal to `count`
67
+ # @param [Fixnum] count
68
+ # @return [RSpec::Kwalify::HaveError]
69
+ # @overload have_validation_error(regexp)
70
+ # Matches if the error message matches the regexp
71
+ # @param [Regexp] regexp
72
+ # @return [RSpec::Kwalify::HaveError]
54
73
  def have_validation_error(error=nil)
55
74
  RSpec::Kwalify::HaveError.new(error, ::Kwalify::ValidationError)
56
75
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Kwalify
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -7,9 +7,9 @@ Gem::Specification.new do |s|
7
7
  s.version = RSpec::Kwalify::VERSION
8
8
  s.authors = ["Martin Englund"]
9
9
  s.email = ["martin@englund.nu"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/pmenglund/rspec-kwalify"
11
11
  s.summary = %q{rspec matchers for kwalify}
12
- s.description = %q{rspec matchers for kwalify}
12
+ s.description = %q{rspec matchers for kwalify to help you validate yaml files}
13
13
 
14
14
  s.rubyforge_project = "rspec-kwalify"
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-kwalify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-17 00:00:00.000000000Z
12
+ date: 2012-04-18 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70193016224180 !ruby/object:Gem::Requirement
16
+ requirement: &70171027223180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70193016224180
24
+ version_requirements: *70171027223180
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: kwalify
27
- requirement: &70193016223760 !ruby/object:Gem::Requirement
27
+ requirement: &70171027222400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,8 +32,8 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70193016223760
36
- description: rspec matchers for kwalify
35
+ version_requirements: *70171027222400
36
+ description: rspec matchers for kwalify to help you validate yaml files
37
37
  email:
38
38
  - martin@englund.nu
39
39
  executables: []
@@ -44,7 +44,7 @@ files:
44
44
  - .travis.yml
45
45
  - Gemfile
46
46
  - Guardfile
47
- - README.textile
47
+ - README.md
48
48
  - Rakefile
49
49
  - lib/rspec-kwalify.rb
50
50
  - lib/rspec-kwalify/version.rb
@@ -54,7 +54,7 @@ files:
54
54
  - spec/assets/syntax.yml
55
55
  - spec/rspec-kwalify_spec.rb
56
56
  - spec/spec_helper.rb
57
- homepage: ''
57
+ homepage: https://github.com/pmenglund/rspec-kwalify
58
58
  licenses: []
59
59
  post_install_message:
60
60
  rdoc_options: []
@@ -1,15 +0,0 @@
1
- h1. RSpec-Kwalify "!https://secure.travis-ci.org/pmenglund/rspec-kwalify.png?branch=master!":http://travis-ci.org/pmenglund/rspec-kwalify
2
-
3
- RSpec matchers to help you use Kwalify in RSpec
4
-
5
- h1. Examples
6
-
7
- <pre>
8
- it "should have 2 errors" do
9
- validator.validate(asset("empty.yml")).should have_error(2)
10
- end
11
-
12
- it "should have validation error" do
13
- validator.validate(asset("empty.yml")).should have_validation_error
14
- end
15
- </pre>