sequel_spec 0.1.0 → 0.1.1
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 +2 -1
- data/README.md +4 -0
- data/lib/sequel_spec/association/have_many_through_many_matcher.rb +15 -0
- data/lib/sequel_spec/association.rb +2 -0
- data/lib/sequel_spec/version.rb +1 -1
- data/spec/sequel_spec/association/have_many_through_many_matcher_spec.rb +63 -0
- data/spec/sequel_spec/association/have_many_to_many_matcher_spec.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cc55d801d8460a333aec9a8a6e615060def64cb
|
4
|
+
data.tar.gz: f777ca9fdb5a21a4da44f42aa79848db8210315a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2d90a2402dc7fd5e1e679e9d23f1246b52b3f96ef3a6337cbf04146071d5b1cbf872679962265732b34ea7e2b75ff0c62c7856dd1b1e882588e55ea6f768dce
|
7
|
+
data.tar.gz: e48d8533c4b7238da88c7c8f98afc44337962a56ef58fa33090ff35d4ced2345b4c31805d9f7d273b0a8a7472dd9c6a424050ce420c7f99130e6940be93eecb7
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -89,3 +89,7 @@ it { should validate_length_of(:name).is(20).with_message "Name should be 20 cha
|
|
89
89
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
90
90
|
4. Push to the branch (`git push origin my-new-feature`)
|
91
91
|
5. Create new Pull Request
|
92
|
+
|
93
|
+
## Credits
|
94
|
+
|
95
|
+
* Jonathan Tron and Joseph Halter for the original [rspec_sequel_matchers](https://github.com/openhood/rspec_sequel_matchers) code
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SequelSpec
|
2
|
+
module Matchers
|
3
|
+
module Association
|
4
|
+
class HaveManyThroughManyMatcher < AssociationMatcher
|
5
|
+
def association_type
|
6
|
+
:many_through_many
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def have_many_through_many(*args)
|
11
|
+
HaveManyThroughManyMatcher.new(*args)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -4,6 +4,8 @@ require 'sequel_spec/association/have_many_to_one_matcher'
|
|
4
4
|
require 'sequel_spec/association/have_one_to_many_matcher'
|
5
5
|
require 'sequel_spec/association/have_one_to_one_matcher'
|
6
6
|
require 'sequel_spec/association/have_one_through_one_matcher'
|
7
|
+
require 'sequel_spec/association/have_many_through_many_matcher'
|
8
|
+
|
7
9
|
|
8
10
|
module SequelSpec
|
9
11
|
module Matchers
|
data/lib/sequel_spec/version.rb
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "have_many_through_many_matcher" do
|
4
|
+
before :all do
|
5
|
+
define_model :comment
|
6
|
+
define_model :comments_items
|
7
|
+
define_model :item do
|
8
|
+
plugin :many_through_many
|
9
|
+
many_through_many :comments, [
|
10
|
+
[:comments_items, :item_id, :comment_id],
|
11
|
+
[:comments, :id, :id]
|
12
|
+
], join_table: :comments_items
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
subject{ Item }
|
17
|
+
|
18
|
+
describe "messages" do
|
19
|
+
describe "without option" do
|
20
|
+
it "should contain a description" do
|
21
|
+
@matcher = have_many_through_many :comments
|
22
|
+
@matcher.description.should == "have a many_through_many association :comments"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should set failure messages" do
|
26
|
+
@matcher = have_many_through_many :comments
|
27
|
+
@matcher.matches? subject
|
28
|
+
@matcher.failure_message.should == "expected Item to " + @matcher.description
|
29
|
+
@matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "with options" do
|
34
|
+
it "should contain a description" do
|
35
|
+
@matcher = have_many_through_many(:comments).with_options :join_table => :comments_items
|
36
|
+
@matcher.description.should == 'have a many_through_many association :comments with option(s) :join_table => :comments_items'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should set failure messages" do
|
40
|
+
@matcher = have_many_through_many(:comments).with_options :class_name => "Comment"
|
41
|
+
@matcher.matches? subject
|
42
|
+
@matcher.failure_message.should == "expected Item to " + @matcher.description
|
43
|
+
@matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should explicit used options if different than expected" do
|
47
|
+
@matcher = have_many_through_many(:comments).with_options :join_table => :whatever
|
48
|
+
@matcher.matches? subject
|
49
|
+
explanation = ' expected :join_table == :whatever but found :comments_items instead'
|
50
|
+
@matcher.failure_message.should == "expected Item to " + @matcher.description + explanation
|
51
|
+
@matcher.negative_failure_message.should == "expected Item to not " + @matcher.description + explanation
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "matchers" do
|
57
|
+
it{ should have_many_through_many(:comments) }
|
58
|
+
it{ should have_many_through_many(:comments).with_options :join_table => :comments_items }
|
59
|
+
it{ should_not have_many_through_many(:prices) }
|
60
|
+
it{ should_not have_many_through_many(:comments).with_options :class_name => "Price" }
|
61
|
+
it{ should_not have_many_through_many(:comments).with_options :join_table => :items_comments }
|
62
|
+
end
|
63
|
+
end
|
@@ -24,6 +24,7 @@ describe "have_many_to_many_matcher" do
|
|
24
24
|
@matcher.negative_failure_message.should == "expected Comment to not " + @matcher.description
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
27
28
|
describe "with options" do
|
28
29
|
it "should contain a description" do
|
29
30
|
@matcher = have_many_to_many(:items).with_options :class_name => "Item"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrià Planas
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-03-
|
13
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sequel
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/sequel_spec.rb
|
99
99
|
- lib/sequel_spec/association.rb
|
100
100
|
- lib/sequel_spec/association/association_matcher.rb
|
101
|
+
- lib/sequel_spec/association/have_many_through_many_matcher.rb
|
101
102
|
- lib/sequel_spec/association/have_many_to_many_matcher.rb
|
102
103
|
- lib/sequel_spec/association/have_many_to_one_matcher.rb
|
103
104
|
- lib/sequel_spec/association/have_one_through_one_matcher.rb
|
@@ -120,6 +121,7 @@ files:
|
|
120
121
|
- lib/sequel_spec/version.rb
|
121
122
|
- sequel_spec.gemspec
|
122
123
|
- spec/migrations/001_create_tables.rb
|
124
|
+
- spec/sequel_spec/association/have_many_through_many_matcher_spec.rb
|
123
125
|
- spec/sequel_spec/association/have_many_to_many_matcher_spec.rb
|
124
126
|
- spec/sequel_spec/association/have_many_to_one_matcher_spec.rb
|
125
127
|
- spec/sequel_spec/association/have_one_through_one_matcher_spec.rb
|