facemock 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,7 +38,7 @@ module Facemock
38
38
  raise Facemock::Errors::IncorrectDataFormat.new "users format is incorrect" unless validate_users(users)
39
39
 
40
40
  # Create application and user record
41
- self.database if @db
41
+ Facemock::Database::Application.new({ id: app_id, secret: app_secret }).save!
42
42
  app = Facemock::FbGraph::Application.new(app_id, secret: app_secret)
43
43
  users.each do |options|
44
44
  app.test_user!(options)
@@ -9,10 +9,11 @@ module Facemock
9
9
  TABLE_NAME = :applications
10
10
  COLUMN_NAMES = [:id, :secret, :created_at]
11
11
 
12
+ # WANT : DBに登録済みの値と重複しないようにする(id, secret)
12
13
  def initialize(options={})
13
14
  opts = Hashie::Mash.new(options)
14
15
  @id = ( opts.id.to_i > 0 ) ? opts.id.to_i : (0..9).to_a.shuffle[0..15].join.to_i
15
- @secret = opts.secret || Digest::SHA512.hexdigest(identifier.to_s)
16
+ @secret = opts.secret || rand(36**32).to_s(36)
16
17
  @created_at = opts.created_at
17
18
  end
18
19
  end
@@ -209,6 +209,8 @@ module Facemock
209
209
  def self.define_find_by_column(column_name)
210
210
  self.class_eval <<-EOF
211
211
  def self.find_by_#{column_name}(value)
212
+ return nil if value.nil?
213
+
212
214
  column_value = case value
213
215
  when String then "'" + value + "'"
214
216
  when Time then "'" + value.to_s + "'"
@@ -227,6 +229,8 @@ module Facemock
227
229
  def self.define_find_all_by_column(column_name)
228
230
  self.class_eval <<-EOF
229
231
  def self.find_all_by_#{column_name}(value)
232
+ return [] if value.nil?
233
+
230
234
  column_value = case value
231
235
  when String then "'" + value + "'"
232
236
  when Time then "'" + value.to_s + "'"
@@ -7,33 +7,42 @@ require 'facemock/database/application'
7
7
  module Facemock
8
8
  module FbGraph
9
9
  class Application
10
- attr_reader :identifier
11
- attr_reader :secret
10
+ attr_accessor :identifier
11
+ attr_accessor :secret
12
+ attr_accessor :access_token # user access token
12
13
 
13
14
  def initialize(identifier, options={})
14
15
  opts = Hashie::Mash.new(options)
15
- if (identifier == :app && opts.access_token)
16
- identifier = (0..9).to_a.shuffle[0..15].join
17
- secret = opts.access_token
18
- else
19
- secret = opts.secret || rand(36**32).to_s(36)
20
- end
21
-
22
- @record = Facemock::Database::Application.new({id: identifier, secret: secret})
23
- @record.save! unless Facemock::Database::Application.find_by_id(identifier)
24
- @identifier = identifier.to_i
25
- @secret = secret
16
+ @identifier = identifier
17
+ @secret = opts.secret
18
+ @access_token = opts.access_token
26
19
  end
27
20
 
28
21
  def fetch
29
- if @record = Facemock::Database::Application.find_by_id(@identifier)
30
- @identifier = @record.id
31
- @secret = @record.secret
22
+ @record = if @identifier == :app
23
+ unless validate_access_token
24
+ raise Facemock::FbGraph::InvalidToken.new "Invalid OAuth access token."
25
+ end
26
+ find_by_access_token
27
+ else
28
+ if @access_token && !validate_access_token
29
+ raise Facemock::FbGraph::InvalidToken.new "Invalid OAuth access token."
30
+ elsif !validate_identifier_and_secret
31
+ raise Facemock::FbGraph::InvalidRequest.new "Unsupported get request."
32
+ end
33
+ Facemock::Database::Application.find_by_id(@identifier)
34
+ end
35
+
36
+ if @record
37
+ @identifier = @record.id
38
+ @secret = @record.secret
39
+ @access_token = nil
32
40
  end
33
41
  self
34
42
  end
35
43
 
36
44
  def test_user!(options={})
45
+ validate_and_raise_error
37
46
  options.merge!({application_id: self.identifier})
