Skip to content

Commit be61909

Browse files
author
Alex Evanczuk
authored
Skip gems when adding load paths (#50)
1 parent dc11fdb commit be61909

File tree

9 files changed

+21
-8
lines changed

9 files changed

+21
-8
lines changed

lib/stimpack/integrations/factory_bot.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ def initialize(app)
77
return unless app.config.respond_to?(:factory_bot)
88
Stimpack.configure_packs
99

10-
Packs.all.each do |pack|
11-
next if pack.relative_path.glob('*.gemspec').any?
10+
Packs.all.reject(&:is_gem?).each do |pack|
1211
app.config.factory_bot.definition_file_paths << pack.relative_path.join("spec/factories").to_s
1312
end
1413
end

lib/stimpack/integrations/rails.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ def initialize(app)
1717
end
1818

1919
def create_engines
20-
Packs.all.each do |pack|
20+
Packs.all.reject(&:is_gem?).each do |pack|
2121
next unless pack.metadata['engine']
2222

2323
create_engine(pack)
2424
end
2525
end
2626

2727
def inject_paths
28-
Packs.all.each do |pack|
28+
Packs.all.reject(&:is_gem?).each do |pack|
2929
Stimpack.config.paths.each do |path|
3030
@app.paths[path] << pack.relative_path.join(path)
3131
end

lib/stimpack/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Stimpack
2-
VERSION = "0.8.2".freeze
2+
VERSION = "0.8.3".freeze
33
end
Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/rails-7.0/components/jackets/app/views/show.html.erb

Whitespace-only changes.

spec/fixtures/rails-7.0/components/jackets/jackets.gemspec

Whitespace-only changes.

spec/fixtures/rails-7.0/components/jackets/package.yml

Whitespace-only changes.

spec/spec_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@
1212
c.syntax = :expect
1313
end
1414
end
15+
16+
def require_test_rails_application
17+
rails_dir = Pathname.new(File.expand_path("fixtures/rails-7.0", __dir__))
18+
Dir.chdir(rails_dir)
19+
require_relative rails_dir.join("config/environment")
20+
rails_dir
21+
end

spec/stimpack_spec.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
require "pathname"
22

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

75
RSpec.describe Stimpack do
86
it "autoloads classes in autoload paths" do
@@ -15,6 +13,12 @@
1513
end
1614
end
1715

16+
it "does not add gem paths to the application" do
17+
Stimpack.config.paths.each do |path|
18+
expect(Rails.application.paths[path].paths).to_not include(rails_dir.join('components', "jackets", path))
19+
end
20+
end
21+
1822
it "creates engines namespace for engine packs" do
1923
expect(defined?(Shoes::Engine)).to eq("constant")
2024
end

0 commit comments

Comments
 (0)