Skip to content

Instantly share code, notes, and snippets.

@CGA1123
Created December 28, 2016 18:06
Show Gist options
  • Select an option

  • Save CGA1123/6772774924a9dae6c8187f83e818d339 to your computer and use it in GitHub Desktop.

Select an option

Save CGA1123/6772774924a9dae6c8187f83e818d339 to your computer and use it in GitHub Desktop.

Revisions

  1. CGA1123 created this gist Dec 28, 2016.
    31 changes: 31 additions & 0 deletions bin_test_script.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/usr/bin/env ruby
    require 'pathname'

    # path to your application root.
    APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)

    Dir.chdir APP_ROOT do
    test_env = 'test'
    puts "Application Environment: #{test_env}"

    # Resets the test database
    puts "Setting Up Database..."
    puts "Drop Database"
    system "RAILS_ENV=#{test_env} bundle exec rake db:drop"
    puts "Create Database"
    system "RAILS_ENV=#{test_env} bundle exec rake db:create"
    puts "Load Database Schema"
    system "RAILS_ENV=#{test_env} bundle exec rake db:schema:load"

    # Run the rspec testing framework
    # options enabled are: --format documentation
    puts "\nRun RSpec"
    puts "$ RAILS_ENV=#{test_env} bundle exec rspec -f d"
    system "RAILS_ENV=#{test_env} bundle exec rspec -f d"

    # Run Rubocop
    # option enabled are: --format fuubar, --display-cop-names, --extra-details
    puts "\nRun Rubocop"
    puts "$ bundle exec rubocop -f fu -D -E"
    system 'bundle exec rubocop -f fu -D -E'
    end