rspec_sequel_matchers 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/{README.rdoc → README.md} +35 -17
- data/lib/rspec_sequel/base.rb +11 -2
- data/lib/rspec_sequel/matchers/have_one_to_one.rb +19 -0
- data/lib/rspec_sequel/validation.rb +3 -3
- data/spec/have_column_matcher_spec.rb +23 -23
- data/spec/have_many_to_many_matcher_spec.rb +14 -14
- data/spec/have_many_to_one_matcher_spec.rb +12 -12
- data/spec/have_one_to_many_matcher_spec.rb +12 -12
- data/spec/have_one_to_one_matcher_spec.rb +48 -0
- data/spec/migrations/001_create_items.rb +1 -1
- data/spec/migrations/004_create_profile.rb +18 -0
- data/spec/spec_helper.rb +10 -3
- data/spec/validate_exact_length_matcher_spec.rb +23 -23
- data/spec/validate_format_matcher_spec.rb +23 -23
- data/spec/validate_includes_matcher_spec.rb +23 -23
- data/spec/validate_integer_matcher_spec.rb +18 -18
- data/spec/validate_length_range_matcher_spec.rb +23 -23
- data/spec/validate_max_length_matcher_spec.rb +23 -23
- data/spec/validate_min_length_matcher_spec.rb +23 -23
- data/spec/validate_not_string_matcher_spec.rb +18 -18
- data/spec/validate_numeric_matcher_spec.rb +18 -18
- data/spec/validate_presence_matcher_spec.rb +18 -18
- data/spec/validate_unique_matcher_spec.rb +20 -20
- metadata +12 -9
@@ -15,14 +15,14 @@ describe "validate_presence_matcher" do
|
|
15
15
|
|
16
16
|
describe "arguments" do
|
17
17
|
it "should require attribute" do
|
18
|
-
|
18
|
+
expect do
|
19
19
|
@matcher = validate_presence
|
20
|
-
|
20
|
+
end.to raise_error
|
21
21
|
end
|
22
22
|
it "should refuse additionnal parameters" do
|
23
|
-
|
23
|
+
expect do
|
24
24
|
@matcher = validate_presence :name, :id
|
25
|
-
|
25
|
+
end.to raise_error
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -30,48 +30,48 @@ describe "validate_presence_matcher" do
|
|
30
30
|
describe "without option" do
|
31
31
|
it "should contain a description" do
|
32
32
|
@matcher = validate_presence :name
|
33
|
-
@matcher.description.
|
33
|
+
expect( @matcher.description ).to eq "validate presence of :name"
|
34
34
|
end
|
35
35
|
it "should set failure messages" do
|
36
36
|
@matcher = validate_presence :name
|
37
37
|
@matcher.matches? subject
|
38
|
-
@matcher.failure_message.
|
39
|
-
@matcher.
|
38
|
+
expect( @matcher.failure_message ).to eq "expected Item to " + @matcher.description
|
39
|
+
expect( @matcher.failure_message_when_negated ).to eq "expected Item to not " + @matcher.description
|
40
40
|
end
|
41
41
|
end
|
42
42
|
describe "with options" do
|
43
43
|
it "should contain a description" do
|
44
44
|
@matcher = validate_presence :name, :allow_nil => true
|
45
|
-
@matcher.description.
|
45
|
+
expect( @matcher.description ).to eq "validate presence of :name with option(s) :allow_nil => true"
|
46
46
|
end
|
47
47
|
it "should set failure messages" do
|
48
48
|
@matcher = validate_presence :price, :allow_nil => true
|
49
49
|
@matcher.matches? subject
|
50
|
-
@matcher.failure_message.
|
51
|
-
@matcher.
|
50
|
+
expect( @matcher.failure_message ).to eq "expected Item to " + @matcher.description
|
51
|
+
expect( @matcher.failure_message_when_negated ).to eq "expected Item to not " + @matcher.description
|
52
52
|
end
|
53
53
|
it "should explicit used options if different than expected" do
|
54
54
|
@matcher = validate_presence :name, :allow_blank => true
|
55
55
|
@matcher.matches? subject
|
56
56
|
explanation = " but called with option(s) :allow_nil => true instead"
|
57
|
-
@matcher.failure_message.
|
58
|
-
@matcher.
|
57
|
+
expect( @matcher.failure_message ).to eq "expected Item to " + @matcher.description + explanation
|
58
|
+
expect( @matcher.failure_message_when_negated ).to eq "expected Item to not " + @matcher.description + explanation
|
59
59
|
end
|
60
60
|
it "should warn if invalid options are used" do
|
61
61
|
@matcher = validate_presence :name, :allow_anything => true
|
62
62
|
@matcher.matches? subject
|
63
63
|
explanation = " but option :allow_anything is not valid"
|
64
|
-
@matcher.failure_message.
|
65
|
-
@matcher.
|
64
|
+
expect( @matcher.failure_message ).to eq "expected Item to " + @matcher.description + explanation
|
65
|
+
expect( @matcher.failure_message_when_negated ).to eq "expected Item to not " + @matcher.description + explanation
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe "matchers" do
|
71
|
-
it{
|
72
|
-
it{
|
73
|
-
it{
|
74
|
-
it{
|
71
|
+
it{ is_expected.to validate_presence(:name) }
|
72
|
+
it{ is_expected.to validate_presence(:name, :allow_nil => true) }
|
73
|
+
it{ is_expected.not_to validate_presence(:price) }
|
74
|
+
it{ is_expected.not_to validate_presence(:name, :allow_blank => true) }
|
75
75
|
end
|
76
76
|
|
77
77
|
end
|
@@ -15,14 +15,14 @@ describe "validate_unique_matcher" do
|
|
15
15
|
|
16
16
|
describe "arguments" do
|
17
17
|
it "should require attribute" do
|
18
|
-
|
18
|
+
expect do
|
19
19
|
@matcher = validate_unique
|
20
|
-
|
20
|
+
end.to raise_error
|
21
21
|
end
|
22
22
|
it "should refuse additionnal parameters" do
|
23
|
-
|
23
|
+
expect do
|
24
24
|
@matcher = validate_unique :name, :id
|
25
|
-
|
25
|
+
end.to raise_error
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -30,50 +30,50 @@ describe "validate_unique_matcher" do
|
|
30
30
|
describe "without option" do
|
31
31
|
it "should contain a description" do
|
32
32
|
@matcher = validate_unique :name
|
33
|
-
@matcher.description.
|
33
|
+
expect( @matcher.description ).to eq "validate uniqueness of :name"
|
34
34
|
end
|
35
35
|
it "should set failure messages" do
|
36
36
|
@matcher = validate_unique :name
|
37
37
|
@matcher.matches? subject
|
38
|
-
@matcher.failure_message.
|
39
|
-
@matcher.
|
38
|
+
expect( @matcher.failure_message ).to eq "expected Item to " + @matcher.description
|
39
|
+
expect( @matcher.failure_message_when_negated ).to eq "expected Item to not " + @matcher.description
|
40
40
|
end
|
41
41
|
end
|
42
42
|
describe "with options" do
|
43
43
|
it "should contain a description" do
|
44
44
|
@matcher = validate_unique :name, :message => "Hello"
|
45
|
-
@matcher.description.
|
45
|
+
expect( @matcher.description ).to eq 'validate uniqueness of :name with option(s) :message => "Hello"'
|
46
46
|
end
|
47
47
|
it "should set failure messages" do
|
48
48
|
@matcher = validate_unique :price, :message => "Hello"
|
49
49
|
@matcher.matches? subject
|
50
|
-
@matcher.failure_message.
|
51
|
-
@matcher.
|
50
|
+
expect( @matcher.failure_message ).to eq "expected Item to " + @matcher.description
|
51
|
+
expect( @matcher.failure_message_when_negated ).to eq "expected Item to not " + @matcher.description
|
52
52
|
end
|
53
53
|
it "should explicit used options if different than expected" do
|
54
54
|
@matcher = validate_unique :name, :message => "Hello world"
|
55
55
|
@matcher.matches? subject
|
56
56
|
explanation = ' but called with option(s) :message => "Hello" instead'
|
57
|
-
@matcher.failure_message.
|
58
|
-
@matcher.
|
57
|
+
expect( @matcher.failure_message ).to eq "expected Item to " + @matcher.description + explanation
|
58
|
+
expect( @matcher.failure_message_when_negated ).to eq "expected Item to not " + @matcher.description + explanation
|
59
59
|
end
|
60
60
|
it "should warn if invalid options are used" do
|
61
61
|
@matcher = validate_unique :name, :allow_nil => true
|
62
62
|
@matcher.matches? subject
|
63
63
|
explanation = " but option :allow_nil is not valid"
|
64
|
-
@matcher.failure_message.
|
65
|
-
@matcher.
|
64
|
+
expect( @matcher.failure_message ).to eq "expected Item to " + @matcher.description + explanation
|
65
|
+
expect( @matcher.failure_message_when_negated ).to eq "expected Item to not " + @matcher.description + explanation
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe "matchers" do
|
71
|
-
it{
|
72
|
-
it{
|
73
|
-
it{
|
74
|
-
it{
|
75
|
-
it{
|
76
|
-
it{
|
71
|
+
it{ is_expected.to validate_unique(:name) }
|
72
|
+
it{ is_expected.to validate_unique([:id, :name]) }
|
73
|
+
it{ is_expected.to validate_unique(:name, :message => "Hello") }
|
74
|
+
it{ is_expected.not_to validate_unique(:id) }
|
75
|
+
it{ is_expected.not_to validate_unique(:price) }
|
76
|
+
it{ is_expected.not_to validate_unique(:name, :allow_nil => true) }
|
77
77
|
end
|
78
78
|
|
79
79
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_sequel_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Tron
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 3.8.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
@@ -40,35 +40,36 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '0'
|
48
|
+
version: '3.0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0'
|
55
|
+
version: '3.0'
|
56
56
|
description:
|
57
57
|
email: team@openhood.com
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files:
|
61
61
|
- LICENSE
|
62
|
-
- README.
|
62
|
+
- README.md
|
63
63
|
files:
|
64
64
|
- LICENSE
|
65
|
-
- README.
|
65
|
+
- README.md
|
66
66
|
- lib/rspec_sequel/association.rb
|
67
67
|
- lib/rspec_sequel/base.rb
|
68
68
|
- lib/rspec_sequel/matchers/have_column.rb
|
69
69
|
- lib/rspec_sequel/matchers/have_many_to_many.rb
|
70
70
|
- lib/rspec_sequel/matchers/have_many_to_one.rb
|
71
71
|
- lib/rspec_sequel/matchers/have_one_to_many.rb
|
72
|
+
- lib/rspec_sequel/matchers/have_one_to_one.rb
|
72
73
|
- lib/rspec_sequel/matchers/validate_exact_length.rb
|
73
74
|
- lib/rspec_sequel/matchers/validate_format.rb
|
74
75
|
- lib/rspec_sequel/matchers/validate_includes.rb
|
@@ -86,9 +87,11 @@ files:
|
|
86
87
|
- spec/have_many_to_many_matcher_spec.rb
|
87
88
|
- spec/have_many_to_one_matcher_spec.rb
|
88
89
|
- spec/have_one_to_many_matcher_spec.rb
|
90
|
+
- spec/have_one_to_one_matcher_spec.rb
|
89
91
|
- spec/migrations/001_create_items.rb
|
90
92
|
- spec/migrations/002_create_comments.rb
|
91
93
|
- spec/migrations/003_create_comments_items.rb
|
94
|
+
- spec/migrations/004_create_profile.rb
|
92
95
|
- spec/spec_helper.rb
|
93
96
|
- spec/validate_exact_length_matcher_spec.rb
|
94
97
|
- spec/validate_format_matcher_spec.rb
|