38
47
  user = User.new(options)
39
48
  user.save!
@@ -41,8 +50,55 @@ module Facemock
41
50
  end
42
51
 
43
52
  def test_users(options={})
53
+ validate_and_raise_error
44
54
  TestUsers.new(self.identifier, options)
45
55
  end
56
+
57
+ private
58
+
59
+ def validate_and_raise_error()
60
+ if @access_token && !validate_access_token
61
+ raise Facemock::FbGraph::InvalidToken.new "Invalid OAuth access token."
62
+ elsif !validate_identifier_and_secret
63
+ raise Facemock::FbGraph::InvalidRequest.new "Unsupported get request."
64
+ end
65
+ end
66
+
67
+ def validate_identifier_and_secret
68
+ if validate_identifier && validate_secret
69
+ # WANT : find_by_**_and_**(**, **)の実装
70
+ app_by_id = Facemock::Database::Application.find_by_id(@identifier)
71
+ app_by_secret = Facemock::Database::Application.find_by_secret(@secret)
72
+ !!(app_by_id && app_by_secret && app_by_id.identifier == app_by_secret.identifier)
73
+ else
74
+ false
75
+ end
76
+ end
77
+
78
+ def validate_identifier
79
+ return false if @identifier.nil? || @identifier == ""
80
+ return false unless [Fixnum, String].include?(@identifier.class)
81
+ return false unless Facemock::Database::Application.find_by_id(@identifier)
82
+ true
83
+ end
84
+
85
+ def validate_secret
86
+ return false if @secret.nil? || @secret == ""
87
+ return false unless Facemock::Database::Application.find_by_secret(@secret)
88
+ true
89
+ end
90
+
91
+ def validate_access_token
92
+ !!(Facemock::Database::User.find_by_access_token(@access_token))
93
+ end
94
+
95
+ def find_by_access_token
96
+ if user = Facemock::Database::User.find_by_access_token(@access_token)
97
+ Facemock::Database::Application.find_by_id(user.application_id)
98
+ else
99
+ nil
100
+ end
101
+ end
46
102
  end
47
103
  end
48
104
  end
@@ -26,5 +26,6 @@ module Facemock
26
26
  end
27
27
 
28
28
  class InvalidToken < ::FbGraph::InvalidToken; end
29
+ class InvalidRequest < ::FbGraph::InvalidRequest; end
29
30
  end
30
31
  end
@@ -1,3 +1,3 @@
1
1
  module Facemock
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -35,7 +35,7 @@ describe Facemock::Database::Application do
35
35
 
36
36
  describe '.size' do
37
37
  subject { Facemock::Database::Application.new.secret.size }
38
- it { is_expected.to eq 128 }
38
+ it { is_expected.to be <= 32 }
39
39
  end
40
40
  end
41
41
 
@@ -451,6 +451,11 @@ describe Facemock::Database::Table do
451
451
  end
452
452
 
453
453
  describe '.find_by_id' do
454
+ context 'with nil' do
455
+ subject { Facemock::Database::Table.find_by_id(nil) }
456
+ it { is_expected.to be_nil }
457
+ end
458
+
454
459
  context 'with not id' do
455
460
  subject { Facemock::Database::Table.find_by_id("hoge") }
456
461
  it { is_expected.to be_nil }
@@ -512,6 +517,11 @@ describe Facemock::Database::Table do
512
517
  end
513
518
 
514
519
  describe '.find_all_by_id' do
520
+ context 'with nil' do
521
+ subject { Facemock::Database::Table.find_all_by_id(nil) }
522
+ it { is_expected.to be_empty }
523
+ end
524
+
515
525
  context 'with not id' do
516
526
  subject { Facemock::Database::Table.find_all_by_id("hoge") }
517
527
  it { is_expected.to be_empty }
@@ -80,7 +80,7 @@ describe Facemock::Database::User do
80
80
 
81
81
  describe '.size' do
82
82
  subject { Facemock::Database::User.new.password.size }
83
- it { is_expected.to eq 10 }
83
+ it { is_expected.to be <= 10 }
84
84
  end
85
85
  end
86
86
 
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Facemock::FbGraph::Application::TestUsers do
4
+ include ApplicationCreateHelper
5
+
4
6
  let(:db_name) { ".test" }
