perpetuity 1.0.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 1a8e9f40c8e01e35ae70dc25cfed9e6e32eaffa8
4
- data.tar.gz: 6115b3220a2c680626351aa1c1bb6626d9da73ed
5
- SHA512:
6
- metadata.gz: a216fe83851f3a6e7b7a6839fd76733dc4695cd7f73219d2d94b6bb159f111ae370e90f7befe837e460b1f40f5ddee0a05be43d0c5d8c9f9b1e7b428d07827fb
7
- data.tar.gz: 015afc0afc78719af382d44610f969b3936204004b57a76fff8bf29069b12997ab47a5ed67d68ac80f4daa7f17f8c66f006cd7da511bf43e454e2705487cc068
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6e9c3b65a81c55bb4d428f51fb6fabff9b144157
4
+ data.tar.gz: 26ba0eb66da443557c77b97d25671bb94fcc7626
5
+ SHA512:
6
+ metadata.gz: 0ec48ea694e54ce58c6b46459db4be816472011fa8a0aae0dffec8c2674703b12eb05c42c4f3c5d5ce429bfe44fdbaffe7acf1792e5719998d5d50155f65f905
7
+ data.tar.gz: 47be19d80852c9de55be009998949b48348787dbc0705b9b11c776a20e5712cea96aad71775e54a6235a231f9ee236bc929384cbcd2fa276211770a9b852c050
@@ -1,3 +1,7 @@
1
+ ## Version 1.0.1
2
+
3
+ - Fix bug that broke saving associated objects when declaring the `id` attribute with Virtus.
4
+
1
5
  ## Version 1.0.0
2
6
 
3
7
  - Invoke identity map when using `mapper.select` and `mapper.find` with a block.
@@ -12,7 +12,7 @@ module Perpetuity
12
12
  end
13
13
 
14
14
  def give_id_to object, *args
15
- if args.any?
15
+ unless args.empty?
16
16
  inject_attribute object, :id, args.first
17
17
  end
18
18
  end
@@ -240,11 +240,11 @@ module Perpetuity
240
240
  end
241
241
 
242
242
  def persisted? object
243
- object.instance_variable_defined?(:@id)
243
+ !!id_for(object)
244
244
  end
245
245
 
246
246
  def id_for object
247
- object.instance_variable_get(:@id) if persisted?(object)
247
+ object.instance_variable_get(:@id)
248
248
  end
249
249
 
250
250
  def data_source
@@ -16,6 +16,14 @@ module Perpetuity
16
16
  [to_param] if persisted?
17
17
  end
18
18
 
19
+ def model_name
20
+ self.class.model_name
21
+ end
22
+
23
+ def to_model
24
+ self
25
+ end
26
+
19
27
  module ActiveModelish
20
28
  def model_name
21
29
  self
@@ -52,6 +60,10 @@ module Perpetuity
52
60
  .gsub(/(\w)([A-Z])/, '\1 \2')
53
61
  end
54
62
  end
63
+
64
+ def i18n_key
65
+ name.gsub(/::/, '.').gsub(/([a-z])([A-Z])/, '\1_\2').downcase
66
+ end
55
67
  end
56
68
  end
57
69
  end
@@ -1,3 +1,3 @@
1
1
  module Perpetuity
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
19
19
 
20
20
  # specify any dependencies here; for example:
21
21
  s.add_development_dependency "rake"
22
- s.add_development_dependency "rspec", "~> 2.13"
22
+ s.add_development_dependency "rspec", "~> 3.0"
23
23
  end
@@ -14,18 +14,19 @@ describe 'associations with other objects' do
14
14
 
15
15
  describe 'referenced relationships' do
16
16
  let(:creator) { topic_mapper.find(topic_mapper.id_for topic).creator }
17
- subject { creator }
18
17
 
