Module: Tapioca::Helpers::Test::Content
- Extended by:
- T::Helpers, T::Sig
- Included in:
- DslCompiler
- Defined in:
- lib/tapioca/helpers/test/content.rb
Instance Method Summary collapse
- #add_content_file(name, content) ⇒ Object
- #add_ruby_file(name, content, require_file: true) ⇒ Object
- #remove_tmp_path ⇒ Object
- #teardown ⇒ Object
- #tmp_path(*args) ⇒ Object
Instance Method Details
#add_content_file(name, content) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/tapioca/helpers/test/content.rb', line 39 def add_content_file(name, content) file_name = tmp_path("lib/#{name}") raise ArgumentError, "a file named '#{name}' was already added; cannot overwrite." if File.exist?(file_name) FileUtils.mkdir_p(File.dirname(file_name)) File.write(file_name, content) file_name end |
#add_ruby_file(name, content, require_file: true) ⇒ Object
32 33 34 35 36 |
# File 'lib/tapioca/helpers/test/content.rb', line 32 def add_ruby_file(name, content, require_file: true) add_content_file(name, content).tap do |file_name| Tapioca.silence_warnings { require(file_name) } if require_file end end |
#remove_tmp_path ⇒ Object
27 28 29 |
# File 'lib/tapioca/helpers/test/content.rb', line 27 def remove_tmp_path FileUtils.rm_rf(tmp_path) end |
#teardown ⇒ Object
14 15 16 17 |
# File 'lib/tapioca/helpers/test/content.rb', line 14 def teardown super remove_tmp_path end |