Module: Rspec::Rails::Generators
- Defined in:
- lib/rspec/rails/generators.rb,
lib/rspec/rails/generators/config.rb,
lib/rspec/rails/generators/helper.rb,
lib/rspec/rails/generators/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Method Summary collapse
- #cleanup_destination ⇒ Object
- #expect_file(file_path) {|File.read(destination_file_path)| ... } ⇒ Object
- #not_expect_file(file_path) ⇒ Object
- #prepare_destination ⇒ Object
-
#run_generator(generator_class, args = default_arguments, config = {}) ⇒ Object
Mimics railties/lib/rails/generators/testing/behaviour.rb.
Instance Method Details
#cleanup_destination ⇒ Object
11 12 13 |
# File 'lib/rspec/rails/generators/helper.rb', line 11 def cleanup_destination FileUtils.rm_rf(destination_root) end |
#expect_file(file_path) {|File.read(destination_file_path)| ... } ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/rspec/rails/generators/helper.rb', line 23 def expect_file(file_path) destination_file_path = "#{destination_root}/#{file_path}" expect(File).to exist(destination_file_path) return unless block_given? yield File.read(destination_file_path) end |
#not_expect_file(file_path) ⇒ Object
31 32 33 34 |
# File 'lib/rspec/rails/generators/helper.rb', line 31 def not_expect_file(file_path) destination_file_path = "#{destination_root}/#{file_path}" expect(File).not_to exist(destination_file_path) end |
#prepare_destination ⇒ Object
6 7 8 9 |
# File 'lib/rspec/rails/generators/helper.rb', line 6 def prepare_destination FileUtils.rm_rf(destination_root) FileUtils.mkdir(destination_root) end |
#run_generator(generator_class, args = default_arguments, config = {}) ⇒ Object
Mimics railties/lib/rails/generators/testing/behaviour.rb
16 17 18 19 20 21 |
# File 'lib/rspec/rails/generators/helper.rb', line 16 def run_generator(generator_class, args = default_arguments, config = {}) args += ["--skip-bundle"] unless args.include?("--no-skip-bundle") || args.include?("--dev") args |= ["--skip-bootsnap"] unless args.include?("--no-skip-bootsnap") generator_class.start(args, config.reverse_merge(destination_root: destination_root)) end |