Skip to content

Instantly share code, notes, and snippets.

@garethrees
Last active September 7, 2017 11:26
Show Gist options
  • Select an option

  • Save garethrees/5f0a10c547f19725a4cbbe992aa602af to your computer and use it in GitHub Desktop.

Select an option

Save garethrees/5f0a10c547f19725a4cbbe992aa602af to your computer and use it in GitHub Desktop.
Lint alaveteli factories
# -*- encoding : utf-8 -*-
require 'rspec/rails'
require Rails.root.join("spec", "support", "load_file_fixtures")
require Rails.root.join("spec", "support", "email_helpers")
RSpec.configure do |config|
config.fixture_path = Rails.root.join("spec","fixtures")
end
namespace :factory_girl do
desc "Verify that all FactoryGirl factories are valid"
task lint: :environment do
if Rails.env.test?
begin
#DatabaseCleaner.start
FactoryGirl.lint
ensure
#DatabaseCleaner.clean
end
else
system("bundle exec rake factory_girl:lint RAILS_ENV='test'")
end
end
end
FactoryGirl::InvalidFactoryError: The following factories are invalid:
* draft_info_request_batch - AlaveteliPro::RequestSummaryCategory(#61492080) expected, got NilClass(#10280920) (ActiveRecord::AssociationTypeMismatch)
* expiring_embargo - AlaveteliPro::RequestSummaryCategory(#61492080) expected, got NilClass(#10280920) (ActiveRecord::AssociationTypeMismatch)
* draft_request_summary - AlaveteliPro::RequestSummaryCategory(#61492080) expected, got NilClass(#10280920) (ActiveRecord::AssociationTypeMismatch)
* batch_request_summary - AlaveteliPro::RequestSummaryCategory(#61492080) expected, got NilClass(#10280920) (ActiveRecord::AssociationTypeMismatch)
* draft_batch_request_summary - AlaveteliPro::RequestSummaryCategory(#61492080) expected, got NilClass(#10280920) (ActiveRecord::AssociationTypeMismatch)
* draft_info_request - AlaveteliPro::RequestSummaryCategory(#61492080) expected, got NilClass(#10280920) (ActiveRecord::AssociationTypeMismatch)
* draft_with_no_duration - AlaveteliPro::RequestSummaryCategory(#61492080) expected, got NilClass(#10280920) (ActiveRecord::AssociationTypeMismatch)
* foi_attachment - Validation failed: FoiAttachment|Content type can't be blank, FoiAttachment|Display size can't be blank (ActiveRecord::RecordInvalid)
* info_request_batch - AlaveteliPro::RequestSummaryCategory(#61492080) expected, got NilClass(#10280920) (ActiveRecord::AssociationTypeMismatch)
* embargoed_batch_request - AlaveteliPro::RequestSummaryCategory(#61492080) expected, got NilClass(#10280920) (ActiveRecord::AssociationTypeMismatch)
* embargo_expiring_request - AlaveteliPro::RequestSummaryCategory(#61492080) expected, got NilClass(#10280920) (ActiveRecord::AssociationTypeMismatch)
* outgoing_message - undefined method `status' for #<FactoryGirl::SyntaxRunner:0x0000000a7a9e00> (NoMethodError)
* post_redirect - undefined method `frontpage_path' for #<FactoryGirl::SyntaxRunner:0x0000000c7a8cd8> (NoMethodError)
* public_body_change_request - Validation failed: PublicBodyChangeRequest|Public body name Please enter the name of the authority (ActiveRecord::RecordInvalid)
* role - Validation failed: Role|Name is not included in the list (ActiveRecord::RecordInvalid)
* user_track - undefined local variable or method `user' for #<FactoryGirl::SyntaxRunner:0x0000000b5f7b10> (NameError)
RAILS_ENV=test bundle exec rake factory_girl:lint
RAILS_ENV=test bundle exec rake db:drop db:create db:migrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment