spec/facemock/fb_graph/application/user_spec.rb in facemock-0.0.6 vs spec/facemock/fb_graph/application/user_spec.rb in facemock-0.0.7
- old
+ new
@@ -15,15 +15,10 @@
application_id: 1 } }
before { stub_const("Facemock::Database::DEFAULT_DB_NAME", db_name) }
after { Facemock::Database.new.drop }
- it 'should have a permission class' do
- expect(Facemock::FbGraph::Application::User::Permission).to be_truthy
- expect(Facemock::FbGraph::Application::User::Permission.ancestors).to include Facemock::Database::Permission
- end
-
describe '#new' do
context 'without options' do
subject { lambda { Facemock::FbGraph::Application::User.new } }
it { is_expected.not_to raise_error }
@@ -144,12 +139,11 @@
end
describe '#destroy' do
context 'when does not have permission' do
before do
- @user = Facemock::FbGraph::Application::User.new(options)
- @user.save!
+ @user = Facemock::FbGraph::Application::User.create!(options)
end
subject { lambda { @user.destroy } }
it { is_expected.not_to raise_error }
@@ -161,42 +155,39 @@
end
context 'when have some permissions' do
before do
opts = { application_id: 1, permissions: "email, read_stream" }
- @user = Facemock::FbGraph::Application::User.new(opts)
- @user.save!
+ @user = Facemock::FbGraph::Application::User.create!(opts)
end
subject { lambda { @user.destroy } }
it { is_expected.not_to raise_error }
it 'user and permission does not exist' do
@user.destroy
expect(Facemock::FbGraph::Application::User.find_by_id(@user.id)).to be_nil
expect(Facemock::FbGraph::Application::User::Permission.find_all_by_user_id(@user.id)).to be_empty
- expect(@user.permissions).not_to be_empty
- expect(@user.permission_objects).not_to be_empty
+ expect(@user.permissions).to be_empty
+ expect(@user.permission_objects).to be_empty
end
end
end
describe '#revoke!' do
context 'when does not have permission' do
before do
- @user = Facemock::FbGraph::Application::User.new(options)
- @user.save!
+ @user = Facemock::FbGraph::Application::User.create!(options)
end
subject { lambda { @user.revoke! } }
it { is_expected.not_to raise_error }
end
context 'when have some permissions' do
before do
opts = { application_id: 1, permissions: "email, read_stream" }
- @user = Facemock::FbGraph::Application::User.new(opts)
- @user.save!
+ @user = Facemock::FbGraph::Application::User.create!(opts)
end
it 'should destroy permissions' do
@user.revoke!
expect(Facemock::FbGraph::Application::User::Permission.find_by_user_id(@user.id)).to be_nil