A proof of concept of having Sinatra like routes inside your controllers.
Since the router is gone, feel free to remove config/routes.rb.
Then add the file below to lib/action_controller/inline_routes.rb
inside your app.
| #!/usr/bin/env ruby | |
| # The game board, at one point in time | |
| class BoardGeneration | |
| # How an instance will build a copy with a new grid | |
| def self.from_grid(grid) | |
| allocate.tap do |bg| | |
| bg.grid = grid | |
| end |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| let(:vehicle) { FactoryGirl.create(:vehicle, vehicle_attributes) } | |
| let(:vehicle_attributes) { {} } | |
| describe "#to_s" | |
| subject { vehicle.to_s } | |
| let(:vehicle_attributes) { {name: "Carzilla"} } | |
| it { should == "Carzilla" } | |
| end |
| # MOTIVATION: As rails apps are growing, people are noticing the drawbacks | |
| # of the ActiveRecord pattern. Several apps I have seen, and several | |
| # developers I have spoken to are looking towards other patterns for object | |
| # persistence. The major drawback with ActiveRecord is that the notion | |
| # of the domain object is conflated with what it means to store/retrieve | |
| # it in any given format (like sql, json, key/value, etc). | |
| # | |
| # This is an attempt to codify the Repository pattern in a way that would | |
| # feel comfortable to beginner and seasoned Ruby developers alike. | |
| # |
| ENV["RAILS_ENV"] = "test" | |
| require File.expand_path('../../config/environment', __FILE__) | |
| require 'rubygems' | |
| gem 'minitest' | |
| require 'minitest/autorun' | |
| require 'action_controller/test_case' | |
| require 'miniskirt' | |
| require 'capybara/rails' |
| def screenshot | |
| require 'capybara/util/save_and_open_page' | |
| now = Time.now | |
| p = "/#{now.strftime('%Y-%m-%d-%H-%M-%S')}-#{rand}" | |
| Capybara.save_page body, "#{p}.html" | |
| path = Rails.root.join("#{Capybara.save_and_open_page_path}" "#{p}.png").to_s | |
| page.driver.render path | |
| Launchy.open path | |
| end |
Patch for load speed: https://gist.github.com/1484985
cd /tmp
git clone git://gist.github.com/1484985.git
rvm install ruby-1.9.3-p0 --patch /tmp/1484985/cached_lp_sorted_lf.patch -n patchedDownload fresh ruby-debug19
| namespace :deploy do | |
| desc "Hot-reload God configuration for the Resque worker" | |
| task :reload_god_config do | |
| sudo "god stop resque" | |
| sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}" | |
| sudo "god start resque" | |
| end | |
| end | |
| # append to the bottom: |
| # | |
| # Put this in spec/support/ | |
| # Will use a sunspot stub session as default in all tests. | |
| # | |
| # To actually test the search you'll need something like: | |
| # describe "something", sunspot: true do | |
| # ...some tests... | |
| # end | |
| # | |
| # If you do this in your spec helper: |