19
- it { should be_a Perpetuity::Reference }
20
- its(:klass) { should be User }
21
- its(:id) { should be == user_mapper.id_for(user) }
18
+ it 'stores a reference in the object attribute' do
19
+ expect(creator).to be_a Perpetuity::Reference
20
+ expect(creator.klass).to be User
21
+ expect(creator.id).to eq user_mapper.id_for(user)
22
+ end
22
23
  end
23
24
 
24
25
  it 'can retrieve a one-to-one association' do
25
26
  retrieved_topic = topic_mapper.find(topic_mapper.id_for topic)
26
27
 
27
28
  topic_mapper.load_association! retrieved_topic, :creator
28
- retrieved_topic.creator.name.should eq 'Flump'
29
+ expect(retrieved_topic.creator.name).to eq 'Flump'
29
30
  end
30
31
 
31
32
  describe 'associations with many objects' do
@@ -44,8 +45,8 @@ describe 'associations with other objects' do
44
45
  persisted_book = book_mapper.find(book_mapper.id_for pragprog_book)
45
46
  book_mapper.load_association! persisted_book, :authors
46
47
 
47
- persisted_book.authors.first.name.should be == 'Dave'
48
- persisted_book.authors.last.name.should be == 'Andy'
48
+ expect(persisted_book.authors.first.name).to be == 'Dave'
49
+ expect(persisted_book.authors.last.name).to be == 'Andy'
49
50
  end
50
51
 
51
52
  it 'can retrieve a many-to-many association' do
@@ -55,7 +56,8 @@ describe 'associations with other objects' do
55
56
 
56
57
  books = book_mapper.select { |book| book.id.in book_ids }.to_a
57
58
  book_mapper.load_association! books, :authors
58
- books.map(&:authors).flatten.map(&:name).should include(*%w(Dave Andy Matt Aslak))
59
+ author_names = books.map(&:authors).flatten.map(&:name)
60
+ expect(author_names).to include(*%w(Dave Andy Matt Aslak))
59
61
  end
60
62
 
61
63
  it 'does not try dereferencing non-reference objects' do
@@ -68,7 +70,7 @@ describe 'associations with other objects' do
68
70
  mapper.insert article
69
71
  retrieved = mapper.find(mapper.id_for(article))
70
72
  mapper.load_association! retrieved, :author
71
- retrieved.author.should == [foo, bar]
73
+ expect(retrieved.author).to be == [foo, bar]
72
74
  end
73
75
  end
74
76
 
@@ -87,7 +89,7 @@ describe 'associations with other objects' do
87
89
  it 'serializes attributes' do
88
90
  mapper.insert object
89
91
  attr = mapper.find(mapper.id_for object).embedded_attribute
90
- attr.should be == [unserializable_object]
92
+ expect(attr).to be == [unserializable_object]
91
93
  end
92
94
  end
93
95
  end
@@ -25,7 +25,7 @@ describe "deletion" do
25
25
  it "should delete all objects of a certain class" do
26
26
  Perpetuity[Article].insert Article.new
27
27
  Perpetuity[Article].delete_all
28
- Perpetuity[Article].count.should eq 0
28
+ expect(Perpetuity[Article].count).to eq 0
29
29
  end
30
30
  end
31
31
  end
@@ -13,7 +13,7 @@ describe 'enumerable syntax' do
13
13
  end
14
14
 
15
15
  it 'finds a single object based on criteria' do
16
- mapper.find { |a| a.title == foo.title }.should be == foo
16
+ expect(mapper.find { |a| a.title == foo.title }).to be == foo
17
17
  end
18
18
 
19
19
  context 'excludes objects based on criteria' do
@@ -23,26 +23,26 @@ describe 'enumerable syntax' do
23
23
 
24
24
  it 'excludes on equality' do
25
25
  articles = mapper.reject { |a| a.title == bar.title }.to_a
26
- articles.should include foo
27
- articles.should_not include bar
26
+ expect(articles).to include foo
27
+ expect(articles).not_to include bar
28
28
  end
29
29
 
30
30
  it 'excludes on inequality' do
31
31
  articles = mapper.reject { |a| a.published_at <= current_time }.to_a
