Skip to content

Commit

Permalink
Switch from factory_girl to factory_bot
Browse files Browse the repository at this point in the history
  • Loading branch information
toupeira committed Jan 19, 2019
1 parent f5aa1d4 commit b45be27
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion doorkeeper-openid_connect.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'json-jwt', '~> 1.6'

spec.add_development_dependency 'rspec-rails'
spec.add_development_dependency 'factory_girl'
spec.add_development_dependency 'factory_bot'
spec.add_development_dependency 'sqlite3'
spec.add_development_dependency 'pry-byebug'
spec.add_development_dependency 'conventional-changelog', '~> 1.2'
Expand Down
16 changes: 8 additions & 8 deletions spec/factories.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
FactoryGirl.define do
FactoryBot.define do
factory :access_grant, class: Doorkeeper::AccessGrant do
resource_owner_id { create(:user).id }
application
redirect_uri 'https://app.com/callback'
expires_in 100
scopes 'public write'
redirect_uri { 'https://app.com/callback' }
expires_in { 100 }
scopes { 'public write' }
end

factory :access_token, class: Doorkeeper::AccessToken do
resource_owner_id { create(:user).id }
application
expires_in 2.hours
expires_in { 2.hours }

factory :clientless_access_token do
application nil
application { nil }
end
end

factory :application, class: Doorkeeper::Application do
sequence(:name) { |n| "Application #{n}" }
redirect_uri 'https://app.com/callback'
redirect_uri { 'https://app.com/callback' }
end

factory :user do
current_sign_in_at Time.at(23)
current_sign_in_at { Time.at(23) }
end

factory :openid_request, class: Doorkeeper::OpenidConnect::Request do
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/oauth/id_token_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@

it 'creates a new token if scopes do not match' do
allow(Doorkeeper.configuration).to receive(:reuse_access_token).and_return(true)
FactoryGirl.create(:access_token, application_id: pre_auth.client.id,
resource_owner_id: owner.id, scopes: '')
create(:access_token, application_id: pre_auth.client.id,
resource_owner_id: owner.id, scopes: '')
expect do
subject.authorize
end.to change { Doorkeeper::AccessToken.count }.by(1)
Expand All @@ -70,8 +70,8 @@
allow(application.scopes).to receive(:has_scopes?).and_return(true)
allow(application.scopes).to receive(:all?).and_return(true)

FactoryGirl.create(:access_token, application_id: pre_auth.client.id,
resource_owner_id: owner.id, scopes: 'public')
create(:access_token, application_id: pre_auth.client.id,
resource_owner_id: owner.id, scopes: 'public')

expect { subject.authorize }.not_to change { Doorkeeper::AccessToken.count }
end
Expand Down
6 changes: 3 additions & 3 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

require_relative 'support/doorkeeper_configuration.rb'

require 'factory_girl'
FactoryGirl.find_definitions
require 'factory_bot'
FactoryBot.find_definitions

RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
Expand All @@ -48,7 +48,7 @@
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")

config.include FactoryGirl::Syntax::Methods
config.include FactoryBot::Syntax::Methods

# Reinitialize configuration after each example
config.after :each do
Expand Down

0 comments on commit b45be27

Please sign in to comment.