5
7
 
6
8
  let(:facebook_app_id) { "100000000000000" }
@@ -133,6 +135,7 @@ describe Facemock::FbGraph::Application::TestUsers do
133
135
 
134
136
  describe '#next' do
135
137
  before do
138
+ create_application({ id: facebook_app_id, secret: "test_secret" })
136
139
  @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: "test_secret")
137
140
  3.times { @app.test_user! }
138
141
  end
@@ -1,12 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Facemock::FbGraph::Application do
4
+ include ApplicationCreateHelper
5
+
4
6
  let(:db_name) { ".test" }
5
7
 
6
8
  let(:facebook_app_id) { 100000000000000 }
7
9
  let(:facebook_app_secret) { "test_secret" }
8
10
  let(:access_token) { "access_token" }
9
11
 
12
+ before do
13
+ stub_const("Facemock::Database::DEFAULT_DB_NAME", db_name)
14
+ @database = Facemock::Database.new
15
+ end
16
+ after { @database.drop }
17
+
10
18
  it 'should have a user class' do
11
19
  expect(Facemock::FbGraph::Application::User).to be_truthy
12
20
  expect(Facemock::FbGraph::Application::User.ancestors).to include Facemock::Database::User
@@ -17,115 +25,270 @@ describe Facemock::FbGraph::Application do
17
25
  expect(Facemock::FbGraph::Application::TestUsers.ancestors).to include Array
18
26
  end
19
27
 
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
28
  describe '#new' do
29
+ before { @default_record_size = Facemock::Database::Application.all.size }
30
+
27
31
  context 'without argument' do
28
32
  subject { lambda { Facemock::FbGraph::Application.new } }
29
33
  it { is_expected.to raise_error ArgumentError }
30
34
  end
31
35
 
32
- context 'with facebook app id and secret' do
33
- before { @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret) }
36
+ context 'with facebook app id' do
37
+ shared_context 'new is success and record creates', assert: :attributes_and_created_record do
38
+ it 'should set only identifier specified value by argument and record create' do
39
+ expect(@app.identifier).to eq @id
40
+ expect(@app.secret).to be_nil
41
+ expect(@app.access_token).to be_nil
42
+ expect(Facemock::Database::Application.all.size).to eq @default_record_size
43
+ end
44
+ end
45
+
46
+ context 'when facebook app id is integer', assert: :attributes_and_created_record do
47
+ before do
48
+ @id = facebook_app_id
49
+ @app = Facemock::FbGraph::Application.new(facebook_app_id)
50
+ end
51
+ end
34
52
 
35
- describe '.identifier' do
36
- subject { @app.identifier }
37
- it { is_expected.to eq facebook_app_id }
53
+ context 'when facebook app id is numerical string', assert: :attributes_and_created_record do
54
+ before do
55
+ @id = facebook_app_id.to_s
56
+ @app = Facemock::FbGraph::Application.new(@id)
57
+ end
38
58
  end
39
59
 
40
- describe '.secreet' do
41
- subject { @app.secret }
42
- it { is_expected.to eq facebook_app_secret }
60
+ context 'when facebook app id is :app' do
61
+ before do
62
+ @id = :app
63
+ @app = Facemock::FbGraph::Application.new(@id)
64
+ end
65
+
66
+ it 'should set only identifier specified value by argument and record does not create' do
67
+ expect(@app.identifier).to eq @id
68
+ expect(@app.secret).to be_nil
69
+ expect(@app.access_token).to be_nil
70
+ expect(Facemock::Database::Application.all.size).to eq @default_record_size
71
+ end
72
+ end
73
+
74
+ context 'and all options' do
75
+ before do
76
+ @options = { secret: facebook_app_secret, access_token: access_token }
77
+ @app = Facemock::FbGraph::Application.new(facebook_app_id, @options)
78
+ end
79
+
80
+ it 'should set all attributes specified value by argument' do
81
+ expect(@app.identifier).to eq facebook_app_id
82
+ expect(@app.secret).to eq @options[:secret]
83
+ expect(@app.access_token).to eq @options[:access_token]
84
+ expect(Facemock::Database::Application.all.size).to eq @default_record_size
85
+ end
43
86
  end
