Skip to content

Commit

Permalink
✅ test that Hyrax::Flexibility module is included
Browse files Browse the repository at this point in the history
In this commit, we test that a module is included when the HYRAX_FLEXIBLE env var is set.
Issue:
- notch8/amigos#20
  • Loading branch information
Shana Moore committed Jun 11, 2024
1 parent 6f9935b commit 6209db7
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions spec/models/hyrax/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,41 @@

it_behaves_like 'a Hyrax::Resource'

before do
@hyrax_flexible_env_var = ENV['HYRAX_FLEXIBLE']
end

after do
ENV.delete('HYRAX_FLEXIBLE')
end

def load_resource_model
Hyrax.send(:remove_const, :Resource) if defined?(Hyrax::Resource)
load File.join('/app/samvera/hyrax-engine/app/models/hyrax/resource.rb')
end

context 'when HYRAX_FLEXIBLE environment variable is set' do
before do
ENV['HYRAX_FLEXIBLE'] = 'true'
load_resource_model
end

it 'includes the Hyrax::Flexibility module' do
expect(Hyrax::Resource.included_modules).to include(Hyrax::Flexibility)
end
end

context 'when HYRAX_FLEXIBLE environment variable is not set' do
before do
ENV.delete('HYRAX_FLEXIBLE')
load_resource_model
end

it 'does not include the Hyrax::Flexibility module' do
expect(Hyrax::Resource.included_modules).not_to include(Hyrax::Flexibility)
end
end

describe '#events' do
it 'includes Hyrax::WithEvents' do
expect(resource).to respond_to(:events)
Expand Down

0 comments on commit 6209db7

Please sign in to comment.