1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #41203 from jonathanhefner/generator-test-stub-thor-apply

Avoid testing Thor internals
This commit is contained in:
Rafael França 2021-01-21 15:13:42 -05:00 committed by GitHub
commit a1c5529f50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,18 +82,17 @@ module SharedGeneratorTests
end
def test_template_is_executed_when_supplied_an_https_path
path = "https://gist.github.com/josevalim/103208/raw/"
template = +%{ say "It works!" }
template.instance_eval "def read; self; end" # Make the string respond to read
url = "https://gist.github.com/josevalim/103208/raw/"
generator([destination_root], template: url, skip_webpack_install: true)
check_open = -> *args do
assert_equal [ path, "Accept" => "application/x-thor-template" ], args
template
applied = nil
apply_stub = -> (path, *) { applied = path }
generator.stub(:apply, apply_stub) do
run_generator_instance
end
generator([destination_root], template: path, skip_webpack_install: true).stub(:open, check_open, template) do
assert_match(/It works!/, run_generator_instance)
end
assert_equal url, applied
end
def test_skip_gemfile