44
87
  end
88
+ end
45
89
 
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)
90
+ describe '#fetch' do
91
+ context 'when instance identifier is nil' do
92
+ before { @app = Facemock::FbGraph::Application.new(nil) }
93
+ subject { lambda { @app.fetch } }
94
+ it { is_expected.to raise_error Facemock::FbGraph::InvalidRequest }
95
+ end
96
+
97
+ context 'when instance identifier is empty string' do
98
+ before { @app = Facemock::FbGraph::Application.new("") }
99
+ subject { lambda { @app.fetch } }
100
+ it { is_expected.to raise_error Facemock::FbGraph::InvalidRequest }
101
+ end
102
+
103
+ context 'when instance identifier is integer' do
104
+ context 'and secret is not specified' do
105
+ before { @app = Facemock::FbGraph::Application.new(facebook_app_id) }
106
+ subject { lambda { @app.fetch } }
107
+ it { is_expected.to raise_error Facemock::FbGraph::InvalidRequest }
50
108
  end
51
109
 
52
- describe '.identifier' do
53
- subject { @app.identifier }
54
- it { is_expected.to eq facebook_app_id }
110
+ context 'and incorrect secret is specified' do
111
+ before do
112
+ Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
113
+ @app = Facemock::FbGraph::Application.new(facebook_app_id)
114
+ @app.secret = "incorrect_secret"
115
+ end
116
+ subject { lambda { @app.fetch } }
117
+ it { is_expected.to raise_error Facemock::FbGraph::InvalidRequest }
55
118
  end
56
119
 
57
- describe '.secreet' do
58
- subject { @app.secret }
59
- it { is_expected.to eq facebook_app_secret }
120
+ context 'and the other application secret is specified' do
121
+ before do
122
+ secret = "other_secret"
123
+ app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
124
+ app = Facemock::FbGraph::Application.new(facebook_app_id + 1, secret: secret)
125
+ @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: secret)
126
+ end
127
+ subject { lambda { @app.fetch } }
128
+ it { is_expected.to raise_error Facemock::FbGraph::InvalidRequest }
129
+ end
130
+
131
+ context 'and correct secret is specified' do
132
+ before do
133
+ create_application({ id: facebook_app_id, secret: facebook_app_secret })
134
+ @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
135
+ end
136
+
137
+ subject { @app.fetch }
138
+ it { is_expected.to be_kind_of Facemock::FbGraph::Application }
139
+
140
+ it 'should not change identifier and secret' do
141
+ identifier = @app.identifier
142
+ secret = @app.secret
143
+ @app.fetch
144
+ expect(@app.identifier).to eq identifier
145
+ expect(@app.secret).to eq secret
146
+ expect(@app.access_token).to be_nil
147
+ end
148
+
149
+ context 'and incorrect access_token is specified' do
150
+ before do
151
+ @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
152
+ @app.access_token = "incorrect_token"
153
+ end
154
+ subject { lambda { @app.fetch } }
155
+ it { is_expected.to raise_error Facemock::FbGraph::InvalidToken }
156
+ end
60
157
  end
61
158
  end
62
159
 
63
- context 'with app symbole and access_token' do
64
- before { @app = Facemock::FbGraph::Application.new(:app, access_token: access_token) }
160
+ context 'when instance identifier is :app' do
161
+ context 'and access token is not specified' do
162
+ before { @app = Facemock::FbGraph::Application.new(:app) }
163
+ subject { lambda { @app.fetch } }
164
+ it { is_expected.to raise_error Facemock::FbGraph::InvalidToken }
165
+ end
65
166
 
66
- describe '.identifier' do
67
- subject { @app.identifier }
68
- it { is_expected.to be_kind_of Integer }
167
+ context 'and access token is incorrect' do
168
+ before { @app = Facemock::FbGraph::Application.new(:app, access_token: "incorrect_token") }
169
+ subject { lambda { @app.fetch } }
170
+ it { is_expected.to raise_error Facemock::FbGraph::InvalidToken }
69
171
  end
70
172
 
