blob: 6f0407b2eb5b9715b1e67f8b1bf1a8c368f9c610 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
require 'rails_helper'
describe User::Repository do
subject { User::Repository.new }
describe "#all" do
let!(:user) { create(:user) }
it 'returns all the users' do
expect(subject.all).to include(user)
end
end
describe "#ordered" do
let!(:first_person) { create(:user, creations_count: 0) }
let!(:second_person) { create(:user, creations_count: 1) }
let(:results) { subject.ordered }
it "should load the person with the most cakes first" do
expect(results.first).to eql(second_person)
end
it "should load the person with the least cakes last" do
expect(results.last).to eql(first_person)
end
end
describe "#search_by" do
let!(:mo) { create(:user) }
let!(:bob) { create(:user) }
it "returns a user that has a matching email address" do
results = subject.search_by(mo.email)
expect(results).to include(mo)
expect(results).to_not include(bob)
end
it "returns a user that has a matching name" do
results = subject.search_by(bob.name)
expect(results).to include(bob)
expect(results).to_not include(mo)
end
end
describe "#search_with" do
let!(:mo) { create(:user, creations_count: 1) }
let!(:bob) { create(:user, creations_count: 1) }
it 'returns all artists with the matching name' do
results = subject.search_with(q: bob.name)
expect(results).to include(bob)
expect(results).to_not include(mo)
end
end
end
|