A clean workaround for running capybara tests on Rails with assets pipeline enabled.
Original: teamcapybara/capybara#500 (comment)
| apt-get install xvfb | |
| apt-get install firefox |
| task :ask_production_confirmation do | |
| set(:confirmed) do | |
| puts <<-WARN | |
| ======================================================================== | |
| WARNING: You're about to perform actions on production server(s) | |
| Please confirm that all your intentions are kind and friendly | |
| ======================================================================== |
| sudo cp nginx /etc/init.d/ | |
| sudo update-rc.d nginx defaults | |
| sudo chmod +x /etc/init.d/nginx | |
| /etc/init.d/nginx start |
| $(function() { | |
| /* Convenience for forms or links that return HTML from a remote ajax call. | |
| The returned markup will be inserted into the element id specified. | |
| */ | |
| $('form[data-update-target]').live('ajax:success', function(evt, data) { | |
| var target = $(this).data('update-target'); | |
| $('#' + target).html(data); | |
| }); | |
| }); |
| #put in lib/tasks/fixtures.rake | |
| namespace :db do | |
| namespace :fixtures do | |
| desc 'Create YAML test fixtures from data in an existing database. | |
| Defaults to development database. Set RAILS_ENV to override.' | |
| task :dump => :environment do | |
| sql = "SELECT * FROM %s" | |
| skip_tables = ["schema_migrations"] | |
| ActiveRecord::Base.establish_connection(:development) | |
| (ActiveRecord::Base.connection.tables - skip_tables).each do |table_name| |
| # Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed. | |
| # We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies. | |
| # Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module | |
| # | |
| # Deployment structure | |
| # | |
| # SERVER: | |
| # /etc/init.d/nginx (1. nginx) | |
| # /home/app/public_html/app_production/current (Capistrano directory) | |
| # |
A clean workaround for running capybara tests on Rails with assets pipeline enabled.
Original: teamcapybara/capybara#500 (comment)
| set :stage, 'production' | |
| set :shared_children, shared_children << 'tmp/sockets' | |
| puma_sock = "unix://#{shared_path}/sockets/puma.sock" | |
| puma_control = "unix://#{shared_path}/sockets/pumactl.sock" | |
| puma_state = "#{shared_path}/sockets/puma.state" | |
| puma_log = "#{shared_path}/log/puma-#{stage}.log" | |
| namespace :deploy do | |
| desc "Start the application" |
| #! /usr/bin/env ruby | |
| # some models have whack shit that can't survive a marshal round-trip | |
| # | |
| class Model | |
| include Mongoid::Document | |
| def initialize(*args, &block) | |
| super | |
| ensure |