32
- articles.should include bar
33
- articles.should_not include foo
32
+ expect(articles).to include bar
33
+ expect(articles).not_to include foo
34
34
  end
35
35
 
36
36
  it 'excludes on not-equal' do
37
37
  articles = mapper.reject { |a| a.title != foo.title }.to_a
38
- articles.should include foo
39
- articles.should_not include bar
38
+ expect(articles).to include foo
39
+ expect(articles).not_to include bar
40
40
  end
41
41
 
42
42
  it 'excludes on regex match' do
43
43
  articles = mapper.reject { |a| a.title =~ /Foo/ }.to_a
44
- articles.should include bar
45
- articles.should_not include foo
44
+ expect(articles).to include bar
45
+ expect(articles).not_to include foo
46
46
  end
47
47
  end
48
48
  end
@@ -30,32 +30,35 @@ describe 'indexing' do
30
30
  after { mapper.data_source.drop_collection Object }
31
31
 
32
32
  it 'adds indexes to database collections/tables' do
33
- name_index.attribute.name.should be == :name
33
+ expect(name_index.attribute.name).to be == :name
34
34
  end
35
35
 
36
36
  it 'verifies that indexes are inactive' do
37
- name_index.should be_inactive
37
+ expect(name_index).to be_inactive
38
38
  end
39
39
 
40
40
  it 'creates indexes' do
41
41
  mapper.reindex!
42
- mapper.data_source.active_indexes(Object).map do |index|
42
+ index_names = mapper.data_source.active_indexes(Object).map do |index|
43
43
  index.attribute.name.to_s
44
- end.should include 'name'
45
- name_index.should be_active
44
+ end
45
+ expect(index_names).to include 'name'
46
+ expect(name_index).to be_active
46
47
  end
47
48
 
48
49
  it 'specifies uniqueness of the index' do
49
- name_index.should be_unique
50
+ expect(name_index).to be_unique
50
51
  end
51
52
 
52
53
  it 'removes other indexes' do
53
54
  mapper.reindex!
54
55
  mapper_without_index = mapper_class_without_index.new
55
56
  mapper_without_index.reindex!
56
- mapper.data_source.active_indexes(Object).any? do |index|
57
+ any_indexes = mapper.data_source.active_indexes(Object).any? do |index|
57
58
  index.attribute.name.to_s == 'name'
58
- end.should be_false
59
+ end
60
+
61
+ expect(any_indexes).to be_falsey
59
62
  end
60
63
  end
61
64
 
@@ -3,25 +3,25 @@ require 'support/test_classes'
3
3
 
4
4
  describe 'pagination' do
5
5
  it 'specifies the page we want' do
6
- Perpetuity[Article].all.should respond_to :page
6
+ expect(Perpetuity[Article].all).to respond_to :page
7
7
  end
8
8
 
9
9
  it 'specify the quantity per page' do
10
- Perpetuity[Article].all.should respond_to :per_page
10
+ expect(Perpetuity[Article].all).to respond_to :per_page
11
11
  end
12
12
 
13
13
  it 'returns an empty set when there is no data for that page' do
14
14
  mapper = Perpetuity[Article]
15
15
  mapper.delete_all
16
16
  data = mapper.all.page(2)
17
- data.should be_empty
17
+ expect(data).to be_empty
18
18
  end
19
19
 
20
20
  it 'specifies per-page quantity' do
21
21
  Perpetuity[Article].delete_all
22
22
  5.times { |i| Perpetuity[Article].insert Article.new i }
23
23
  data = Perpetuity[Article].all.page(3).per_page(2).to_a
24
- data.should have(1).item
24
+ expect(data.size).to be 1
25
25
  end
26
26
  end
27
27
 
@@ -7,28 +7,29 @@ describe 'Persistence' do
7
7
 
8
8
  it "persists an object" do
9
9
  article = Article.new 'I have a title'
10
- mapper.serialize article
11
10
  expect { mapper.insert article }.to change { mapper.count }.by 1
