require "test_helper" class NewProjectTest < Minitest::Test def test_ensure_tests_pass Dir.chdir(project_path) do Bundler.with_clean_env do ENV["TEST"] = nil assert `rake test` == "", "rake should not produce an error" end end end def test_ruby_version_file ruby_version_file = IO.read("#{project_path}/.ruby-version") assert_equal ruby_version_file, "#{RUBY_VERSION}\n" end def test_rubocop_should_pass Dir.chdir(project_path) do Bundler.with_clean_env do assert `rubocop`.match(/no offenses detected/), "Rubocop should not be offended" end end end def test_puma_config_should_exist assert File.exists?("#{project_path}/config/puma.rb"), "config/puma.rb should exist" end def test_gemfile_should_contain_certain_gems gemfile = IO.read("#{project_path}/Gemfile") assert gemfile.match(/bootstrap-sass/), "Gemfile should contain bootstrap-sass gem" assert gemfile.match(/quiet_assets/), "Gemfile should contain quiet assets gem" assert gemfile.match(/nprogress-rails/), "Gemfile should contain NProgress-rails" assert gemfile.match(/font-awesome-sass/), "Gemfile should contain font-awesome-sass" assert gemfile.match(/bootstrap_form/), "Gemfile should contain bootstrap_form" assert gemfile.match(/puma/), "Gemfile should contain puma" assert gemfile.match(/rails_12factor/), "Gemfile should contain rails_12factor" end def test_gemfile_should_contain_ruby_version gemfile = IO.read("#{project_path}/Gemfile") assert gemfile.match(/^ruby \".+\"$/), "Gemfile should contain a Ruby version" end def test_database_yml_should_containt_staging_and_production database_yml = IO.read("#{project_path}/config/database.yml") assert database_yml.match(/staging/), "Database.yml should contain staging" assert database_yml.match(/production/), "Database.yml should contain production" end def test_application_js_should_b_created app_js_file = IO.read("#{project_path}/app/assets/javascripts/application.js") assert app_js_file.match(/= require jquery.turbolinks/), "Jquery.turbolinks should be present" assert app_js_file.match(/= require bootstrap-sprockets/), "Bootstrap should be present" assert app_js_file.match(/= require nprogress/), "Nprogress should be present" assert app_js_file.match(/FastClick.attach/), "Fastclick should be initialized" end def test_gitignore_should_be_created app_ignore_file = IO.read("#{project_path}/.gitignore") assert app_ignore_file.match(/passenger/), "Passenger ignore should be present" assert app_ignore_file.match(/env/), ".env ignore should be present" end def test_application_css_should_be_created app_css_file = IO.read("#{project_path}/app/assets/stylesheets/application.scss") assert app_css_file.match(/bootstrap/), "Bootstrap should be present" assert app_css_file.match(/nprogress/), "Nprogress should be present" assert app_css_file.match(/font-awesome/), "FontAwesome should be present" assert app_css_file.match(/rails_bootstrap_forms/), "Bootstrap Forms should be present" end def test_develoment_rb_content development_rb_file = IO.read("#{project_path}/config/environments/development.rb") assert development_rb_file.match(/letter_opener/), "Should have the letter opener" end def test_helper_generation_should_be_disabled application_rb_file = IO.read("#{project_path}/config/application.rb") assert application_rb_file.match("config.generators.stylesheets = false"), "Should disable stylesheet generation" end end