Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit d8b8929

Browse files
committed
Fix a broken unit test
1 parent e8ae7cb commit d8b8929

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/requirejs-rails_test.rb

+10-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ def setup
2727
@cfg = Requirejs::Rails::Config.new(Rails.application)
2828
end
2929

30+
def asset_allowed?(asset_path)
31+
!!@cfg.logical_path_patterns.find do |logical_path_pattern|
32+
logical_path_pattern.match(asset_path)
33+
end
34+
end
35+
3036
test "config accepts known loaders" do
3137
@cfg.loader = :almond
3238
assert_equal :almond, @cfg.loader
@@ -39,10 +45,10 @@ def setup
3945
end
4046

4147
test "matches configured logical assets" do
42-
assert_equal true, @cfg.asset_allowed?('foo.js')
43-
assert_equal false, @cfg.asset_allowed?('bar.frobnitz')
44-
@cfg.logical_path_patterns += [/\.frobnitz$/]
45-
assert_equal true, @cfg.asset_allowed?('bar.frobnitz')
48+
assert_equal true, asset_allowed?("foo.js")
49+
assert_equal false, asset_allowed?("bar.frobnitz")
50+
@cfg.logical_path_patterns.push(Regexp.new("\\.frobnitz\\z"))
51+
assert_equal true, asset_allowed?("bar.frobnitz")
4652
end
4753

4854
test "should have a default empty user_config" do

0 commit comments

Comments
 (0)