12
- mapper.find(mapper.id_for(article)).title.should eq 'I have a title'
11
+ expect(
12
+ mapper.find(mapper.id_for(article)).title
13
+ ).to eq 'I have a title'
13
14
  end
14
15
 
15
16
  it 'persists multiple objects' do
16
17
  mapper.delete_all
17
18
  articles = 2.times.map { Article.new(SecureRandom.hex) }
18
19
  expect { mapper.insert articles }.to change { mapper.count }.by 2
19
- mapper.all.sort(:title).to_a.should == articles.sort_by(&:title)
20
+ expect(mapper.all.sort(:title).to_a).to be == articles.sort_by(&:title)
20
21
  end
21
22
 
22
23
  it 'returns the id of the persisted object' do
23
24
  article = Article.new
24
- mapper.insert(article).should eq mapper.id_for(article)
25
+ expect(mapper.insert(article)).to eq mapper.id_for(article)
25
26
  end
26
27
 
27
28
  it "gives an id to objects" do
28
29
  article = Article.new
29
30
  mapper.give_id_to article, 1
30
31
 
31
- mapper.id_for(article).should eq 1
32
+ expect(mapper.id_for(article)).to eq 1
32
33
  end
33
34
 
34
35
  it 'persists referenced objects if they are not persisted' do
@@ -37,7 +38,7 @@ describe 'Persistence' do
37
38
  mapper.insert article
38
39
 
39
40
  retrieved = mapper.find(mapper.id_for(article))
40
- mapper.id_for(retrieved.author).should be == mapper.id_for(article.author)
41
+ expect(mapper.id_for(retrieved.author)).to be == mapper.id_for(article.author)
41
42
  end
42
43
 
43
44
  it 'persists arrays of referenced objects if they are not persisted' do
@@ -48,7 +49,7 @@ describe 'Persistence' do
48
49
  mapper.insert book
49
50
 
50
51
  first_author = mapper.find(mapper.id_for book).authors.first
51
- mapper.id_for(first_author).should be == mapper.id_for(authors.first)
52
+ expect(mapper.id_for(first_author)).to be == mapper.id_for(authors.first)
52
53
  end
53
54
 
54
55
  describe 'id injection' do
@@ -56,15 +57,15 @@ describe 'Persistence' do
56
57
 
57
58
  it 'assigns an id to the inserted object' do
58
59
  mapper.insert article
59
- mapper.id_for(article).should_not be_nil
60
+ expect(mapper.id_for(article)).not_to be_nil
60
61
  end
61
62
 
62
63
  it "assigns an id using Mapper.first" do
63
- mapper.id_for(mapper.first).should_not be_nil
64
+ expect(mapper.id_for(mapper.first)).not_to be_nil
64
65
  end
65
66
 
66
67
  it 'assigns an id using Mapper.all.first' do
67
- mapper.id_for(mapper.all.first).should_not be_nil
68
+ expect(mapper.id_for(mapper.all.first)).not_to be_nil
68
69
  end
69
70
  end
70
71
 
@@ -74,7 +75,7 @@ describe 'Persistence' do
74
75
  it 'persists arrays' do
75
76
  article.comments << 1 << 2 << 3
76
77
  mapper.insert article
77
- mapper.find(mapper.id_for article).comments.should eq [1, 2, 3]
78
+ expect(mapper.find(mapper.id_for article).comments).to eq [1, 2, 3]
78
79
  end
79
80
 
80
81
  it 'persists arrays with unserializable objects in them' do
@@ -82,8 +83,8 @@ describe 'Persistence' do
82
83
  article.comments << comment
83
84
  mapper.insert article
84
85
  persisted_comment = mapper.find(mapper.id_for article).comments.first
85
- persisted_comment.should be_a Comment
86
- persisted_comment.body.should eq comment.body
86
+ expect(persisted_comment).to be_a Comment
87
+ expect(persisted_comment.body).to eq comment.body
87
88
  end
88
89
  end
89
90
 
@@ -94,7 +95,7 @@ describe 'Persistence' do
94
95
 
