From 8e9c61fe5b9054cc2defc3f050221edb909b00f3 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Mon, 13 May 2019 16:46:13 +0200 Subject: [PATCH] Change from rake Task to a single spec This has the advantage that if you run the whole suite it gets run automatically but if you run a single test it doesn't. This seems like the best of both worlds.. --- lib/tasks/factorybot.rake | 8 -------- spec/factorybot_lint_spec.rb | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 8 deletions(-) delete mode 100644 lib/tasks/factorybot.rake create mode 100644 spec/factorybot_lint_spec.rb diff --git a/lib/tasks/factorybot.rake b/lib/tasks/factorybot.rake deleted file mode 100644 index 7ae5e59..0000000 --- a/lib/tasks/factorybot.rake +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -namespace :factorybot do - desc 'Lint FactoryBot factories' - task lint: :environment do - FactoryBot.lint - end -end diff --git a/spec/factorybot_lint_spec.rb b/spec/factorybot_lint_spec.rb new file mode 100644 index 0000000..a75aa6f --- /dev/null +++ b/spec/factorybot_lint_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +# spec/lint_spec.rb + +require 'rails_helper' + +RSpec.describe 'Lint' do + it 'FactoryBot factories' do + conn = ActiveRecord::Base.connection + conn.transaction do + FactoryBot.lint + raise ActiveRecord::Rollback + end + end +end