71
- describe '.secreet' do
72
- subject { @app.secret }
73
- it { is_expected.not_to be_empty }
173
+ context 'and access token is correct' do
174
+ before do
175
+ create_application({ id: facebook_app_id, secret: facebook_app_secret})
176
+ app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
177
+ user = app.test_user!
178
+ @access_token = user.access_token
179
+ end
180
+
181
+ it 'should set all attributes specified value by argument' do
182
+ app = Facemock::FbGraph::Application.new(:app, access_token: @access_token)
183
+ app.fetch
184
+ expect(app.identifier).to eq facebook_app_id
185
+ expect(app.secret).to eq facebook_app_secret
186
+ expect(app.access_token).to be_nil
187
+ end
74
188
  end
75
189
  end
76
190
  end
77
191
 
78
- describe '#fetch' do
79
- before { @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret) }
192
+ describe '#test_user!' do
193
+ context 'when incorrect access token is specified' do
80
194
 
81
- describe '.identifier' do
82
- subject { @app.fetch.identifier }
83
- it { is_expected.to eq @app.identifier }
195
+ it 'should raise error Facemoc::FbGraph::InvalidToken' do
196
+ app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
197
+ app.access_token = "incorrect_token"
198
+ expect(lambda { app.test_user! }).to raise_error Facemock::FbGraph::InvalidToken
199
+ end
84
200
  end
85
201
 
86
- describe '.secret' do
87
- subject { @app.fetch.secret }
88
- it { is_expected.to eq @app.secret }
202
+ context 'when identifier or secret is incorrect' do
203
+ before { Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret) }
204
+
205
+ it 'should raise error Facemoc::FbGraph::InvalidRequest' do
206
+ app = Facemock::FbGraph::Application.new(nil)
207
+ [nil, "", "hoge", facebook_app_id].each do |id|
208
+ app.identifier = id
209
+ [nil, "", "hoge"].each do |secret|
210
+ app.secret = secret
211
+ expect(lambda { app.test_user! }).to raise_error Facemock::FbGraph::InvalidRequest
212
+ end
213
+ end
214
+ end
89
215
  end
90
- end
91
216
 
92
- describe '#test_user!' do
93
- before { @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret) }
217
+ context 'when identifier and secret is correct' do
218
+ before do
219
+ create_application({ id: facebook_app_id, secret: facebook_app_secret })
220
+ @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
221
+ end
94
222
 
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)
223
+ it 'should created user' do
224
+ expect(Facemock::FbGraph::Application::User.all).to be_empty
225
+ created_user = @app.test_user!
226
+ finded_user = Facemock::FbGraph::Application::User.find_by_id(created_user.id)
227
+ Facemock::FbGraph::Application::User.column_names.each do |column_name|
228
+ expect(created_user.send(column_name)).to eq finded_user.send(column_name)
229
+ end
101
230
  end
102
231
  end
103
232
  end
104
233
 
105
234
  describe '#test_users' do
106
- before do
107
- @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
235
+ context 'when identifier is invalid' do
236
+ before { Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret) }
237
+
238
+ it 'should raise error Facemock::FbGraph::InvalidRequest' do
239
+ [nil, "", facebook_app_id + 1].each do |id|
240
+ app = Facemock::FbGraph::Application.new(id)
241
+ expect(lambda{ app.test_users }).to raise_error Facemock::FbGraph::InvalidRequest
242
+ end
243
+ end
108
244
  end
109
245
 
110
- context 'when test_user is not created' do
111
- subject { @app.test_users }
246
+ context 'when secret is invalid' do
247
+ before { Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret) }
248
+
249
+ it 'should raise error Facemock::FbGraph::InvalidRequest' do
250
+ [nil, "", "incorrect_secret"].each do |secret|
251
+ app = Facemock::FbGraph::Application.new(facebook_app_id)
252
+ app.secret = secret
253
+ expect(lambda{ app.test_users }).to raise_error Facemock::FbGraph::InvalidRequest
254
+ end
255
+ end
256
+ end
112
257
 
113
- it { is_expected.to be_kind_of Facemock::FbGraph::Application::TestUsers }
114
- it { is_expected.to be_empty }
258
+ context 'when access_token is invalid' do
259
+ it 'should raise error Facemock::FbGraph::InvalidToken' do
260
+ app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
261
+ app.access_token = "incorrect_token"
262
+ expect(lambda{ app.test_users }).to raise_error Facemock::FbGraph::InvalidToken
263
+ end
115
264
  end
