rspec_sequel_matchers 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +47 -0
- data/Rakefile +46 -0
- data/lib/rspec_sequel/association.rb +30 -0
- data/lib/rspec_sequel/base.rb +33 -0
- data/lib/rspec_sequel/matchers/have_column.rb +35 -0
- data/lib/rspec_sequel/matchers/have_many_to_many.rb +22 -0
- data/lib/rspec_sequel/matchers/have_many_to_one.rb +22 -0
- data/lib/rspec_sequel/matchers/have_one_to_many.rb +22 -0
- data/lib/rspec_sequel/matchers/validate_exact_length.rb +25 -0
- data/lib/rspec_sequel/matchers/validate_format.rb +25 -0
- data/lib/rspec_sequel/matchers/validate_includes.rb +25 -0
- data/lib/rspec_sequel/matchers/validate_integer.rb +21 -0
- data/lib/rspec_sequel/matchers/validate_length_range.rb +25 -0
- data/lib/rspec_sequel/matchers/validate_max_length.rb +25 -0
- data/lib/rspec_sequel/matchers/validate_min_length.rb +25 -0
- data/lib/rspec_sequel/matchers/validate_not_string.rb +21 -0
- data/lib/rspec_sequel/matchers/validate_numeric.rb +21 -0
- data/lib/rspec_sequel/matchers/validate_presence.rb +21 -0
- data/lib/rspec_sequel/matchers/validate_unique.rb +33 -0
- data/lib/rspec_sequel/validation.rb +77 -0
- data/lib/rspec_sequel_matchers.rb +9 -0
- data/rspec_sequel_matchers.gemspec +107 -0
- data/spec/have_column_matcher_spec.rb +89 -0
- data/spec/have_many_to_many_matcher_spec.rb +56 -0
- data/spec/have_many_to_one_matcher_spec.rb +55 -0
- data/spec/have_one_to_many_matcher_spec.rb +55 -0
- data/spec/migrations/001_create_items.rb +15 -0
- data/spec/migrations/002_create_comments.rb +17 -0
- data/spec/migrations/003_create_comments_items.rb +15 -0
- data/spec/spec_helper.rb +51 -0
- data/spec/validate_exact_length_matcher_spec.rb +88 -0
- data/spec/validate_format_matcher_spec.rb +88 -0
- data/spec/validate_includes_matcher_spec.rb +88 -0
- data/spec/validate_integer_matcher_spec.rb +77 -0
- data/spec/validate_length_range_matcher_spec.rb +88 -0
- data/spec/validate_max_length_matcher_spec.rb +88 -0
- data/spec/validate_min_length_matcher_spec.rb +88 -0
- data/spec/validate_not_string_matcher_spec.rb +77 -0
- data/spec/validate_numeric_matcher_spec.rb +77 -0
- data/spec/validate_presence_matcher_spec.rb +77 -0
- data/spec/validate_unique_matcher_spec.rb +79 -0
- metadata +153 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
+
|
3
|
+
describe "validate_unique_matcher" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
define_model :item do
|
7
|
+
plugin :validation_helpers
|
8
|
+
def validate
|
9
|
+
validates_unique [:id, :name], :name, :message => "Hello"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
subject{ Item }
|
15
|
+
|
16
|
+
describe "arguments" do
|
17
|
+
it "should require attribute" do
|
18
|
+
lambda{
|
19
|
+
@matcher = validate_unique
|
20
|
+
}.should raise_error(ArgumentError)
|
21
|
+
end
|
22
|
+
it "should refuse additionnal parameters" do
|
23
|
+
lambda{
|
24
|
+
@matcher = validate_unique :name, :id
|
25
|
+
}.should raise_error(ArgumentError)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "messages" do
|
30
|
+
describe "without option" do
|
31
|
+
it "should contain a description" do
|
32
|
+
@matcher = validate_unique :name
|
33
|
+
@matcher.description.should == "validate uniqueness of :name"
|
34
|
+
end
|
35
|
+
it "should set failure messages" do
|
36
|
+
@matcher = validate_unique :name
|
37
|
+
@matcher.matches? subject
|
38
|
+
@matcher.failure_message.should == "expected Item to " + @matcher.description
|
39
|
+
@matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
|
40
|
+
end
|
41
|
+
end
|
42
|
+
describe "with options" do
|
43
|
+
it "should contain a description" do
|
44
|
+
@matcher = validate_unique :name, :message => "Hello"
|
45
|
+
@matcher.description.should == 'validate uniqueness of :name with option(s) :message => "Hello"'
|
46
|
+
end
|
47
|
+
it "should set failure messages" do
|
48
|
+
@matcher = validate_unique :price, :message => "Hello"
|
49
|
+
@matcher.matches? subject
|
50
|
+
@matcher.failure_message.should == "expected Item to " + @matcher.description
|
51
|
+
@matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
|
52
|
+
end
|
53
|
+
it "should explicit used options if different than expected" do
|
54
|
+
@matcher = validate_unique :name, :message => "Hello world"
|
55
|
+
@matcher.matches? subject
|
56
|
+
explanation = ' but called with option(s) :message => "Hello" instead'
|
57
|
+
@matcher.failure_message.should == "expected Item to " + @matcher.description + explanation
|
58
|
+
@matcher.negative_failure_message.should == "expected Item to not " + @matcher.description + explanation
|
59
|
+
end
|
60
|
+
it "should warn if invalid options are used" do
|
61
|
+
@matcher = validate_unique :name, :allow_nil => true
|
62
|
+
@matcher.matches? subject
|
63
|
+
explanation = " but option :allow_nil is not valid"
|
64
|
+
@matcher.failure_message.should == "expected Item to " + @matcher.description + explanation
|
65
|
+
@matcher.negative_failure_message.should == "expected Item to not " + @matcher.description + explanation
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "matchers" do
|
71
|
+
it{ should validate_unique(:name) }
|
72
|
+
it{ should validate_unique([:id, :name]) }
|
73
|
+
it{ should validate_unique(:name, :message => "Hello") }
|
74
|
+
it{ should_not validate_unique(:id) }
|
75
|
+
it{ should_not validate_unique(:price) }
|
76
|
+
it{ should_not validate_unique(:name, :allow_nil => true) }
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec_sequel_matchers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jonathan Tron
|
13
|
+
- Joseph Halter
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-03-02 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 2
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
- a
|
33
|
+
version: 2.0.0.a
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sequel
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 3
|
45
|
+
- 8
|
46
|
+
- 0
|
47
|
+
version: 3.8.0
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
description:
|
51
|
+
email: team@openhood.com
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files:
|
57
|
+
- LICENSE
|
58
|
+
- README.rdoc
|
59
|
+
files:
|
60
|
+
- .document
|
61
|
+
- .gitignore
|
62
|
+
- LICENSE
|
63
|
+
- README.rdoc
|
64
|
+
- Rakefile
|
65
|
+
- lib/rspec_sequel/association.rb
|
66
|
+
- lib/rspec_sequel/base.rb
|
67
|
+
- lib/rspec_sequel/matchers/have_column.rb
|
68
|
+
- lib/rspec_sequel/matchers/have_many_to_many.rb
|
69
|
+
- lib/rspec_sequel/matchers/have_many_to_one.rb
|
70
|
+
- lib/rspec_sequel/matchers/have_one_to_many.rb
|
71
|
+
- lib/rspec_sequel/matchers/validate_exact_length.rb
|
72
|
+
- lib/rspec_sequel/matchers/validate_format.rb
|
73
|
+
- lib/rspec_sequel/matchers/validate_includes.rb
|
74
|
+
- lib/rspec_sequel/matchers/validate_integer.rb
|
75
|
+
- lib/rspec_sequel/matchers/validate_length_range.rb
|
76
|
+
- lib/rspec_sequel/matchers/validate_max_length.rb
|
77
|
+
- lib/rspec_sequel/matchers/validate_min_length.rb
|
78
|
+
- lib/rspec_sequel/matchers/validate_not_string.rb
|
79
|
+
- lib/rspec_sequel/matchers/validate_numeric.rb
|
80
|
+
- lib/rspec_sequel/matchers/validate_presence.rb
|
81
|
+
- lib/rspec_sequel/matchers/validate_unique.rb
|
82
|
+
- lib/rspec_sequel/validation.rb
|
83
|
+
- lib/rspec_sequel_matchers.rb
|
84
|
+
- rspec_sequel_matchers.gemspec
|
85
|
+
- spec/have_column_matcher_spec.rb
|
86
|
+
- spec/have_many_to_many_matcher_spec.rb
|
87
|
+
- spec/have_many_to_one_matcher_spec.rb
|
88
|
+
- spec/have_one_to_many_matcher_spec.rb
|
89
|
+
- spec/migrations/001_create_items.rb
|
90
|
+
- spec/migrations/002_create_comments.rb
|
91
|
+
- spec/migrations/003_create_comments_items.rb
|
92
|
+
- spec/spec_helper.rb
|
93
|
+
- spec/validate_exact_length_matcher_spec.rb
|
94
|
+
- spec/validate_format_matcher_spec.rb
|
95
|
+
- spec/validate_includes_matcher_spec.rb
|
96
|
+
- spec/validate_integer_matcher_spec.rb
|
97
|
+
- spec/validate_length_range_matcher_spec.rb
|
98
|
+
- spec/validate_max_length_matcher_spec.rb
|
99
|
+
- spec/validate_min_length_matcher_spec.rb
|
100
|
+
- spec/validate_not_string_matcher_spec.rb
|
101
|
+
- spec/validate_numeric_matcher_spec.rb
|
102
|
+
- spec/validate_presence_matcher_spec.rb
|
103
|
+
- spec/validate_unique_matcher_spec.rb
|
104
|
+
has_rdoc: true
|
105
|
+
homepage: http://github.com/openhood/rspec_sequel_matchers
|
106
|
+
licenses: []
|
107
|
+
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options:
|
110
|
+
- --charset=UTF-8
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
version: "0"
|
127
|
+
requirements: []
|
128
|
+
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 1.3.6
|
131
|
+
signing_key:
|
132
|
+
specification_version: 3
|
133
|
+
summary: RSpec Matchers for Sequel
|
134
|
+
test_files:
|
135
|
+
- spec/have_column_matcher_spec.rb
|
136
|
+
- spec/have_many_to_many_matcher_spec.rb
|
137
|
+
- spec/have_many_to_one_matcher_spec.rb
|
138
|
+
- spec/have_one_to_many_matcher_spec.rb
|
139
|
+
- spec/migrations/001_create_items.rb
|
140
|
+
- spec/migrations/002_create_comments.rb
|
141
|
+
- spec/migrations/003_create_comments_items.rb
|
142
|
+
- spec/spec_helper.rb
|
143
|
+
- spec/validate_exact_length_matcher_spec.rb
|
144
|
+
- spec/validate_format_matcher_spec.rb
|
145
|
+
- spec/validate_includes_matcher_spec.rb
|
146
|
+
- spec/validate_integer_matcher_spec.rb
|
147
|
+
- spec/validate_length_range_matcher_spec.rb
|
148
|
+
- spec/validate_max_length_matcher_spec.rb
|
149
|
+
- spec/validate_min_length_matcher_spec.rb
|
150
|
+
- spec/validate_not_string_matcher_spec.rb
|
151
|
+
- spec/validate_numeric_matcher_spec.rb
|
152
|
+
- spec/validate_presence_matcher_spec.rb
|
153
|
+
- spec/validate_unique_matcher_spec.rb
|