facemock 0.0.2 → 0.0.3
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.
- metadata +4 -70
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -22
- data/.rspec +0 -2
- data/.travis.yml +0 -6
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/README.md +0 -154
- data/Rakefile +0 -6
- data/db/.gitkeep +0 -0
- data/facemock.gemspec +0 -32
- data/lib/facemock/config/database.rb +0 -99
- data/lib/facemock/config.rb +0 -92
- data/lib/facemock/errors.rb +0 -6
- data/lib/facemock/fb_graph/application/test_users.rb +0 -36
- data/lib/facemock/fb_graph/application/user/right.rb +0 -14
- data/lib/facemock/fb_graph/application/user.rb +0 -68
- data/lib/facemock/fb_graph/application.rb +0 -44
- data/lib/facemock/fb_graph/errors.rb +0 -11
- data/lib/facemock/fb_graph/user.rb +0 -14
- data/lib/facemock/fb_graph.rb +0 -36
- data/lib/facemock/version.rb +0 -3
- data/lib/facemock.rb +0 -15
- data/spec/facemock/config/database_spec.rb +0 -220
- data/spec/facemock/config_spec.rb +0 -195
- data/spec/facemock/fb_graph/application/test_users_spec.rb +0 -159
- data/spec/facemock/fb_graph/application/user/right_spec.rb +0 -10
- data/spec/facemock/fb_graph/application/user_spec.rb +0 -131
- data/spec/facemock/fb_graph/application_spec.rb +0 -140
- data/spec/facemock/fb_graph/errors_spec.rb +0 -13
- data/spec/facemock/fb_graph/user_spec.rb +0 -39
- data/spec/facemock/fb_graph_spec.rb +0 -54
- data/spec/facemock_spec.rb +0 -72
- data/spec/spec_helper.rb +0 -15
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Facemock::FbGraph::Application::User::Right do
|
4
|
-
let(:table_name) { "user_rights" }
|
5
|
-
|
6
|
-
describe '.table_name' do
|
7
|
-
subject { Facemock::FbGraph::Application::User::Right.table_name }
|
8
|
-
it { is_expected.to eq table_name }
|
9
|
-
end
|
10
|
-
end
|
@@ -1,131 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Facemock::FbGraph::Application::User do
|
4
|
-
let(:table_name) { "users" }
|
5
|
-
|
6
|
-
let(:db_name) { ".test" }
|
7
|
-
let(:adapter) { "sqlite3" }
|
8
|
-
let(:db_directory) { File.expand_path("../../../../db", __FILE__) }
|
9
|
-
let(:db_filepath) { File.join(db_directory, "#{db_name}.#{adapter}") }
|
10
|
-
let(:options) { { identifier: 100000000000001,
|
11
|
-
name: "test user",
|
12
|
-
email: "test@example.com",
|
13
|
-
password: "testpass",
|
14
|
-
installed: true,
|
15
|
-
access_token: "test_token",
|
16
|
-
permissions: "email, read_stream" } }
|
17
|
-
|
18
|
-
before do
|
19
|
-
stub_const("Facemock::Config::Database::DEFAULT_DB_NAME", db_name)
|
20
|
-
Facemock::Config.database
|
21
|
-
end
|
22
|
-
after { Facemock::Config.database.drop }
|
23
|
-
|
24
|
-
it 'should have a rigth class' do
|
25
|
-
expect(Facemock::FbGraph::Application::User::Right).to be_truthy
|
26
|
-
expect(Facemock::FbGraph::Application::User::Right.ancestors).to include ActiveRecord::Base
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '.table_name' do
|
30
|
-
subject { Facemock::FbGraph::Application::User.table_name }
|
31
|
-
it { is_expected.to eq table_name }
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#new' do
|
35
|
-
context 'without options' do
|
36
|
-
subject { lambda { Facemock::FbGraph::Application::User.new } }
|
37
|
-
it { is_expected.not_to raise_error }
|
38
|
-
|
39
|
-
it 'should be initialized attribute' do
|
40
|
-
user = Facemock::FbGraph::Application::User.new
|
41
|
-
|
42
|
-
expect(user.identifier).to be_kind_of Integer
|
43
|
-
expect(user.name).to be_kind_of String
|
44
|
-
expect(user.email).to be_kind_of String
|
45
|
-
expect(user.password).to be_kind_of String
|
46
|
-
expect(user.access_token).to be_kind_of String
|
47
|
-
expect(user.permissions).to be_kind_of Array
|
48
|
-
|
49
|
-
expect(user.identifier).to be >= 100000000000000
|
50
|
-
expect(user.name).not_to be_empty
|
51
|
-
expect(user.password).not_to be_empty
|
52
|
-
expect(user.installed).to be false
|
53
|
-
expect(user.access_token).not_to be_empty
|
54
|
-
expect(user.permissions).to be_empty
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'with all options' do
|
59
|
-
it 'should be initialized attribute by options' do
|
60
|
-
user = Facemock::FbGraph::Application::User.new(options)
|
61
|
-
options.each do |attribute, value|
|
62
|
-
if attribute.eql? :permissions
|
63
|
-
expect(user.send(attribute)).to include :email
|
64
|
-
expect(user.send(attribute)).to include :read_stream
|
65
|
-
else
|
66
|
-
expect(user.send(attribute)).to eq value
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
user.rights.each do |right|
|
71
|
-
expect(options[:permissions]).to include right.name
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'with only name option' do
|
77
|
-
before { @options = { name: "test_user" } }
|
78
|
-
|
79
|
-
subject { @user = Facemock::FbGraph::Application::User.new(@options).email }
|
80
|
-
it { is_expected.to eq "#{@options[:name]}@example.com" }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe '#fetch' do
|
85
|
-
before { @user = Facemock::FbGraph::Application::User.new }
|
86
|
-
|
87
|
-
context 'when user does not save' do
|
88
|
-
subject { @user.fetch }
|
89
|
-
it { is_expected.to eq nil }
|
90
|
-
end
|
91
|
-
|
92
|
-
context 'when user already saved' do
|
93
|
-
before do
|
94
|
-
@user.save!
|
95
|
-
end
|
96
|
-
|
97
|
-
subject { @user.fetch }
|
98
|
-
it { is_expected.not_to eq nil }
|
99
|
-
|
100
|
-
describe '.id' do
|
101
|
-
subject { @user.fetch.id }
|
102
|
-
it { is_expected.to eq @user.id }
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe '#revoke!' do
|
108
|
-
context 'when does not have permission' do
|
109
|
-
before do
|
110
|
-
@user = Facemock::FbGraph::Application::User.new
|
111
|
-
@user.save!
|
112
|
-
end
|
113
|
-
|
114
|
-
subject { lambda { @user.revoke! } }
|
115
|
-
it { is_expected.not_to raise_error }
|
116
|
-
end
|
117
|
-
|
118
|
-
context 'when have some permissions' do
|
119
|
-
before do
|
120
|
-
@user = Facemock::FbGraph::Application::User.new({permissions: "email, read_stream"})
|
121
|
-
@user.save!
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'should destroy permissions' do
|
125
|
-
@user.revoke!
|
126
|
-
expect(Facemock::FbGraph::Application::User::Right.find_by_user_id(@user.id)).to be_nil
|
127
|
-
expect(@user.permissions).to be_empty
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
@@ -1,140 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Facemock::FbGraph::Application do
|
4
|
-
let(:table_name) { "applications" }
|
5
|
-
|
6
|
-
let(:facebook_app_id) { 100000000000000 }
|
7
|
-
let(:facebook_app_secret) { "test_secret" }
|
8
|
-
let(:access_token) { "access_token" }
|
9
|
-
|
10
|
-
let(:db_name) { ".test" }
|
11
|
-
let(:adapter) { "sqlite3" }
|
12
|
-
let(:db_directory) { File.expand_path("../../../../db", __FILE__) }
|
13
|
-
let(:db_filepath) { File.join(db_directory, "#{db_name}.#{adapter}") }
|
14
|
-
|
15
|
-
it 'should have a user class' do
|
16
|
-
expect(Facemock::FbGraph::Application::User).to be_truthy
|
17
|
-
expect(Facemock::FbGraph::Application::User.ancestors).to include ActiveRecord::Base
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should have a users class' do
|
21
|
-
expect(Facemock::FbGraph::Application::TestUsers).to be_truthy
|
22
|
-
expect(Facemock::FbGraph::Application::TestUsers.ancestors).to include Array
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '.table_name' do
|
26
|
-
subject { Facemock::FbGraph::Application.table_name }
|
27
|
-
it { is_expected.to eq table_name }
|
28
|
-
end
|
29
|
-
|
30
|
-
before do
|
31
|
-
stub_const("Facemock::Config::Database::DEFAULT_DB_NAME", db_name)
|
32
|
-
Facemock::Config.database
|
33
|
-
end
|
34
|
-
after { Facemock::Config.database.drop }
|
35
|
-
|
36
|
-
describe '#new' do
|
37
|
-
context 'without argument' do
|
38
|
-
subject { lambda { Facemock::FbGraph::Application.new } }
|
39
|
-
it { is_expected.to raise_error ArgumentError }
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'with facebook app id and secret' do
|
43
|
-
before { @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret) }
|
44
|
-
|
45
|
-
describe '.id' do
|
46
|
-
subject { @app.id }
|
47
|
-
it { is_expected.to eq facebook_app_id }
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '.secreet' do
|
51
|
-
subject { @app.secret }
|
52
|
-
it { is_expected.to eq facebook_app_secret }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'with facebook app id and secret' do
|
57
|
-
before do
|
58
|
-
options = { secret: facebook_app_secret }
|
59
|
-
Facemock::FbGraph.on
|
60
|
-
@app = Facemock::FbGraph::Application.new(facebook_app_id, options)
|
61
|
-
end
|
62
|
-
|
63
|
-
describe '.id' do
|
64
|
-
subject { @app.id }
|
65
|
-
it { is_expected.to eq facebook_app_id }
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '.secreet' do
|
69
|
-
subject { @app.secret }
|
70
|
-
it { is_expected.to eq facebook_app_secret }
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'with app symbole and access_token' do
|
75
|
-
before { @app = Facemock::FbGraph::Application.new(:app, access_token: access_token) }
|
76
|
-
|
77
|
-
describe '.id' do
|
78
|
-
subject { @app.id }
|
79
|
-
it { is_expected.to be_kind_of Integer }
|
80
|
-
end
|
81
|
-
|
82
|
-
describe '.secreet' do
|
83
|
-
subject { @app.secret }
|
84
|
-
it { is_expected.not_to be_empty }
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe '#fetch' do
|
90
|
-
before { @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret) }
|
91
|
-
|
92
|
-
describe '.id' do
|
93
|
-
subject { @app.fetch.identifier }
|
94
|
-
it { is_expected.to eq @app.identifier }
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '.secret' do
|
98
|
-
subject { @app.fetch.secret }
|
99
|
-
it { is_expected.to eq @app.secret }
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe '#test_user!' do
|
104
|
-
before { @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret) }
|
105
|
-
|
106
|
-
it 'should created user' do
|
107
|
-
expect(Facemock::FbGraph::Application::User.all).to be_empty
|
108
|
-
user = @app.test_user!
|
109
|
-
expect(Facemock::FbGraph::Application::User.find_by_id(user.id)).to eq user
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
describe '#test_users' do
|
114
|
-
before do
|
115
|
-
@app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
|
116
|
-
end
|
117
|
-
|
118
|
-
context 'when test_user is not created' do
|
119
|
-
subject { @app.test_users }
|
120
|
-
|
121
|
-
it { is_expected.to be_kind_of Facemock::FbGraph::Application::TestUsers }
|
122
|
-
it { is_expected.to be_empty }
|
123
|
-
end
|
124
|
-
|
125
|
-
context 'when test_user is created' do
|
126
|
-
before do
|
127
|
-
@user = @app.test_user!
|
128
|
-
end
|
129
|
-
|
130
|
-
subject { @app.test_users }
|
131
|
-
it { is_expected.to be_kind_of Facemock::FbGraph::Application::TestUsers }
|
132
|
-
it { is_expected.not_to be_empty }
|
133
|
-
|
134
|
-
describe '.first.id' do
|
135
|
-
subject { @app.test_users.first.id }
|
136
|
-
it { is_expected.to eq @user.id }
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Facemock::FbGraph::Errors do
|
4
|
-
before do
|
5
|
-
Facemock::FbGraph.off
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should have a error module' do
|
9
|
-
expect(Facemock::FbGraph::Errors::Error).to be_truthy
|
10
|
-
expect(Facemock::FbGraph::Errors::Error.ancestors).to include StandardError
|
11
|
-
expect(Facemock::FbGraph::Errors::InvalidToken.ancestors).to include FbGraph::InvalidToken
|
12
|
-
end
|
13
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Facemock::FbGraph::User do
|
4
|
-
let(:facebook_app_id) { "100000000000000" }
|
5
|
-
let(:facebook_app_secret) { "test_secret" }
|
6
|
-
let(:db_name) { ".test" }
|
7
|
-
let(:adapter) { "sqlite3" }
|
8
|
-
let(:table_names) { [:users, :user_rights] }
|
9
|
-
let(:db_directory) { File.expand_path("../../../../db", __FILE__) }
|
10
|
-
let(:db_filepath) { File.join(db_directory, "#{db_name}.#{adapter}") }
|
11
|
-
|
12
|
-
before do
|
13
|
-
stub_const("Facemock::Config::Database::DEFAULT_DB_NAME", db_name)
|
14
|
-
Facemock::Config.database
|
15
|
-
end
|
16
|
-
after { Facemock::Config.database.drop }
|
17
|
-
|
18
|
-
describe '.me' do
|
19
|
-
context 'when access_token is correct' do
|
20
|
-
before do
|
21
|
-
app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
|
22
|
-
@user = app.test_user!
|
23
|
-
@access_token = @user.access_token
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'can get user' do
|
27
|
-
user = Facemock::FbGraph::User.me(@access_token)
|
28
|
-
Facemock::FbGraph::Application::User.column_names.each do |column|
|
29
|
-
expect(user.send(column)).to eq @user.send(column) unless column == "created_at"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when access_token is incorrect' do
|
35
|
-
subject { Facemock::FbGraph::User.me('incorrect_token') }
|
36
|
-
it { is_expected.to eq nil }
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Facemock::FbGraph do
|
4
|
-
let(:db_name) { ".test" }
|
5
|
-
|
6
|
-
it 'should have a application class' do
|
7
|
-
expect(Facemock::FbGraph::Application).to be_truthy
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should have a errors module' do
|
11
|
-
expect(Facemock::FbGraph::Errors).to be_truthy
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should have a user module' do
|
15
|
-
expect(Facemock::FbGraph::User).to be_truthy
|
16
|
-
end
|
17
|
-
|
18
|
-
before do
|
19
|
-
stub_const("Facemock::Config::Database::DEFAULT_DB_NAME", db_name)
|
20
|
-
end
|
21
|
-
after { Facemock::Config.database.drop }
|
22
|
-
|
23
|
-
describe '#on' do
|
24
|
-
subject { Facemock::FbGraph.on }
|
25
|
-
it { is_expected.to be_truthy }
|
26
|
-
|
27
|
-
context 'FbGraph' do
|
28
|
-
before { Facemock::FbGraph.on }
|
29
|
-
it { expect(::FbGraph).to eq Facemock::FbGraph }
|
30
|
-
it { expect( lambda { Facemock::FbGraph.on } ).not_to raise_error }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#off' do
|
35
|
-
subject { Facemock::FbGraph.off }
|
36
|
-
it { is_expected.to be_truthy }
|
37
|
-
|
38
|
-
context 'FbGraph' do
|
39
|
-
before { Facemock::FbGraph.off }
|
40
|
-
it { expect(FbGraph).to eq FbGraph }
|
41
|
-
it { expect( lambda { Facemock::FbGraph.off } ).not_to raise_error }
|
42
|
-
|
43
|
-
context 'when mock is on' do
|
44
|
-
before do
|
45
|
-
Facemock::FbGraph.on
|
46
|
-
Facemock::FbGraph.off
|
47
|
-
end
|
48
|
-
|
49
|
-
subject { ::FbGraph }
|
50
|
-
it { is_expected.to eq FbGraph }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
data/spec/facemock_spec.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Facemock do
|
4
|
-
let(:version) { "0.0.2" }
|
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 errors module' do
|
21
|
-
expect(Facemock::Errors).to be_truthy
|
22
|
-
end
|
23
|
-
|
24
|
-
before do
|
25
|
-
stub_const("Facemock::Config::Database::DEFAULT_DB_NAME", db_name)
|
26
|
-
end
|
27
|
-
after { Facemock::Config.database.drop }
|
28
|
-
|
29
|
-
describe '#on' do
|
30
|
-
subject { Facemock.on }
|
31
|
-
it { is_expected.to be_truthy }
|
32
|
-
|
33
|
-
context 'FbGraph' do
|
34
|
-
context 'without option' do
|
35
|
-
before { Facemock.on }
|
36
|
-
it { expect(::FbGraph).to eq Facemock::FbGraph }
|
37
|
-
it { expect( lambda { Facemock.on } ).not_to raise_error }
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'with database_name option' do
|
41
|
-
before do
|
42
|
-
@options = { database_name: db_name}
|
43
|
-
Facemock.on(@options)
|
44
|
-
end
|
45
|
-
it { expect(::FbGraph).to eq Facemock::FbGraph }
|
46
|
-
it { expect( lambda { Facemock.on } ).not_to raise_error }
|
47
|
-
it { expect( lambda { Facemock.on(@options) } ).not_to raise_error }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '#off' do
|
53
|
-
subject { Facemock.off }
|
54
|
-
it { is_expected.to be_truthy }
|
55
|
-
|
56
|
-
context 'FbGraph' do
|
57
|
-
before { Facemock.off }
|
58
|
-
it { expect(FbGraph).to eq FbGraph }
|
59
|
-
it { expect( lambda { Facemock.off } ).not_to raise_error }
|
60
|
-
|
61
|
-
context 'when Mock is on' do
|
62
|
-
before do
|
63
|
-
Facemock.on
|
64
|
-
Facemock.off
|
65
|
-
end
|
66
|
-
|
67
|
-
subject { ::FbGraph }
|
68
|
-
it { is_expected.to eq FbGraph }
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
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
|
-
require 'facemock'
|