Class: Spree::Generators::TestAppGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Spree::Generators::TestAppGenerator
- Defined in:
- lib/generators/spree/test_app_generator.rb
Class Attribute Summary collapse
-
.verbose ⇒ Object
Returns the value of attribute verbose.
Class Method Summary collapse
Instance Method Summary collapse
- #append_db_adapter_gem ⇒ Object
- #create_databases_yml ⇒ Object
- #create_root ⇒ Object
- #create_rspec_gemfile ⇒ Object
- #generate_app ⇒ Object
- #remove_unneeded_files ⇒ Object
- #replace_gemfile ⇒ Object
- #setup_environments ⇒ Object
- #tweak_gemfile ⇒ Object
Class Attribute Details
.verbose ⇒ Object
Returns the value of attribute verbose.
8 9 10 |
# File 'lib/generators/spree/test_app_generator.rb', line 8 def verbose @verbose end |
Class Method Details
.source_root ⇒ Object
15 16 17 |
# File 'lib/generators/spree/test_app_generator.rb', line 15 def self.source_root File.('../../templates', __FILE__) end |
Instance Method Details
#append_db_adapter_gem ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/generators/spree/test_app_generator.rb', line 81 def append_db_adapter_gem silence_stream(STDOUT) { case database_name when "mysql" gem "mysql2" append_file '../../Gemfile' do "gem 'mysql2'" end else gem "sqlite3-ruby" append_file '../../Gemfile' do "gem 'sqlite3-ruby'" end end } end |
#create_databases_yml ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/generators/spree/test_app_generator.rb', line 61 def create_databases_yml silence_stream(STDOUT) { remove_file "config/database.yml" template "config/database.yml.#{database_name}" mv "spec/test_app/config/database.yml.#{database_name}", "spec/test_app/config/database.yml", :verbose => false } end |
#create_root ⇒ Object
34 35 36 |
# File 'lib/generators/spree/test_app_generator.rb', line 34 def create_root self.destination_root = File.("spec/#{test_app}", destination_root) end |
#create_rspec_gemfile ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/generators/spree/test_app_generator.rb', line 26 def create_rspec_gemfile # newer versions of rspec require a Gemfile in the local gem dirs so create one there as well as in spec/test_app silence_stream(STDOUT) { template "Gemfile", :force => true remove_file "Gemfile.lock" } end |
#generate_app ⇒ Object
19 20 21 22 23 24 |
# File 'lib/generators/spree/test_app_generator.rb', line 19 def generate_app remove_directory_if_exists("spec/#{test_app}") inside "spec" do run "bundle exec rails new #{test_app} --database=#{database_name} -GJTq --skip-gemfile" end end |
#remove_unneeded_files ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/spree/test_app_generator.rb', line 38 def remove_unneeded_files silence_stream(STDOUT) { remove_file "doc" remove_file "lib/tasks" remove_file "public/images/rails.png" remove_file "public/index.html" remove_file "README" remove_file "vendor" } end |
#replace_gemfile ⇒ Object
49 50 51 52 53 |
# File 'lib/generators/spree/test_app_generator.rb', line 49 def replace_gemfile silence_stream(STDOUT) { template "Gemfile" } end |
#setup_environments ⇒ Object
55 56 57 58 59 |
# File 'lib/generators/spree/test_app_generator.rb', line 55 def setup_environments silence_stream(STDOUT) { template "config/environments/cucumber.rb" } end |
#tweak_gemfile ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/generators/spree/test_app_generator.rb', line 69 def tweak_gemfile silence_stream(STDOUT) { append_file '../../Gemfile' do full_path_for_local_gems end append_file 'Gemfile' do full_path_for_local_gems end } end |