95
96
  it 'saves and retrieves hashes' do
96
97
  user_mapper.insert user
97
- user_mapper.find(user_mapper.id_for user).name.should be == name_hash
98
+ expect(user_mapper.find(user_mapper.id_for user).name).to be == name_hash
98
99
  end
99
100
  end
100
101
 
@@ -103,7 +104,7 @@ describe 'Persistence' do
103
104
  book = Book.new("My Title #{noise}")
104
105
 
105
106
  Perpetuity[Book].insert book
106
- Perpetuity[Book].id_for(book).should eq "my-title-#{noise}"
107
+ expect(Perpetuity[Book].id_for(book)).to eq "my-title-#{noise}"
107
108
  end
108
109
 
109
110
  context 'with namespaced classes' do
@@ -114,7 +115,7 @@ describe 'Persistence' do
114
115
 
115
116
  it 'persists even with colons in the names' do
116
117
  mapper.insert person
117
- mapper.persisted?(person).should be_true
118
+ expect(mapper.persisted?(person)).to be_truthy
118
119
  end
119
120
  end
120
121
  end
@@ -14,9 +14,9 @@ describe "retrieval" do
14
14
  mapper.insert article
15
15
  retrieved = mapper.find(mapper.id_for article)
16
16
 
17
- mapper.id_for(retrieved).should be == mapper.id_for(article)
18
- retrieved.title.should eq article.title
19
- retrieved.body.should eq article.body
17
+ expect(mapper.id_for(retrieved)).to be == mapper.id_for(article)
18
+ expect(retrieved.title).to be == article.title
19
+ expect(retrieved.body).to be == article.body
20
20
  end
21
21
 
22
22
  describe 'sorting' do
@@ -31,25 +31,25 @@ describe "retrieval" do
31
31
 
32
32
  it 'sorts results' do
33
33
  titles = mapper.all.sort(:published_at).map(&:title)
34
- titles.should be == %w(First Second Third)
34
+ expect(titles).to be == %w(First Second Third)
35
35
  end
36
36
 
37
37
  it 'reverse-sorts results' do
38
38
  titles = mapper.all.sort(:published_at).reverse.map(&:title)
39
- titles.should be == %w(Third Second First)
39
+ expect(titles).to be == %w(Third Second First)
40
40
  end
41
41
  end
42
42
 
43
43
  it 'limits result set' do
44
44
  5.times { mapper.insert Article.new }
45
- mapper.all.limit(4).to_a.should have(4).items
45
+ expect(mapper.all.limit(4).to_a.size).to eq 4
46
46
  end
47
47
 
48
48
  it 'counts result set' do
49
49
  title = "Foo #{Time.now.to_f}"
50
50
  mapper = Perpetuity[Article]
51
51
  5.times { mapper.insert Article.new(title) }
52
- mapper.count { |article| article.title == title }.should == 5
52
+ expect(mapper.count { |article| article.title == title }).to be == 5
53
53
  end
54
54
 
55
55
  describe "Array-like syntax" do
@@ -68,57 +68,57 @@ describe "retrieval" do
68
68
  it 'selects objects using equality' do
69
69
  selected = mapper.select { |article| article.title == 'Published' }
70
70
  ids = selected.map { |article| mapper.id_for article }
71
- ids.should include published_id
72
- ids.should_not include draft_id
71
+ expect(ids).to include published_id
72
+ expect(ids).not_to include draft_id
73
73
  end
74
74
 
75
75
  it 'selects objects using greater-than' do
76
76
  selected = mapper.select { |article| article.published_at < Time.now }
77
77
  ids = selected.map { |article| mapper.id_for article }
78
- ids.should include published_id
79
- ids.should_not include draft_id
78
+ expect(ids).to include published_id
79
+ expect(ids).not_to include draft_id
80
80
  end
81
81
 
82
82
  it 'selects objects using greater-than-or-equal' do
83
83
  selected = mapper.select { |article| article.views >= 3 }
84
84
  ids = selected.map { |article| mapper.id_for article }
