class Rspec::Generators::InstallGenerator
@private
Public Class Methods
source_root()
click to toggle source
# File lib/generators/rspec/install/install_generator.rb, line 15 def self.source_root @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates')) end
Public Instance Methods
copy_rails_files()
click to toggle source
# File lib/generators/rspec/install/install_generator.rb, line 27 def copy_rails_files template 'spec/rails_helper.rb' end
copy_spec_files()
click to toggle source
# File lib/generators/rspec/install/install_generator.rb, line 19 def copy_spec_files Dir.mktmpdir do |dir| generate_rspec_init dir template File.join(dir, '.rspec'), '.rspec' directory File.join(dir, 'spec'), 'spec' end end
Private Instance Methods
generate_rspec_init(tmpdir)
click to toggle source
# File lib/generators/rspec/install/install_generator.rb, line 33 def generate_rspec_init(tmpdir) initializer = ::RSpec::Core::ProjectInitializer.new( destination: tmpdir, report_stream: StringIO.new ) initializer.run spec_helper_path = File.join(tmpdir, 'spec', 'spec_helper.rb') replace_generator_command(spec_helper_path) remove_warnings_configuration(spec_helper_path) end
remove_warnings_configuration(spec_helper_path)
click to toggle source
# File lib/generators/rspec/install/install_generator.rb, line 53 def remove_warnings_configuration(spec_helper_path) empty_line = '^\n' comment_line = '^\s*#.+\n' gsub_file spec_helper_path, /#{empty_line}(#{comment_line})+\s+config\.warnings = true\n/, '', verbose: false end
replace_generator_command(spec_helper_path)
click to toggle source
# File lib/generators/rspec/install/install_generator.rb, line 46 def replace_generator_command(spec_helper_path) gsub_file spec_helper_path, 'rspec --init', 'rails generate rspec:install', verbose: false end