Skip to content

Commit

Permalink
set up factorybot to create test objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Nov 26, 2024
1 parent e714902 commit e0217f0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ gem "rubocop-rails-omakase", require: false
gem "rspec-rails"
gem "database_cleaner-active_record"
gem "factory_bot_rails"

gem "faker", "~> 3.5"
5 changes: 5 additions & 0 deletions spec/factories/actor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FactoryBot.define do
factory :actor, class: 'Federails::Actor' do
username { Faker::Internet.username separators: [ '-', '_' ] }
end
end
2 changes: 1 addition & 1 deletion spec/requests/reports_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RSpec.describe "Reports" do
let(:actor) { Federails::Actor.create }
let(:actor) { create :actor }
let(:report_body) {
<<-EOF
{
Expand Down
10 changes: 10 additions & 0 deletions spec/support/factory_bot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

require "factory_bot"

RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
FactoryBot.definition_file_paths = [Federails::Moderation::Engine.root.join("spec/factories")]

Check failure on line 6 in spec/support/factory_bot.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.

Check failure on line 6 in spec/support/factory_bot.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
config.before(:suite) do
FactoryBot.find_definitions
end
end

0 comments on commit e0217f0

Please sign in to comment.