follow_system 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.empty +0 -0
- data/.gitignore +15 -0
- data/.keep +0 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +23 -0
- data/Appraisals +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +93 -0
- data/Rakefile +8 -0
- data/follow_system.gemspec +31 -0
- data/gemfiles/.empty +0 -0
- data/gemfiles/.gitignore +0 -0
- data/gemfiles/.keep +0 -0
- data/gemfiles/rails4.1.gemfile +7 -0
- data/gemfiles/rails4.2.gemfile +7 -0
- data/lib/.empty +0 -0
- data/lib/.gitignore +0 -0
- data/lib/.keep +0 -0
- data/lib/follow_system/.empty +0 -0
- data/lib/follow_system/.gitignore +0 -0
- data/lib/follow_system/.keep +0 -0
- data/lib/follow_system/follow.rb +155 -0
- data/lib/follow_system/followee.rb +58 -0
- data/lib/follow_system/follower.rb +88 -0
- data/lib/follow_system/version.rb +12 -0
- data/lib/follow_system.rb +45 -0
- data/lib/generators/.empty +0 -0
- data/lib/generators/.gitignore +0 -0
- data/lib/generators/.keep +0 -0
- data/lib/generators/follow_system/.empty +0 -0
- data/lib/generators/follow_system/.gitignore +0 -0
- data/lib/generators/follow_system/.keep +0 -0
- data/lib/generators/follow_system/follow_system_generator.rb +46 -0
- data/lib/generators/follow_system/templates/.empty +0 -0
- data/lib/generators/follow_system/templates/.gitignore +0 -0
- data/lib/generators/follow_system/templates/.keep +0 -0
- data/lib/generators/follow_system/templates/migration.rb +47 -0
- data/spec/.empty +0 -0
- data/spec/.gitignore +0 -0
- data/spec/.keep +0 -0
- data/spec/db/.empty +0 -0
- data/spec/db/.gitignore +0 -0
- data/spec/db/.keep +0 -0
- data/spec/db/migrate/.empty +0 -0
- data/spec/db/migrate/.gitignore +0 -0
- data/spec/db/migrate/.keep +0 -0
- data/spec/db/migrate/20140926000000_create_follows.rb +47 -0
- data/spec/db/migrate/20140926000005_create_dummy_followers.rb +22 -0
- data/spec/db/migrate/20140926000010_create_dummy_followees.rb +22 -0
- data/spec/follow_system/.empty +0 -0
- data/spec/follow_system/.gitignore +0 -0
- data/spec/follow_system/.keep +0 -0
- data/spec/follow_system/follow_spec.rb +177 -0
- data/spec/follow_system/followee_spec.rb +69 -0
- data/spec/follow_system/follower_spec.rb +96 -0
- data/spec/spec_helper.rb +116 -0
- data/spec/support/.empty +0 -0
- data/spec/support/.gitignore +0 -0
- data/spec/support/.keep +0 -0
- data/spec/support/active_record.rb +12 -0
- data/spec/support/shoulda_matchers.rb +2 -0
- metadata +237 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
require 'rails/generators/active_record'
|
3
|
+
|
4
|
+
###
|
5
|
+
# FollowSystemGenerator class
|
6
|
+
#
|
7
|
+
# This class generates the follow model migration in follow system
|
8
|
+
###
|
9
|
+
class FollowSystemGenerator < Rails::Generators::Base
|
10
|
+
###
|
11
|
+
# Includes Rails::Generators::Migration
|
12
|
+
###
|
13
|
+
include Rails::Generators::Migration
|
14
|
+
|
15
|
+
###
|
16
|
+
# Generator description definition
|
17
|
+
###
|
18
|
+
desc "Generates a migration for the Follow model"
|
19
|
+
|
20
|
+
###
|
21
|
+
# Retrieves the source root
|
22
|
+
#
|
23
|
+
# @return [String]
|
24
|
+
###
|
25
|
+
def self.source_root
|
26
|
+
@source_root ||= File.dirname(__FILE__) + '/templates'
|
27
|
+
end
|
28
|
+
|
29
|
+
###
|
30
|
+
# Retrieves the next migration number
|
31
|
+
#
|
32
|
+
# @path [String] path - the path to calculate the next migration number
|
33
|
+
# @return [String]
|
34
|
+
###
|
35
|
+
def self.next_migration_number(path)
|
36
|
+
ActiveRecord::Generators::Base.next_migration_number(path)
|
37
|
+
end
|
38
|
+
|
39
|
+
###
|
40
|
+
# Generates the migration
|
41
|
+
###
|
42
|
+
def generate_migration
|
43
|
+
migration_template 'migration.rb', 'db/migrate/create_follows.rb'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,47 @@
|
|
1
|
+
###
|
2
|
+
# CreateFollows class
|
3
|
+
#
|
4
|
+
# This class defines the create follows migration in follow system
|
5
|
+
###
|
6
|
+
class CreateFollows < ActiveRecord::Migration
|
7
|
+
###
|
8
|
+
# Changes the database
|
9
|
+
###
|
10
|
+
def change
|
11
|
+
###
|
12
|
+
# Follows table creation
|
13
|
+
###
|
14
|
+
create_table :follows do |t|
|
15
|
+
###
|
16
|
+
# Followee id field and followee type field definition
|
17
|
+
###
|
18
|
+
t.references :followee, polymorphic: true
|
19
|
+
|
20
|
+
###
|
21
|
+
# Follower id fiel and follower type field definition
|
22
|
+
###
|
23
|
+
t.references :follower, polymorphic: true
|
24
|
+
|
25
|
+
###
|
26
|
+
# Timestamps fields definition
|
27
|
+
###
|
28
|
+
t.timestamps null: false
|
29
|
+
end
|
30
|
+
|
31
|
+
###
|
32
|
+
# Follows table followee id field and followee type field index addition
|
33
|
+
###
|
34
|
+
add_index :follows, [:followee_id, :followee_type], name: "follows_followee_idx"
|
35
|
+
|
36
|
+
###
|
37
|
+
# Follows table follower id field and follower type field index addition
|
38
|
+
###
|
39
|
+
add_index :follows, [:follower_id, :follower_type], name: "follows_follower_idx"
|
40
|
+
|
41
|
+
###
|
42
|
+
# Follows table followee id field and followee type field and follower id field and follower type field unique index addition
|
43
|
+
###
|
44
|
+
add_index :follows, [:followee_id, :followee_type, :follower_id, :follower_type], name: "follows_followee_follower_idx", unique: true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
data/spec/.empty
ADDED
File without changes
|
data/spec/.gitignore
ADDED
File without changes
|
data/spec/.keep
ADDED
File without changes
|
data/spec/db/.empty
ADDED
File without changes
|
data/spec/db/.gitignore
ADDED
File without changes
|
data/spec/db/.keep
ADDED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,47 @@
|
|
1
|
+
###
|
2
|
+
# CreateFollows class
|
3
|
+
#
|
4
|
+
# This class defines the test create follows migration in follow system
|
5
|
+
###
|
6
|
+
class CreateFollows < ActiveRecord::Migration
|
7
|
+
###
|
8
|
+
# Changes the database
|
9
|
+
###
|
10
|
+
def change
|
11
|
+
###
|
12
|
+
# Follows table creation
|
13
|
+
###
|
14
|
+
create_table :follows do |t|
|
15
|
+
###
|
16
|
+
# Followee id field and followee type field definition
|
17
|
+
###
|
18
|
+
t.references :followee, polymorphic: true
|
19
|
+
|
20
|
+
###
|
21
|
+
# Follower id fiel and follower type field definition
|
22
|
+
###
|
23
|
+
t.references :follower, polymorphic: true
|
24
|
+
|
25
|
+
###
|
26
|
+
# Timestamps fields definition
|
27
|
+
###
|
28
|
+
t.timestamps null: false
|
29
|
+
end
|
30
|
+
|
31
|
+
###
|
32
|
+
# Follows table followee id field and followee type field index addition
|
33
|
+
###
|
34
|
+
add_index :follows, [:followee_id, :followee_type], name: "follows_followee_idx"
|
35
|
+
|
36
|
+
###
|
37
|
+
# Follows table follower id field and follower type field index addition
|
38
|
+
###
|
39
|
+
add_index :follows, [:follower_id, :follower_type], name: "follows_follower_idx"
|
40
|
+
|
41
|
+
###
|
42
|
+
# Follows table followee id field and followee type field and follower id field and follower type field unique index addition
|
43
|
+
###
|
44
|
+
add_index :follows, [:followee_id, :followee_type, :follower_id, :follower_type], name: "follows_followee_follower_idx", unique: true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
###
|
2
|
+
# CreateDummyFollowers class
|
3
|
+
#
|
4
|
+
# This class defines the create dummy followers migration in follow system
|
5
|
+
###
|
6
|
+
class CreateDummyFollowers < ActiveRecord::Migration
|
7
|
+
###
|
8
|
+
# Changes the database
|
9
|
+
###
|
10
|
+
def change
|
11
|
+
###
|
12
|
+
# Dummy followers table creation
|
13
|
+
###
|
14
|
+
create_table :dummy_followers do |t|
|
15
|
+
###
|
16
|
+
# Timestamps fields definition
|
17
|
+
###
|
18
|
+
t.timestamps null: false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
###
|
2
|
+
# CreateDummyFollowees class
|
3
|
+
#
|
4
|
+
# This class defines the create dummy followees migration in follow system
|
5
|
+
###
|
6
|
+
class CreateDummyFollowees < ActiveRecord::Migration
|
7
|
+
###
|
8
|
+
# Changes the database
|
9
|
+
###
|
10
|
+
def change
|
11
|
+
###
|
12
|
+
# Dummy followees table creation
|
13
|
+
###
|
14
|
+
create_table :dummy_followees do |t|
|
15
|
+
###
|
16
|
+
# Timestamps fields definition
|
17
|
+
###
|
18
|
+
t.timestamps null: false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
###
|
4
|
+
# Describes FollowSystem::Follow
|
5
|
+
###
|
6
|
+
describe FollowSystem::Follow do
|
7
|
+
###
|
8
|
+
# Let followee be DummyFollowee.create
|
9
|
+
###
|
10
|
+
let(:followee) { DummyFollowee.create }
|
11
|
+
|
12
|
+
###
|
13
|
+
# Let follower be DummyFollower.create
|
14
|
+
###
|
15
|
+
let(:follower) { DummyFollower.create }
|
16
|
+
|
17
|
+
###
|
18
|
+
# Describes associations
|
19
|
+
###
|
20
|
+
describe "associations" do
|
21
|
+
###
|
22
|
+
# Should belong to followee
|
23
|
+
###
|
24
|
+
it "should belong to followee" do
|
25
|
+
should belong_to(:followee)
|
26
|
+
end
|
27
|
+
|
28
|
+
###
|
29
|
+
# Should belong to follower
|
30
|
+
###
|
31
|
+
it "should belong to follower" do
|
32
|
+
should belong_to(:follower)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
###
|
37
|
+
# Describes class methods
|
38
|
+
###
|
39
|
+
describe "class methods" do
|
40
|
+
###
|
41
|
+
# Should raise argument error on invalid followee when follows
|
42
|
+
###
|
43
|
+
it "should raise argument error on invalid followee when follows" do
|
44
|
+
expect { FollowSystem::Follow.follow(follower, follower) }.to raise_error ArgumentError
|
45
|
+
end
|
46
|
+
|
47
|
+
###
|
48
|
+
# Should raise argument error on invalid follower when follows
|
49
|
+
###
|
50
|
+
it "should raise argument error on invalid follower when follows " do
|
51
|
+
expect { FollowSystem::Follow.follow(followee, followee) }.to raise_error ArgumentError
|
52
|
+
end
|
53
|
+
|
54
|
+
###
|
55
|
+
# Should follow
|
56
|
+
###
|
57
|
+
it "should follow" do
|
58
|
+
expect(FollowSystem::Follow.follow(follower, followee)).to equal(true)
|
59
|
+
end
|
60
|
+
|
61
|
+
###
|
62
|
+
# Should not follow
|
63
|
+
###
|
64
|
+
it "should not follow" do
|
65
|
+
FollowSystem::Follow.follow(follower, followee)
|
66
|
+
|
67
|
+
expect(FollowSystem::Follow.follow(follower, followee)).to equal(false)
|
68
|
+
end
|
69
|
+
|
70
|
+
###
|
71
|
+
# Should raise argument error on invalid followee when unfollows
|
72
|
+
###
|
73
|
+
it "should raise argument error on invalid followee when unfollows" do
|
74
|
+
expect { FollowSystem::Follow.unfollow(follower, follower) }.to raise_error ArgumentError
|
75
|
+
end
|
76
|
+
|
77
|
+
###
|
78
|
+
# Should raise argument error on invalid follower when unfollows
|
79
|
+
###
|
80
|
+
it "should raise argument error on invalid follower when unfollows" do
|
81
|
+
expect { FollowSystem::Follow.unfollow(followee, followee) }.to raise_error ArgumentError
|
82
|
+
end
|
83
|
+
|
84
|
+
###
|
85
|
+
# Should unfollow
|
86
|
+
###
|
87
|
+
it "should unfollow" do
|
88
|
+
FollowSystem::Follow.follow(follower, followee)
|
89
|
+
|
90
|
+
expect(FollowSystem::Follow.unfollow(follower, followee)).to equal(true)
|
91
|
+
end
|
92
|
+
|
93
|
+
###
|
94
|
+
# Should not unfollow
|
95
|
+
###
|
96
|
+
it "should not unfollow" do
|
97
|
+
expect(FollowSystem::Follow.unfollow(follower, followee)).to equal(false)
|
98
|
+
end
|
99
|
+
|
100
|
+
###
|
101
|
+
# Should raise argument error on invalid followee when toggle follow
|
102
|
+
###
|
103
|
+
it "should raise argument error on invalid followee when toggle follow" do
|
104
|
+
expect { FollowSystem::Follow.toggle_follow(follower, follower) }.to raise_error ArgumentError
|
105
|
+
end
|
106
|
+
|
107
|
+
###
|
108
|
+
# Should raise argument error on invalid follower when toggle follow
|
109
|
+
###
|
110
|
+
it "should raise argument error on invalid follower when toggle follow" do
|
111
|
+
expect { FollowSystem::Follow.toggle_follow(followee, followee) }.to raise_error ArgumentError
|
112
|
+
end
|
113
|
+
|
114
|
+
###
|
115
|
+
# Should toggle follow
|
116
|
+
###
|
117
|
+
it "should toggle follow" do
|
118
|
+
expect(FollowSystem::Follow.follows?(follower, followee)).to equal(false)
|
119
|
+
|
120
|
+
FollowSystem::Follow.toggle_follow(follower, followee)
|
121
|
+
|
122
|
+
expect(FollowSystem::Follow.follows?(follower, followee)).to equal(true)
|
123
|
+
|
124
|
+
FollowSystem::Follow.toggle_follow(follower, followee)
|
125
|
+
|
126
|
+
expect(FollowSystem::Follow.follows?(follower, followee)).to equal(false)
|
127
|
+
end
|
128
|
+
|
129
|
+
###
|
130
|
+
# Should specify if follows
|
131
|
+
###
|
132
|
+
it "should specify if follows" do
|
133
|
+
expect(FollowSystem::Follow.follows?(follower, followee)).to equal(false)
|
134
|
+
|
135
|
+
FollowSystem::Follow.follow(follower, followee)
|
136
|
+
|
137
|
+
expect(FollowSystem::Follow.follows?(follower, followee)).to equal(true)
|
138
|
+
end
|
139
|
+
|
140
|
+
###
|
141
|
+
# Should scope follows by followee
|
142
|
+
###
|
143
|
+
it "should scope follows by followee" do
|
144
|
+
scope = FollowSystem::Follow.where(followee: followee)
|
145
|
+
|
146
|
+
expect(FollowSystem::Follow.scope_by_followee(followee)).to eq(scope)
|
147
|
+
end
|
148
|
+
|
149
|
+
###
|
150
|
+
# Should scope follows by followee type
|
151
|
+
####
|
152
|
+
it "should scope follows by followee type" do
|
153
|
+
scope = FollowSystem::Follow.where(followee_type: DummyFollowee)
|
154
|
+
|
155
|
+
expect(FollowSystem::Follow.scope_by_followee_type(DummyFollowee)).to eq(scope)
|
156
|
+
end
|
157
|
+
|
158
|
+
###
|
159
|
+
# Should scope follows by follower
|
160
|
+
###
|
161
|
+
it "should scope follows by follower" do
|
162
|
+
scope = FollowSystem::Follow.where(follower: follower)
|
163
|
+
|
164
|
+
expect(FollowSystem::Follow.scope_by_follower(follower)).to eq(scope)
|
165
|
+
end
|
166
|
+
|
167
|
+
###
|
168
|
+
# Should scope follows by follower type
|
169
|
+
####
|
170
|
+
it "should scope follows by follower type" do
|
171
|
+
scope = FollowSystem::Follow.where(follower_type: DummyFollower)
|
172
|
+
|
173
|
+
expect(FollowSystem::Follow.scope_by_follower_type(DummyFollower)).to eq(scope)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
###
|
4
|
+
# Shared examples for FollowSystem::Followee
|
5
|
+
###
|
6
|
+
shared_examples_for FollowSystem::Followee do
|
7
|
+
###
|
8
|
+
# Let followee be DummyFollowee.create
|
9
|
+
###
|
10
|
+
let(:followee) { DummyFollowee.create }
|
11
|
+
|
12
|
+
###
|
13
|
+
# Let follower be DummyFollower.create
|
14
|
+
###
|
15
|
+
let(:follower) { DummyFollower.create }
|
16
|
+
|
17
|
+
###
|
18
|
+
# Describes associations
|
19
|
+
###
|
20
|
+
describe "associations" do
|
21
|
+
###
|
22
|
+
# Should have many followers
|
23
|
+
###
|
24
|
+
it "should have many followers" do
|
25
|
+
should have_many(:followers)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
###
|
30
|
+
# Describes class methods
|
31
|
+
###
|
32
|
+
describe "class methods" do
|
33
|
+
###
|
34
|
+
# Should be a followee
|
35
|
+
###
|
36
|
+
it "should be a followee" do
|
37
|
+
expect(followee.is_followee?).to equal(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
###
|
41
|
+
# Should be followed by a follower
|
42
|
+
###
|
43
|
+
it "should specify if is followed by a follower" do
|
44
|
+
expect(FollowSystem::Follow).to receive(:follows?).with(follower, followee) { true }
|
45
|
+
|
46
|
+
expect(followee.followed_by?(follower)).to equal(true)
|
47
|
+
end
|
48
|
+
|
49
|
+
###
|
50
|
+
# Should scope followers filtered by follower type
|
51
|
+
###
|
52
|
+
it "should scope followers filtered by follower type" do
|
53
|
+
scope = FollowSystem::Follow.scope_by_followee(followee).scope_by_follower_type(DummyFollower)
|
54
|
+
|
55
|
+
expect(followee.followers_by(DummyFollower)).to eq(scope)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
###
|
61
|
+
# Describes DummyFollowee
|
62
|
+
###
|
63
|
+
describe DummyFollowee do
|
64
|
+
###
|
65
|
+
# It behaves like FollowSystem::Followee
|
66
|
+
###
|
67
|
+
it_behaves_like FollowSystem::Followee
|
68
|
+
end
|
69
|
+
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
###
|
4
|
+
# Shared examples for FollowSystem::Follower
|
5
|
+
###
|
6
|
+
shared_examples_for FollowSystem::Follower do
|
7
|
+
###
|
8
|
+
# Let followee be DummyFollowee.create
|
9
|
+
###
|
10
|
+
let(:followee) { DummyFollowee.create }
|
11
|
+
|
12
|
+
###
|
13
|
+
# Let follower be DummyFollower.create
|
14
|
+
###
|
15
|
+
let(:follower) { DummyFollower.create }
|
16
|
+
|
17
|
+
###
|
18
|
+
# Describes associations
|
19
|
+
###
|
20
|
+
describe "associations" do
|
21
|
+
###
|
22
|
+
# Should have many followees
|
23
|
+
###
|
24
|
+
it "should have many followees" do
|
25
|
+
should have_many(:followees)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
###
|
30
|
+
# Describes class methods
|
31
|
+
###
|
32
|
+
describe "class methods" do
|
33
|
+
###
|
34
|
+
# Should be a follower
|
35
|
+
###
|
36
|
+
it "should be a follower" do
|
37
|
+
expect(follower.is_follower?).to equal(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
###
|
41
|
+
# Should follow a followee
|
42
|
+
###
|
43
|
+
it "Should follow a followee" do
|
44
|
+
expect(FollowSystem::Follow).to receive(:follow).with(follower, followee) { true }
|
45
|
+
|
46
|
+
expect(follower.follow(followee)).to equal(true)
|
47
|
+
end
|
48
|
+
|
49
|
+
###
|
50
|
+
# Should unfollow a followee
|
51
|
+
###
|
52
|
+
it "Should unfollow a followee" do
|
53
|
+
expect(FollowSystem::Follow).to receive(:unfollow).with(follower, followee) { true }
|
54
|
+
|
55
|
+
expect(follower.unfollow(followee)).to equal(true)
|
56
|
+
end
|
57
|
+
|
58
|
+
###
|
59
|
+
# Should toggle follow a followee
|
60
|
+
###
|
61
|
+
it "Should toggle follow a followee" do
|
62
|
+
expect(FollowSystem::Follow).to receive(:toggle_follow).with(follower, followee) { true }
|
63
|
+
|
64
|
+
expect(follower.toggle_follow(followee)).to equal(true)
|
65
|
+
end
|
66
|
+
|
67
|
+
###
|
68
|
+
# Should follow a followee
|
69
|
+
###
|
70
|
+
it "should specify if follows a followee" do
|
71
|
+
expect(FollowSystem::Follow).to receive(:follows?).with(follower, followee) { true }
|
72
|
+
|
73
|
+
expect(follower.follows?(followee)).to equal(true)
|
74
|
+
end
|
75
|
+
|
76
|
+
###
|
77
|
+
# Should scope followees filtered by followee type
|
78
|
+
###
|
79
|
+
it "should scope followees filtered by followee type" do
|
80
|
+
scope = FollowSystem::Follow.scope_by_follower(follower).scope_by_followee_type(DummyFollowee)
|
81
|
+
|
82
|
+
expect(follower.followees_by(DummyFollowee)).to eq(scope)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
###
|
88
|
+
# Describes DummyFollower
|
89
|
+
###
|
90
|
+
describe DummyFollower do
|
91
|
+
###
|
92
|
+
# It behaves like FollowSystem::Follower
|
93
|
+
###
|
94
|
+
it_behaves_like FollowSystem::Follower
|
95
|
+
end
|
96
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'support/active_record'
|
2
|
+
require 'support/shoulda_matchers'
|
3
|
+
require 'follow_system'
|
4
|
+
|
5
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
6
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
7
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
8
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
9
|
+
#
|
10
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
11
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
12
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
13
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
14
|
+
# a separate helper file that requires the additional dependencies and performs
|
15
|
+
# the additional setup, and require it from the spec files that actually need it.
|
16
|
+
#
|
17
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
18
|
+
# users commonly want.
|
19
|
+
#
|
20
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
21
|
+
RSpec.configure do |config|
|
22
|
+
# rspec-expectations config goes here. You can use an alternate
|
23
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
24
|
+
# assertions if you prefer.
|
25
|
+
config.expect_with :rspec do |expectations|
|
26
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
27
|
+
# and `failure_message` of custom matchers include text for helper methods
|
28
|
+
# defined using `chain`, e.g.:
|
29
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
30
|
+
# # => "be bigger than 2 and smaller than 4"
|
31
|
+
# ...rather than:
|
32
|
+
# # => "be bigger than 2"
|
33
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
34
|
+
end
|
35
|
+
|
36
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
37
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
38
|
+
config.mock_with :rspec do |mocks|
|
39
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
40
|
+
# a real object. This is generally recommended, and will default to
|
41
|
+
# `true` in RSpec 4.
|
42
|
+
mocks.verify_partial_doubles = true
|
43
|
+
end
|
44
|
+
|
45
|
+
# The settings below are suggested to provide a good initial experience
|
46
|
+
# with RSpec, but feel free to customize to your heart's content.
|
47
|
+
=begin
|
48
|
+
# These two settings work together to allow you to limit a spec run
|
49
|
+
# to individual examples or groups you care about by tagging them with
|
50
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
51
|
+
# get run.
|
52
|
+
config.filter_run :focus
|
53
|
+
config.run_all_when_everything_filtered = true
|
54
|
+
|
55
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
56
|
+
# For more details, see:
|
57
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
58
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
59
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
60
|
+
config.disable_monkey_patching!
|
61
|
+
|
62
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
63
|
+
# be too noisy due to issues in dependencies.
|
64
|
+
config.warnings = true
|
65
|
+
|
66
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
67
|
+
# file, and it's useful to allow more verbose output when running an
|
68
|
+
# individual spec file.
|
69
|
+
if config.files_to_run.one?
|
70
|
+
# Use the documentation formatter for detailed output,
|
71
|
+
# unless a formatter has already been configured
|
72
|
+
# (e.g. via a command-line flag).
|
73
|
+
config.default_formatter = 'doc'
|
74
|
+
end
|
75
|
+
|
76
|
+
# Print the 10 slowest examples and example groups at the
|
77
|
+
# end of the spec run, to help surface which specs are running
|
78
|
+
# particularly slow.
|
79
|
+
config.profile_examples = 10
|
80
|
+
|
81
|
+
# Run specs in random order to surface order dependencies. If you find an
|
82
|
+
# order dependency and want to debug it, you can fix the order by providing
|
83
|
+
# the seed, which is printed after each run.
|
84
|
+
# --seed 1234
|
85
|
+
config.order = :random
|
86
|
+
|
87
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
88
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
89
|
+
# test failures related to randomization by passing the same `--seed` value
|
90
|
+
# as the one that triggered the failure.
|
91
|
+
Kernel.srand config.seed
|
92
|
+
=end
|
93
|
+
end
|
94
|
+
|
95
|
+
###
|
96
|
+
# DummyFollowee class
|
97
|
+
#
|
98
|
+
# This class defines the dummy followee model in follow system
|
99
|
+
###
|
100
|
+
class DummyFollowee < ActiveRecord::Base
|
101
|
+
###
|
102
|
+
# Acts as followee
|
103
|
+
act_as_followee
|
104
|
+
end
|
105
|
+
|
106
|
+
###
|
107
|
+
# DummyFollower class
|
108
|
+
#
|
109
|
+
# This class defines the dummy follower model in follow system
|
110
|
+
###
|
111
|
+
class DummyFollower < ActiveRecord::Base
|
112
|
+
###
|
113
|
+
# Acts as follower
|
114
|
+
act_as_follower
|
115
|
+
end
|
116
|
+
|
data/spec/support/.empty
ADDED
File without changes
|
File without changes
|
data/spec/support/.keep
ADDED
File without changes
|