Skip to content

Commit

Permalink
Skip gems when adding load paths (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Evanczuk authored Jan 6, 2023
1 parent dc11fdb commit be61909
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 8 deletions.
3 changes: 1 addition & 2 deletions lib/stimpack/integrations/factory_bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ def initialize(app)
return unless app.config.respond_to?(:factory_bot)
Stimpack.configure_packs

Packs.all.each do |pack|
next if pack.relative_path.glob('*.gemspec').any?
Packs.all.reject(&:is_gem?).each do |pack|
app.config.factory_bot.definition_file_paths << pack.relative_path.join("spec/factories").to_s
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/stimpack/integrations/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ def initialize(app)
end

def create_engines
Packs.all.each do |pack|
Packs.all.reject(&:is_gem?).each do |pack|
next unless pack.metadata['engine']

create_engine(pack)
end
end

def inject_paths
Packs.all.each do |pack|
Packs.all.reject(&:is_gem?).each do |pack|
Stimpack.config.paths.each do |path|
@app.paths[path] << pack.relative_path.join(path)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/stimpack/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Stimpack
VERSION = "0.8.2".freeze
VERSION = "0.8.3".freeze
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@
c.syntax = :expect
end
end

def require_test_rails_application
rails_dir = Pathname.new(File.expand_path("fixtures/rails-7.0", __dir__))
Dir.chdir(rails_dir)
require_relative rails_dir.join("config/environment")
rails_dir
end
10 changes: 7 additions & 3 deletions spec/stimpack_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require "pathname"

rails_dir = Pathname.new(File.expand_path("fixtures/rails-7.0", __dir__))
Dir.chdir(rails_dir)
require_relative rails_dir.join("config/environment")
rails_dir = require_test_rails_application

RSpec.describe Stimpack do
it "autoloads classes in autoload paths" do
Expand All @@ -15,6 +13,12 @@
end
end

it "does not add gem paths to the application" do
Stimpack.config.paths.each do |path|
expect(Rails.application.paths[path].paths).to_not include(rails_dir.join('components', "jackets", path))
end
end

it "creates engines namespace for engine packs" do
expect(defined?(Shoes::Engine)).to eq("constant")
end
Expand Down

0 comments on commit be61909

Please sign in to comment.