Skip to content

Commit

Permalink
Merge pull request #4242 from samvera/attempting-to-squash-a-flappy-test
Browse files Browse the repository at this point in the history
Attempting to squash a flappy test
  • Loading branch information
jeremyf authored Feb 1, 2020
2 parents a37a5c9 + 82be9be commit 600753e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/wings/orm_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def self.base_for(klass:)
end

##
# @param klass [String] an `ActiveFedora` model
# @param klass [Class] an `ActiveFedora` model class
#
# @return [Class] a dyamically generated `Valkyrie::Resource` subclass
# mirroring the provided `ActiveFedora` model
Expand Down
22 changes: 13 additions & 9 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ def ci_build?
# FIXME: Pin to older version of chromedriver to avoid issue with clicking non-visible elements
Webdrivers::Chromedriver.version = '72.0.3626.69'

ActiveJob::Base.queue_adapter = :test

# require 'http_logger'
# HttpLogger.logger = Logger.new(STDOUT)
# HttpLogger.ignore = [/localhost:8983\/solr/]
Expand Down Expand Up @@ -152,6 +150,8 @@ def main_app
query_registration_target.register_query_handler(handler)
end

ActiveJob::Base.queue_adapter = :test

require 'active_fedora/cleaner'
RSpec.configure do |config|
config.disable_monkey_patching!
Expand Down Expand Up @@ -294,23 +294,27 @@ def main_app
#
# ActiveJob::Base.queue_adapter.filter = [JobClass]
#
config.before(:example, :perform_enqueued) do |example|
config.around(:example, :perform_enqueued) do |example|
ActiveJob::Base.queue_adapter.filter =
example.metadata[:perform_enqueued].try(:to_a)

ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true
ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = true
end

config.after(:example, :perform_enqueued) do
ActiveJob::Base.queue_adapter.filter = nil
ActiveJob::Base.queue_adapter.enqueued_jobs = []
ActiveJob::Base.queue_adapter.performed_jobs = []
example.run

ActiveJob::Base.queue_adapter.filter = nil
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = false
ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = false
end

# Ensuring we have a clear queue between each spec. This appears to
# resolve a "flappy spec" problem (found in seed 2816 for
# SHA da3b4632b45a8bf22100f691612d299a0ac79448 of the code base)
config.after do
ActiveJob::Base.queue_adapter.enqueued_jobs = []
ActiveJob::Base.queue_adapter.performed_jobs = []
end

config.before(:example, :valkyrie_adapter) do |example|
adapter_name = example.metadata[:valkyrie_adapter]

Expand Down
2 changes: 1 addition & 1 deletion spec/wings/orm_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

context 'when given a non-ActiveFedora class' do
it 'raises an exception' do
expect { described_class.to_valkyrie_resource_class(klass: String) }.to raise_error
expect { described_class.to_valkyrie_resource_class(klass: String) }.to raise_error(NoMethodError)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
context 'when list includes an invalid id' do
let(:id_list) { [work1.id, work2.id, '1212121212'] }

it 'returns error' do
expect { subject } .to raise_error
it 'raises an exception' do
expect { subject } .to raise_error(NameError)
end
end
end
Expand Down

0 comments on commit 600753e

Please sign in to comment.