This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # gem install capybara --pre | |
| # gem install rspec | |
| # rspec capybara_test.rb | |
| require 'rubygems' | |
| require 'capybara' | |
| require 'capybara/rspec' | |
| Capybara.configure do |c| | |
| c.current_driver = :selenium |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| root=Dir.pwd | |
| puts ">>> Serving: #{root}" | |
| run Rack::Directory.new("#{root}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Filter | |
| include FormObject | |
| # Proc because Date.yesterday changes every day :) | |
| attribute :from, Date, default: Proc.new { Date.yesterday } | |
| attribute :to, Date, default: Proc.new { 1.month.from_now - 1.day } | |
| end | |
| # in controller | |
| @filter = Filter.new(params[:filter]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| signals 'hit()', 'missed()', 'angleChanged(int)', 'forceChanged(int)', | |
| 'canShoot(bool)' | |
| slots 'setAngle(int)', 'setForce(int)', 'shoot()', 'moveShot()', | |
| 'newTarget()', 'setGameOver()', 'restartGame()' | |
| #... | |
| def restartGame() | |
| if isShooting() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Filter | |
| include FormObject | |
| # Proc because Date.yesterday changes every day :) | |
| attribute :from, Date, default: Proc.new { Date.yesterday } | |
| attribute :to, Date, default: Proc.new { 1.month.from_now - 1.day } | |
| end | |
| # in controller | |
| @filter = Filter.new(params[:filter]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module AccessHelper | |
| # ... | |
| def acl | |
| YaAcl::Acl.instance | |
| end | |
| def can?(route_method, action = nil, options = {}) | |
| url_options = send "hash_for_#{route_method}_path" | |
| resource = "#{url_options[:controller].to_s.camelize}Controller" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Role < ActiveRecord::Base | |
| include RoleRepository | |
| has_many :user_roles, :dependent => :destroy | |
| has_many :users, :through => :user_roles | |
| translate_methods :name | |
| def to_sym | |
| short_name.to_sym | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Path to your oh-my-zsh configuration. | |
| ZSH=$HOME/.oh-my-zsh | |
| # Set name of the theme to load. | |
| # Look in ~/.oh-my-zsh/themes/ | |
| # Optionally, if you set this to "random", it'll load a random theme each | |
| # time that oh-my-zsh is loaded. | |
| ZSH_THEME="robbyrussell" | |
| # Example aliases |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Parent | |
| def test | |
| puts "test" | |
| end | |
| private :test | |
| end | |
| class Child < Parent | |
| public :test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'active_record' | |
| ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:" | |
| ActiveRecord::Migration.create_table :users do |t| | |
| t.string :email | |
| t.string :name | |
| t.timestamps | |
| end |