-
Notifications
You must be signed in to change notification settings - Fork 21.6k
/
rails_helper_generator_test.rb
36 lines (29 loc) · 1.12 KB
/
rails_helper_generator_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require File.expand_path('../generator_test_helper', __FILE__)
class RailsHelperGeneratorTest < GeneratorTestCase
def test_helper_generates_helper
run_generator('helper', %w(products))
assert_generated_helper_for :products
assert_generated_helper_test_for :products
end
def test_helper_generates_namespaced_helper
run_generator('helper', %w(admin::products))
assert_generated_helper_for "admin::products"
assert_generated_helper_test_for "admin::products"
end
def test_helper_generates_namespaced_and_not_namespaced_helpers
run_generator('helper', %w(products))
# We have to require the generated helper to show the problem because
# the test helpers just check for generated files and contents but
# do not actually load them. But they have to be loaded (as in a real environment)
# to make the second generator run fail
require "#{RAILS_ROOT}/app/helpers/products_helper"
assert_nothing_raised do
begin
run_generator('helper', %w(admin::products))
ensure
# cleanup
Object.send(:remove_const, :ProductsHelper)
end
end
end
end