85
- ids.should include published_id
86
- ids.should_not include draft_id
85
+ expect(ids).to include published_id
86
+ expect(ids).not_to include draft_id
87
87
  end
88
88
 
89
89
  it 'selects objects using less-than' do
90
90
  selected = mapper.select { |article| article.views < 3 }
91
91
  ids = selected.map { |article| mapper.id_for article }
92
- ids.should include draft_id
93
- ids.should_not include published_id
92
+ expect(ids).to include draft_id
93
+ expect(ids).not_to include published_id
94
94
  end
95
95
 
96
96
  it 'selects objects using less-than-or-equal' do
97
97
  selected = mapper.select { |article| article.views <= 0 }
98
98
  ids = selected.map { |article| mapper.id_for article }
99
- ids.should include draft_id
100
- ids.should_not include published_id
99
+ expect(ids).to include draft_id
100
+ expect(ids).not_to include published_id
101
101
  end
102
102
 
103
103
  it 'selects objects using inequality' do
104
104
  selected = mapper.select { |article| article.title != 'Draft' }
105
105
  ids = selected.map { |article| mapper.id_for article }
106
- ids.should_not include draft_id
107
- ids.should include published_id
106
+ expect(ids).not_to include draft_id
107
+ expect(ids).to include published_id
108
108
  end
109
109
 
110
110
  it 'selects objects using regular expressions' do
111
111
  selected = mapper.select { |article| article.title =~ /Pub/ }
112
112
  ids = selected.map { |article| mapper.id_for article }
113
- ids.should include published_id
114
- ids.should_not include draft_id
113
+ expect(ids).to include published_id
114
+ expect(ids).not_to include draft_id
115
115
  end
116
116
 
117
117
  it 'selects objects using inclusion' do
118
118
  selected = mapper.select { |article| article.title.in %w( Published ) }
119
119
  ids = selected.map { |article| mapper.id_for article }
120
- ids.should include published_id
121
- ids.should_not include draft_id
120
+ expect(ids).to include published_id
121
+ expect(ids).not_to include draft_id
122
122
  end
123
123
  end
124
124
 
@@ -134,9 +134,9 @@ describe "retrieval" do
134
134
  selected = mapper.select { |article| article.title }
135
135
  ids = selected.map { |article| mapper.id_for(article) }
136
136
 
137
- ids.should include truthy_id
138
- ids.should_not include false_id
139
- ids.should_not include nil_id
137
+ expect(ids).to include truthy_id
138
+ expect(ids).not_to include false_id
139
+ expect(ids).not_to include nil_id
140
140
  end
141
141
  end
142
142
 
@@ -152,32 +152,32 @@ describe "retrieval" do
152
152
 
153
153
  it 'counts the results' do
154
154
  query = mapper.select { |article| article.title == title }
155
- query.count.should == 2
155
+ expect(query.count).to be == 2
156
156
  end
157
157
 
158
158
  it 'checks whether any results match' do
159
- mapper.any? { |article| article.title == title }.should be_true
160
- mapper.any? { |article| article.title == SecureRandom.hex }.should be_false
159
+ expect(mapper.any? { |article| article.title == title }).to be_truthy
160
+ expect(mapper.any? { |article| article.title == SecureRandom.hex }).to be_falsey
161
161
  end
162
162
 
163
163
  it 'checks whether all results match' do
164
164
  mapper.delete_all
165
165
  2.times { |i| mapper.insert Article.new(title, nil, nil, nil, i) }
166
- mapper.all? { |article| article.title == title }.should be_true
167
- mapper.all? { |article| article.views == 0 }.should be_false
166
+ expect(mapper.all? { |article| article.title == title }).to be_truthy
167
+ expect(mapper.all? { |article| article.views == 0 }).to be_falsey
168
168
  end
169
169
 
170
170
  it 'checks whether only one result matches' do
171
171
  unique_title = SecureRandom.hex
172
172
  mapper.insert Article.new(unique_title)
