Skip to content

Commit

Permalink
Add spec helper to generate gems for integration testing
Browse files Browse the repository at this point in the history
  • Loading branch information
apexatoll committed Sep 24, 2023
1 parent 4c517c4 commit bd5365c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ def load_support_files!
config.order = :random

config.include FileHelper
config.include GemHelper
config.include TempDirHelper
end
21 changes: 21 additions & 0 deletions spec/support/gem_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "tmpdir"

module GemHelper
RSpec.configure do |config|
config.around(with_gem: true) do |spec|
self.class.class_eval { attr_reader :gem }

Dir.mktmpdir do |dir|
@gem = Kangaru::Testing::Gem.new(dir:).tap(&:create!)

spec.run

Object.send(:remove_const, :SomeGem) if Object.const_defined?(:SomeGem)

if Kangaru.instance_variable_defined?(:@application)
Kangaru.remove_instance_variable(:@application)
end
end
end
end
end

0 comments on commit bd5365c

Please sign in to comment.