facemock 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.coveralls.yml +1 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +154 -0
- data/Rakefile +6 -0
- data/db/.gitkeep +0 -0
- data/facemock.gemspec +31 -0
- data/lib/facemock/config.rb +88 -0
- data/lib/facemock/database/application.rb +20 -0
- data/lib/facemock/database/permission.rb +21 -0
- data/lib/facemock/database/table.rb +340 -0
- data/lib/facemock/database/user.rb +26 -0
- data/lib/facemock/database.rb +121 -0
- data/lib/facemock/errors.rb +7 -0
- data/lib/facemock/fb_graph/application/test_users.rb +36 -0
- data/lib/facemock/fb_graph/application/user/permission.rb +10 -0
- data/lib/facemock/fb_graph/application/user.rb +69 -0
- data/lib/facemock/fb_graph/application.rb +48 -0
- data/lib/facemock/fb_graph/user.rb +13 -0
- data/lib/facemock/fb_graph.rb +30 -0
- data/lib/facemock/version.rb +3 -0
- data/lib/facemock.rb +19 -0
- data/spec/facemock/config_spec.rb +185 -0
- data/spec/facemock/database/application_spec.rb +73 -0
- data/spec/facemock/database/permission_spec.rb +52 -0
- data/spec/facemock/database/tables_spec.rb +728 -0
- data/spec/facemock/database/user_spec.rb +169 -0
- data/spec/facemock/database_spec.rb +270 -0
- data/spec/facemock/errors_spec.rb +9 -0
- data/spec/facemock/fb_graph/application/test_users_spec.rb +155 -0
- data/spec/facemock/fb_graph/application/user_spec.rb +208 -0
- data/spec/facemock/fb_graph/application_spec.rb +132 -0
- data/spec/facemock/fb_graph/user_spec.rb +36 -0
- data/spec/facemock/fb_graph_spec.rb +47 -0
- data/spec/facemock_spec.rb +74 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/tables_helper.rb +46 -0
- metadata +64 -3
@@ -0,0 +1,208 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Facemock::FbGraph::Application::User do
|
4
|
+
let(:db_name) { ".test" }
|
5
|
+
|
6
|
+
let(:permission1) { :email }
|
7
|
+
let(:permission2) { :read_stream }
|
8
|
+
let(:options) { { identifier: 100000000000001,
|
9
|
+
name: "test user",
|
10
|
+
email: "test@example.com",
|
11
|
+
password: "testpass",
|
12
|
+
installed: true,
|
13
|
+
access_token: "test_token",
|
14
|
+
permissions: "#{permission1}, #{permission2}",
|
15
|
+
application_id: 1 } }
|
16
|
+
|
17
|
+
before { stub_const("Facemock::Database::DEFAULT_DB_NAME", db_name) }
|
18
|
+
after { Facemock::Database.new.drop }
|
19
|
+
|
20
|
+
it 'should have a permission class' do
|
21
|
+
expect(Facemock::FbGraph::Application::User::Permission).to be_truthy
|
22
|
+
expect(Facemock::FbGraph::Application::User::Permission.ancestors).to include Facemock::Database::Permission
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#new' do
|
26
|
+
context 'without options' do
|
27
|
+
subject { lambda { Facemock::FbGraph::Application::User.new } }
|
28
|
+
it { is_expected.not_to raise_error }
|
29
|
+
|
30
|
+
it 'should be initialized attribute' do
|
31
|
+
user = Facemock::FbGraph::Application::User.new
|
32
|
+
|
33
|
+
expect(user.identifier).to be_kind_of Integer
|
34
|
+
expect(user.name).to be_kind_of String
|
35
|
+
expect(user.email).to be_kind_of String
|
36
|
+
expect(user.password).to be_kind_of String
|
37
|
+
expect(user.access_token).to be_kind_of String
|
38
|
+
expect(user.permission_objects).to be_kind_of Array
|
39
|
+
|
40
|
+
expect(user.identifier).to be >= 100000000000000
|
41
|
+
expect(user.name).not_to be_empty
|
42
|
+
expect(user.password).not_to be_empty
|
43
|
+
expect(user.installed).to be false
|
44
|
+
expect(user.access_token).not_to be_empty
|
45
|
+
expect(user.permission_objects).to be_empty
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'with all options' do
|
50
|
+
it 'should be initialized attribute by options' do
|
51
|
+
user = Facemock::FbGraph::Application::User.new(options)
|
52
|
+
options.each do |attribute, value|
|
53
|
+
unless attribute.eql? :permissions
|
54
|
+
expect(user.send(attribute)).to eq value
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
user.permission_objects.each do |permission_object|
|
59
|
+
expect(options[:permissions]).to include permission_object.name
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'with only name option' do
|
65
|
+
before { @options = { name: "test_user" } }
|
66
|
+
|
67
|
+
subject { @user = Facemock::FbGraph::Application::User.new(@options).email }
|
68
|
+
it { is_expected.to eq "#{@options[:name]}@example.com" }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#permission' do
|
73
|
+
context 'when new without permissions option' do
|
74
|
+
before do
|
75
|
+
opts = options.select {|k, v| k != :permissions}
|
76
|
+
@user = Facemock::FbGraph::Application::User.new(opts)
|
77
|
+
end
|
78
|
+
|
79
|
+
subject { @user.permissions }
|
80
|
+
it { is_expected.to eq [] }
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when new with all options' do
|
84
|
+
before do
|
85
|
+
@user = Facemock::FbGraph::Application::User.new(options)
|
86
|
+
end
|
87
|
+
|
88
|
+
subject { @user.permissions }
|
89
|
+
it { is_expected.to include permission1 }
|
90
|
+
it { is_expected.to include permission2 }
|
91
|
+
it { expect(@user.permissions.size).to eq 2 }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#save!' do
|
96
|
+
context 'when new without permissions option' do
|
97
|
+
before do
|
98
|
+
opts = options.select {|k, v| k != :permissions}
|
99
|
+
@user = Facemock::FbGraph::Application::User.new(opts)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should not create permission' do
|
103
|
+
@user.save!
|
104
|
+
expect(@user.permissions).to eq []
|
105
|
+
permissions = Facemock::FbGraph::Application::User::Permission.all
|
106
|
+
expect(permissions).to be_empty
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'when new with permissions option' do
|
111
|
+
before { @user = Facemock::FbGraph::Application::User.new(options) }
|
112
|
+
|
113
|
+
it 'should create permission' do
|
114
|
+
@user.save!
|
115
|
+
expect(@user.permissions).to include permission1
|
116
|
+
expect(@user.permissions).to include permission2
|
117
|
+
permissions = Facemock::FbGraph::Application::User::Permission.all
|
118
|
+
expect(permissions.size).to eq 2
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#fetch' do
|
124
|
+
before { @user = Facemock::FbGraph::Application::User.new(options) }
|
125
|
+
|
126
|
+
context 'when user does not save' do
|
127
|
+
subject { @user.fetch }
|
128
|
+
it { is_expected.to eq nil }
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'when user already saved' do
|
132
|
+
before do
|
133
|
+
@user.save!
|
134
|
+
end
|
135
|
+
|
136
|
+
subject { @user.fetch }
|
137
|
+
it { is_expected.not_to eq nil }
|
138
|
+
|
139
|
+
describe '.id' do
|
140
|
+
subject { @user.fetch.id }
|
141
|
+
it { is_expected.to eq @user.id }
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe '#destroy' do
|
147
|
+
context 'when does not have permission' do
|
148
|
+
before do
|
149
|
+
@user = Facemock::FbGraph::Application::User.new(options)
|
150
|
+
@user.save!
|
151
|
+
end
|
152
|
+
|
153
|
+
subject { lambda { @user.destroy } }
|
154
|
+
it { is_expected.not_to raise_error }
|
155
|
+
|
156
|
+
it 'user does not exist' do
|
157
|
+
@user.destroy
|
158
|
+
user = Facemock::FbGraph::Application::User.find_by_id(@user.id)
|
159
|
+
expect(user).to be_nil
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
context 'when have some permissions' do
|
164
|
+
before do
|
165
|
+
opts = { application_id: 1, permissions: "email, read_stream" }
|
166
|
+
@user = Facemock::FbGraph::Application::User.new(opts)
|
167
|
+
@user.save!
|
168
|
+
end
|
169
|
+
|
170
|
+
subject { lambda { @user.destroy } }
|
171
|
+
it { is_expected.not_to raise_error }
|
172
|
+
|
173
|
+
it 'user and permission does not exist' do
|
174
|
+
@user.destroy
|
175
|
+
expect(Facemock::FbGraph::Application::User.find_by_id(@user.id)).to be_nil
|
176
|
+
expect(Facemock::FbGraph::Application::User::Permission.find_all_by_user_id(@user.id)).to be_empty
|
177
|
+
expect(@user.permissions).not_to be_empty
|
178
|
+
expect(@user.permission_objects).not_to be_empty
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe '#revoke!' do
|
184
|
+
context 'when does not have permission' do
|
185
|
+
before do
|
186
|
+
@user = Facemock::FbGraph::Application::User.new(options)
|
187
|
+
@user.save!
|
188
|
+
end
|
189
|
+
|
190
|
+
subject { lambda { @user.revoke! } }
|
191
|
+
it { is_expected.not_to raise_error }
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'when have some permissions' do
|
195
|
+
before do
|
196
|
+
opts = { application_id: 1, permissions: "email, read_stream" }
|
197
|
+
@user = Facemock::FbGraph::Application::User.new(opts)
|
198
|
+
@user.save!
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'should destroy permissions' do
|
202
|
+
@user.revoke!
|
203
|
+
expect(Facemock::FbGraph::Application::User::Permission.find_by_user_id(@user.id)).to be_nil
|
204
|
+
expect(@user.permissions).to be_empty
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Facemock::FbGraph::Application do
|
4
|
+
let(:db_name) { ".test" }
|
5
|
+
|
6
|
+
let(:facebook_app_id) { 100000000000000 }
|
7
|
+
let(:facebook_app_secret) { "test_secret" }
|
8
|
+
let(:access_token) { "access_token" }
|
9
|
+
|
10
|
+
it 'should have a user class' do
|
11
|
+
expect(Facemock::FbGraph::Application::User).to be_truthy
|
12
|
+
expect(Facemock::FbGraph::Application::User.ancestors).to include Facemock::Database::User
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have a users class' do
|
16
|
+
expect(Facemock::FbGraph::Application::TestUsers).to be_truthy
|
17
|
+
expect(Facemock::FbGraph::Application::TestUsers.ancestors).to include Array
|
18
|
+
end
|
19
|
+
|
20
|
+
before do
|
21
|
+
stub_const("Facemock::Database::DEFAULT_DB_NAME", db_name)
|
22
|
+
@database = Facemock::Database.new
|
23
|
+
end
|
24
|
+
after { @database.drop }
|
25
|
+
|
26
|
+
describe '#new' do
|
27
|
+
context 'without argument' do
|
28
|
+
subject { lambda { Facemock::FbGraph::Application.new } }
|
29
|
+
it { is_expected.to raise_error ArgumentError }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with facebook app id and secret' do
|
33
|
+
before { @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret) }
|
34
|
+
|
35
|
+
describe '.identifier' do
|
36
|
+
subject { @app.identifier }
|
37
|
+
it { is_expected.to eq facebook_app_id }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '.secreet' do
|
41
|
+
subject { @app.secret }
|
42
|
+
it { is_expected.to eq facebook_app_secret }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'with facebook app id and secret' do
|
47
|
+
before do
|
48
|
+
options = { secret: facebook_app_secret }
|
49
|
+
@app = Facemock::FbGraph::Application.new(facebook_app_id, options)
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '.identifier' do
|
53
|
+
subject { @app.identifier }
|
54
|
+
it { is_expected.to eq facebook_app_id }
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '.secreet' do
|
58
|
+
subject { @app.secret }
|
59
|
+
it { is_expected.to eq facebook_app_secret }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'with app symbole and access_token' do
|
64
|
+
before { @app = Facemock::FbGraph::Application.new(:app, access_token: access_token) }
|
65
|
+
|
66
|
+
describe '.identifier' do
|
67
|
+
subject { @app.identifier }
|
68
|
+
it { is_expected.to be_kind_of Integer }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '.secreet' do
|
72
|
+
subject { @app.secret }
|
73
|
+
it { is_expected.not_to be_empty }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#fetch' do
|
79
|
+
before { @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret) }
|
80
|
+
|
81
|
+
describe '.identifier' do
|
82
|
+
subject { @app.fetch.identifier }
|
83
|
+
it { is_expected.to eq @app.identifier }
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '.secret' do
|
87
|
+
subject { @app.fetch.secret }
|
88
|
+
it { is_expected.to eq @app.secret }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#test_user!' do
|
93
|
+
before { @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret) }
|
94
|
+
|
95
|
+
it 'should created user' do
|
96
|
+
expect(Facemock::FbGraph::Application::User.all).to be_empty
|
97
|
+
created_user = @app.test_user!
|
98
|
+
finded_user = Facemock::FbGraph::Application::User.find_by_id(created_user.id)
|
99
|
+
Facemock::FbGraph::Application::User.column_names.each do |column_name|
|
100
|
+
expect(created_user.send(column_name)).to eq finded_user.send(column_name)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe '#test_users' do
|
106
|
+
before do
|
107
|
+
@app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'when test_user is not created' do
|
111
|
+
subject { @app.test_users }
|
112
|
+
|
113
|
+
it { is_expected.to be_kind_of Facemock::FbGraph::Application::TestUsers }
|
114
|
+
it { is_expected.to be_empty }
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'when test_user is created' do
|
118
|
+
before do
|
119
|
+
@user = @app.test_user!
|
120
|
+
end
|
121
|
+
|
122
|
+
subject { @app.test_users }
|
123
|
+
it { is_expected.to be_kind_of Facemock::FbGraph::Application::TestUsers }
|
124
|
+
it { is_expected.not_to be_empty }
|
125
|
+
|
126
|
+
describe '.first.id' do
|
127
|
+
subject { @app.test_users.first.id }
|
128
|
+
it { is_expected.to eq @user.id }
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Facemock::FbGraph::User do
|
4
|
+
let(:db_name) { ".test" }
|
5
|
+
|
6
|
+
let(:facebook_app_id) { "100000000000000" }
|
7
|
+
let(:facebook_app_secret) { "test_secret" }
|
8
|
+
|
9
|
+
before do
|
10
|
+
stub_const("Facemock::Database::DEFAULT_DB_NAME", db_name)
|
11
|
+
@database = Facemock::Database.new
|
12
|
+
end
|
13
|
+
after { @database.drop }
|
14
|
+
|
15
|
+
describe '.me' do
|
16
|
+
context 'when access_token is correct' do
|
17
|
+
before do
|
18
|
+
app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
|
19
|
+
@user = app.test_user!
|
20
|
+
@access_token = @user.access_token
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'can get user' do
|
24
|
+
user = Facemock::FbGraph::User.me(@access_token)
|
25
|
+
Facemock::FbGraph::Application::User.column_names.each do |column|
|
26
|
+
expect(user.send(column)).to eq @user.send(column) unless column == "created_at"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when access_token is incorrect' do
|
32
|
+
subject { Facemock::FbGraph::User.me('incorrect_token') }
|
33
|
+
it { is_expected.to eq nil }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Facemock::FbGraph do
|
4
|
+
it 'should have a application class' do
|
5
|
+
expect(Facemock::FbGraph::Application).to be_truthy
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should have a user module' do
|
9
|
+
expect(Facemock::FbGraph::User).to be_truthy
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should have a invalid_token class' do
|
13
|
+
expect(Facemock::FbGraph::InvalidToken).to be_truthy
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#on' do
|
17
|
+
subject { Facemock::FbGraph.on }
|
18
|
+
it { is_expected.to be_truthy }
|
19
|
+
|
20
|
+
context 'FbGraph' do
|
21
|
+
before { Facemock::FbGraph.on }
|
22
|
+
it { expect(::FbGraph).to eq Facemock::FbGraph }
|
23
|
+
it { expect( lambda { Facemock::FbGraph.on } ).not_to raise_error }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#off' do
|
28
|
+
subject { Facemock::FbGraph.off }
|
29
|
+
it { is_expected.to be_truthy }
|
30
|
+
|
31
|
+
context 'FbGraph' do
|
32
|
+
before { Facemock::FbGraph.off }
|
33
|
+
it { expect(FbGraph).to eq FbGraph }
|
34
|
+
it { expect( lambda { Facemock::FbGraph.off } ).not_to raise_error }
|
35
|
+
|
36
|
+
context 'when mock is on' do
|
37
|
+
before do
|
38
|
+
Facemock::FbGraph.on
|
39
|
+
Facemock::FbGraph.off
|
40
|
+
end
|
41
|
+
|
42
|
+
subject { ::FbGraph }
|
43
|
+
it { is_expected.to eq FbGraph }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Facemock do
|
4
|
+
let(:version) { '0.0.5' }
|
5
|
+
let(:db_name) { '.test' }
|
6
|
+
|
7
|
+
describe 'VERSION' do
|
8
|
+
subject { Facemock::VERSION }
|
9
|
+
it { is_expected.to eq version }
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should have a config module' do
|
13
|
+
expect(Facemock::Config).to be_truthy
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should have a fb_graph module' do
|
17
|
+
expect(Facemock::FbGraph).to be_truthy
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should have a database class' do
|
21
|
+
expect(Facemock::Database).to be_truthy
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have a errors module' do
|
25
|
+
expect(Facemock::Errors).to be_truthy
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.on' do
|
29
|
+
subject { Facemock.on }
|
30
|
+
it { is_expected.to be_truthy }
|
31
|
+
|
32
|
+
context 'FbGraph' do
|
33
|
+
before { Facemock.on }
|
34
|
+
it { expect(::FbGraph).to eq Facemock::FbGraph }
|
35
|
+
it { expect( lambda { Facemock.on } ).not_to raise_error }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '.off' do
|
40
|
+
subject { Facemock.off }
|
41
|
+
it { is_expected.to be_truthy }
|
42
|
+
|
43
|
+
context 'FbGraph' do
|
44
|
+
before { Facemock.off }
|
45
|
+
it { expect(FbGraph).to eq FbGraph }
|
46
|
+
it { expect( lambda { Facemock.off } ).not_to raise_error }
|
47
|
+
|
48
|
+
context 'when Mock is on' do
|
49
|
+
before do
|
50
|
+
Facemock.on
|
51
|
+
Facemock.off
|
52
|
+
end
|
53
|
+
|
54
|
+
subject { ::FbGraph }
|
55
|
+
it { is_expected.to eq FbGraph }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '.on?' do
|
61
|
+
context 'when Facemock.off' do
|
62
|
+
before { Facemock.off }
|
63
|
+
subject { Facemock.on? }
|
64
|
+
it { is_expected.to be true }
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when Facemock.on' do
|
68
|
+
before { Facemock.on }
|
69
|
+
after { Facemock.off }
|
70
|
+
subject { Facemock.on? }
|
71
|
+
it { is_expected.to be true }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
require 'coveralls'
|
5
|
+
|
6
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
7
|
+
SimpleCov::Formatter::HTMLFormatter,
|
8
|
+
Coveralls::SimpleCov::Formatter
|
9
|
+
]
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter '.bundle/'
|
12
|
+
add_filter '/spec/'
|
13
|
+
end
|
14
|
+
|
15
|
+
# spec/support 以下のヘルパーを読み込み
|
16
|
+
Dir[File.expand_path('../support/', __FILE__) + "/**/*.rb"].each {|f| require f}
|
17
|
+
|
18
|
+
require 'facemock'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module TableHelper
|
2
|
+
# テストで動的に定義したクラスメソッドを削除
|
3
|
+
def remove_dynamically_defined_class_method(klass)
|
4
|
+
klass.methods.each do |method_name|
|
5
|
+
if method_name.to_s =~ /^find_by_/ || method_name.to_s =~ /^find_all_by_/
|
6
|
+
klass.class_eval do
|
7
|
+
class_variable_set(:@@target_method_name, method_name)
|
8
|
+
class << self
|
9
|
+
remove_method class_variable_get(:@@target_method_name)
|
10
|
+
end
|
11
|
+
remove_class_variable(:@@target_method_name)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# テストで動的に定義したインスタンスメソッドを削除
|
18
|
+
def remove_dynamically_defined_instance_method(klass)
|
19
|
+
klass.column_names.each do |column_name|
|
20
|
+
getter = column_name
|
21
|
+
if klass.instance_methods.include?(getter)
|
22
|
+
klass.class_eval { remove_method getter }
|
23
|
+
end
|
24
|
+
|
25
|
+
setter = (column_name.to_s + "=").to_sym
|
26
|
+
if klass.instance_methods.include?(setter)
|
27
|
+
klass.class_eval { remove_method setter }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Tableクラスでテストするために、一時的にDB Tableを作成する
|
33
|
+
def create_tables_table_for_test
|
34
|
+
db = Facemock::Database.new
|
35
|
+
db.connection.execute <<-SQL
|
36
|
+
CREATE TABLE TABLES (
|
37
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
38
|
+
text TEXT NOT NULL,
|
39
|
+
active BOOLEAN,
|
40
|
+
number INTEGER NOT NULL,
|
41
|
+
created_at DATETIME NOT NULL
|
42
|
+
);
|
43
|
+
SQL
|
44
|
+
db.disconnect!
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facemock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -162,7 +162,47 @@ email:
|
|
162
162
|
executables: []
|
163
163
|
extensions: []
|
164
164
|
extra_rdoc_files: []
|
165
|
-
files:
|
165
|
+
files:
|
166
|
+
- .coveralls.yml
|
167
|
+
- .gitignore
|
168
|
+
- .rspec
|
169
|
+
- .travis.yml
|
170
|
+
- Gemfile
|
171
|
+
- LICENSE.txt
|
172
|
+
- README.md
|
173
|
+
- Rakefile
|
174
|
+
- db/.gitkeep
|
175
|
+
- facemock.gemspec
|
176
|
+
- lib/facemock.rb
|
177
|
+
- lib/facemock/config.rb
|
178
|
+
- lib/facemock/database.rb
|
179
|
+
- lib/facemock/database/application.rb
|
180
|
+
- lib/facemock/database/permission.rb
|
181
|
+
- lib/facemock/database/table.rb
|
182
|
+
- lib/facemock/database/user.rb
|
183
|
+
- lib/facemock/errors.rb
|
184
|
+
- lib/facemock/fb_graph.rb
|
185
|
+
- lib/facemock/fb_graph/application.rb
|
186
|
+
- lib/facemock/fb_graph/application/test_users.rb
|
187
|
+
- lib/facemock/fb_graph/application/user.rb
|
188
|
+
- lib/facemock/fb_graph/application/user/permission.rb
|
189
|
+
- lib/facemock/fb_graph/user.rb
|
190
|
+
- lib/facemock/version.rb
|
191
|
+
- spec/facemock/config_spec.rb
|
192
|
+
- spec/facemock/database/application_spec.rb
|
193
|
+
- spec/facemock/database/permission_spec.rb
|
194
|
+
- spec/facemock/database/tables_spec.rb
|
195
|
+
- spec/facemock/database/user_spec.rb
|
196
|
+
- spec/facemock/database_spec.rb
|
197
|
+
- spec/facemock/errors_spec.rb
|
198
|
+
- spec/facemock/fb_graph/application/test_users_spec.rb
|
199
|
+
- spec/facemock/fb_graph/application/user_spec.rb
|
200
|
+
- spec/facemock/fb_graph/application_spec.rb
|
201
|
+
- spec/facemock/fb_graph/user_spec.rb
|
202
|
+
- spec/facemock/fb_graph_spec.rb
|
203
|
+
- spec/facemock_spec.rb
|
204
|
+
- spec/spec_helper.rb
|
205
|
+
- spec/support/tables_helper.rb
|
166
206
|
homepage: https://github.com/ogawatti/facemock
|
167
207
|
licenses:
|
168
208
|
- MIT
|
@@ -176,16 +216,37 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
216
|
- - ! '>='
|
177
217
|
- !ruby/object:Gem::Version
|
178
218
|
version: '0'
|
219
|
+
segments:
|
220
|
+
- 0
|
221
|
+
hash: 28983518924956575
|
179
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
223
|
none: false
|
181
224
|
requirements:
|
182
225
|
- - ! '>='
|
183
226
|
- !ruby/object:Gem::Version
|
184
227
|
version: '0'
|
228
|
+
segments:
|
229
|
+
- 0
|
230
|
+
hash: 28983518924956575
|
185
231
|
requirements: []
|
186
232
|
rubyforge_project:
|
187
233
|
rubygems_version: 1.8.25
|
188
234
|
signing_key:
|
189
235
|
specification_version: 3
|
190
236
|
summary: This is facebook mock application for fb_graph.
|
191
|
-
test_files:
|
237
|
+
test_files:
|
238
|
+
- spec/facemock/config_spec.rb
|
239
|
+
- spec/facemock/database/application_spec.rb
|
240
|
+
- spec/facemock/database/permission_spec.rb
|
241
|
+
- spec/facemock/database/tables_spec.rb
|
242
|
+
- spec/facemock/database/user_spec.rb
|
243
|
+
- spec/facemock/database_spec.rb
|
244
|
+
- spec/facemock/errors_spec.rb
|
245
|
+
- spec/facemock/fb_graph/application/test_users_spec.rb
|
246
|
+
- spec/facemock/fb_graph/application/user_spec.rb
|
247
|
+
- spec/facemock/fb_graph/application_spec.rb
|
248
|
+
- spec/facemock/fb_graph/user_spec.rb
|
249
|
+
- spec/facemock/fb_graph_spec.rb
|
250
|
+
- spec/facemock_spec.rb
|
251
|
+
- spec/spec_helper.rb
|
252
|
+
- spec/support/tables_helper.rb
|