173
- mapper.one? { |article| article.title == unique_title }.should be_true
174
- mapper.one? { |article| article.title == title }.should be_false
175
- mapper.one? { |article| article.title == 'Title' }.should be_false
173
+ expect(mapper.one? { |article| article.title == unique_title }).to be_truthy
174
+ expect(mapper.one? { |article| article.title == title }).to be_falsey
175
+ expect(mapper.one? { |article| article.title == 'Title' }).to be_falsey
176
176
  end
177
177
 
178
178
  it 'checks whether no results match' do
179
- mapper.none? { |article| article.title == SecureRandom.hex }.should be_true
180
- mapper.none? { |article| article.title == title }.should be_false
179
+ expect(mapper.none? { |article| article.title == SecureRandom.hex }).to be_truthy
180
+ expect(mapper.none? { |article| article.title == title }).to be_falsey
181
181
  end
182
182
  end
183
183
 
@@ -191,7 +191,7 @@ describe "retrieval" do
191
191
  mapper.insert article
192
192
  retrieved_article = mapper.find(mapper.id_for article)
193
193
  mapper.load_association! retrieved_article, :author
194
- retrieved_article.author.should be_a CRM::Person
194
+ expect(retrieved_article.author).to be_a CRM::Person
195
195
  end
196
196
  end
197
197
 
@@ -201,8 +201,8 @@ describe "retrieval" do
201
201
  articles.each { |article| mapper.insert article }
202
202
 
203
203
  ret = mapper.select { |article| article.title == title }.drop(2).sort(:id).to_a
204
- ret.should have(1).items
205
- ret.first.should == articles.last
204
+ expect(ret.size).to eq 1
205
+ expect(ret.first).to be == articles.last
206
206
  end
207
207
 
208
208
  describe 'selecting random objects' do
@@ -211,7 +211,7 @@ describe "retrieval" do
211
211
  articles = 3.times.map { Article.new(SecureRandom.hex) }
212
212
  articles.each { |article| mapper.insert article }
213
213
 
214
- articles.should include mapper.sample
214
+ expect(articles).to include mapper.sample
215
215
  end
216
216
  end
217
217
 
@@ -220,8 +220,8 @@ describe "retrieval" do
220
220
  id = mapper.insert Article.new(fake_title)
221
221
 
222
222
  retrieved = mapper.find(id)
223
- retrieved.title.should be_a String
224
- retrieved.title.should == fake_title
223
+ expect(retrieved.title).to be_a String
224
+ expect(retrieved.title).to be == fake_title
225
225
  end
226
226
 
227
227
  describe 'Enumerable methods within queries' do
@@ -239,14 +239,14 @@ describe "retrieval" do
239
239
 
240
240
  it 'checks for the existence of attributes in an array' do
241
241
  results = mapper.select { |article| article.comments.any? }.to_a
242
- results.should include article_with_comments
243
- results.should_not include article_without_comments
242
+ expect(results).to include article_with_comments
243
+ expect(results).not_to include article_without_comments
244
244
  end
245
245
 
246
246
  it 'checks that an array has no elements' do
247
247
  results = mapper.select { |article| article.comments.none? }.to_a
248
- results.should include article_without_comments
249
- results.should_not include article_with_comments
248
+ expect(results).to include article_without_comments
249
+ expect(results).not_to include article_with_comments
250
250
  end
251
251
  end
252
252
 
@@ -254,13 +254,13 @@ describe "retrieval" do
254
254
  let(:id) { mapper.insert Article.new }
255
255
 
256
256
  it 'returns the same object when requested with the same id' do
257
- mapper.find(id).should be mapper.find(id)
257
+ expect(mapper.find(id)).to be mapper.find(id)
258
258
  end
259
259
 
260
260
  it 'returns the same object when requested with a block' do
261
261
  first = mapper.find { |article| article.id == id }
262
262
  second = mapper.find { |article| article.id == id }
263
- first.should be second
263
+ expect(first).to be second
264
264
  end
265
265
  end
266
266
  end