Class: Rspec::Generators::InstallGenerator Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Rails::Generators::Base
|
|
Instance Chain:
self,
Rails::Generators::Base
|
|
Inherits: |
Rails::Generators::Base
|
Defined in: | rspec-rails/lib/generators/rspec/install/install_generator.rb |
Class Method Summary
- .source_root Internal use only
Instance Method Summary
- #copy_rails_files Internal use only
- #copy_spec_files Internal use only
- #append_default_path(dot_rspec_path) private Internal use only
- #default_path private Internal use only
- #generate_rspec_init(tmpdir) private Internal use only
- #remove_warnings_configuration(spec_helper_path) private Internal use only
- #replace_generator_command(spec_helper_path) private Internal use only
Class Method Details
.source_root
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/install/install_generator.rb', line 17
def self.source_root @source_root ||= File. (File.join(File.dirname(__FILE__), 'templates')) end
Instance Method Details
#append_default_path(dot_rspec_path) (private)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/install/install_generator.rb', line 70
def append_default_path(dot_rspec_path) append_to_file dot_rspec_path, "--default-path #{default_path}" end
#copy_rails_files
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/install/install_generator.rb', line 29
def copy_rails_files template 'spec/rails_helper.rb', "#{default_path}/rails_helper.rb" end
#copy_spec_files
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/install/install_generator.rb', line 21
def copy_spec_files Dir.mktmpdir do |dir| generate_rspec_init dir template File.join(dir, '.rspec'), '.rspec' directory File.join(dir, 'spec'), default_path end end
#default_path (private)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/install/install_generator.rb', line 75
def default_path [:default_path] end
#generate_rspec_init(tmpdir) (private)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/install/install_generator.rb', line 35
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) unless default_path == "spec" dot_rspec_path = File.join(tmpdir, '.rspec') append_default_path(dot_rspec_path) end end
#remove_warnings_configuration(spec_helper_path) (private)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/install/install_generator.rb', line 61
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) (private)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/install/install_generator.rb', line 54
def replace_generator_command(spec_helper_path) gsub_file spec_helper_path, 'rspec --init', 'rails generate rspec:install', verbose: false end