116
265
 
117
- context 'when test_user is created' do
266
+ context 'when identifier and secret is correct' do
118
267
  before do
119
- @user = @app.test_user!
268
+ create_application({ id: facebook_app_id, secret: facebook_app_secret })
269
+ @app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
120
270
  end
121
271
 
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 }
272
+ context 'when test_user is not created' do
273
+ subject { @app.test_users }
274
+
275
+ it { is_expected.to be_kind_of Facemock::FbGraph::Application::TestUsers }
276
+ it { is_expected.to be_empty }
277
+ end
278
+
279
+ context 'when test_user is created' do
280
+ before do
281
+ @user = @app.test_user!
282
+ end
283
+
284
+ subject { @app.test_users }
285
+ it { is_expected.to be_kind_of Facemock::FbGraph::Application::TestUsers }
286
+ it { is_expected.not_to be_empty }
125
287
 
126
- describe '.first.id' do
127
- subject { @app.test_users.first.id }
128
- it { is_expected.to eq @user.id }
288
+ describe '.first.id' do
289
+ subject { @app.test_users.first.id }
290
+ it { is_expected.to eq @user.id }
291
+ end
129
292
  end
130
293
  end
131
294
  end
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Facemock::FbGraph::User do
4
+ include ApplicationCreateHelper
5
+
4
6
  let(:db_name) { ".test" }
5
7
 
6
8
  let(:facebook_app_id) { "100000000000000" }
@@ -15,6 +17,7 @@ describe Facemock::FbGraph::User do
15
17
  describe '.me' do
16
18
  context 'when access_token is correct' do
17
19
  before do
20
+ create_application({ id: facebook_app_id, secret: "test_secret" })
18
21
  app = Facemock::FbGraph::Application.new(facebook_app_id, secret: facebook_app_secret)
19
22
  @user = app.test_user!
20
23
  @access_token = @user.access_token
@@ -9,8 +9,9 @@ describe Facemock::FbGraph do
9
9
  expect(Facemock::FbGraph::User).to be_truthy
10
10
  end
11
11
 
12
- it 'should have a invalid_token class' do
12
+ it 'should have a error class' do
13
13
  expect(Facemock::FbGraph::InvalidToken).to be_truthy
14
+ expect(Facemock::FbGraph::InvalidRequest).to be_truthy
14
15
  end
15
16
 
16
17
  describe '#on' do
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Facemock do
4
- let(:version) { '0.0.5' }
4
+ let(:version) { '0.0.6' }
5
5
  let(:db_name) { '.test' }
6
6
 
7
7
  describe 'VERSION' do
@@ -0,0 +1,5 @@
1
+ module ApplicationCreateHelper
2
+ def create_application(options={})
3
+ Facemock::Database::Application.new(options).save!
4
+ end
5
+ 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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-26 00:00:00.000000000 Z
12
+ date: 2014-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3
@@ -202,6 +202,7 @@ files:
202
202
  - spec/facemock/fb_graph_spec.rb
203
203
  - spec/facemock_spec.rb
204
204
  - spec/spec_helper.rb
205
+ - spec/support/application_create_helper.rb
205
206
  - spec/support/tables_helper.rb
206
207
  homepage: https://github.com/ogawatti/facemock
207
208
  licenses:
@@ -218,7 +219,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
219
  version: '0'
219
220
  segments:
220
221
  - 0
221
- hash: 28983518924956575
222
+ hash: -2374315487424674791
222
223
  required_rubygems_version: !ruby/object:Gem::Requirement
223
224
  none: false
224
225
  requirements:
@@ -227,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
228
  version: '0'
228
229
  segments:
229
230
  - 0
230
- hash: 28983518924956575
231
+ hash: -2374315487424674791
231
232
  requirements: []
232
233
  rubyforge_project:
233
234
  rubygems_version: 1.8.25
@@ -249,4 +250,5 @@ test_files:
249
250
  - spec/facemock/fb_graph_spec.rb
250
251
  - spec/facemock_spec.rb
251
252
  - spec/spec_helper.rb
253
+ - spec/support/application_create_helper.rb
252
254
  - spec/support/tables_helper.rb