Skip to content

Instantly share code, notes, and snippets.

View vladvinnikov's full-sized avatar

Vladimir Vinnikov vladvinnikov

View GitHub Profile
@vladvinnikov
vladvinnikov / gist:1137686
Created August 10, 2011 18:20
Factory girl chet shit
Factory girl is an object factory library to be used with your tests.
Installation:
$ [sudo] gem install factory_girl
or with Rails >2.1 dependency management, add to environment.rb
config.gem "factory_girl", :lib => false
Then add:
@vladvinnikov
vladvinnikov / gist:1137822
Created August 10, 2011 19:03
devise.mapping
@request.env["devise.mapping"] = :admin
request.env["devise.mapping"] = Devise.mappings[:user]
Changes in syntax
Selectors for the content of an element
before:
response.should have_selector("title", :content => "My Title")
after:
?
response.body.should have_selector("head title", :text => "My Title")
Value of an input field
@vladvinnikov
vladvinnikov / .bashrc
Created August 31, 2011 18:08
.bashrc
PS1="mac osx:\W \$ "
alias gera="cd ~/Documents/railsapp/gera-it"
alias ra="cd ~/Documents/railsapp"
alias ss="cd ~/Documents/railsapp/sstore-experimental"
alias rs="rails s"
alias rc="rails c"
alias rg="rails g"
alias m="mate"
alias bu="bundle"
alias dbm="rake db:migrate"
@vladvinnikov
vladvinnikov / .bash_profile
Created August 31, 2011 18:09
.bash_profile
PATH="/usr/local/bin:/usr/local/sbin:$PATH" # if not already present
PATH="$PATH:/usr/local/mysql/bin"
export PATH=$PATH
source ~/.bashrc
##
# Your previous /Users/voland/.bash_profile file was backed up as /Users/voland/.bash_profile.macports-saved_2011-01-26_at_17:41:49
##
# MacPorts Installer addition on 2011-01-26_at_17:41:49: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
@vladvinnikov
vladvinnikov / .profile
Created August 31, 2011 18:09
.profile
export PATH="/usr/local/bin:/usr/local/git/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
alias vim='/Applications/MacVim.app/Contents/MacOS/Vim'
@vladvinnikov
vladvinnikov / gist:1512379
Created December 22, 2011 23:52
Rails generators config
config.generators do |g|
g.test_framework :rspec, :views => false, :fixture => true
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
g.form_builder :simple_form
g.template_engine :haml
end
@vladvinnikov
vladvinnikov / Get repo
Created December 24, 2011 23:57
New bare git repo
http://scottr.org/presentations/git-in-5-minutes/
git remote add origin git@server_name.ru:foo_site.git
set master track to origin
@vladvinnikov
vladvinnikov / gist:1518611
Created December 25, 2011 01:49
Passenger + Nginx + RVM
http://thekindofme.wordpress.com/2010/10/24/rails-3-on-ubuntu-10-10-with-rvm-passenger-and-nginx/
rvmsudo passenger-install-nginx-module
server {
listen 80; #the server will be running on this port
server_name www.yourhost.com;
root /home/deployer/your_rails_project/public; # <--- be sure to point to 'public'!
passenger_enabled on;
}
@vladvinnikov
vladvinnikov / gist:1593219
Created January 11, 2012 05:33
Factory example

Here's a sample test/factories.rb:

# Factories
Factory.define :article do |t|
	t.association :section # An article belongs to a section
	t.title {|x| "#{x.section.name}Article#{Factory.next(:count)}" }  # Use brackets when you're calling a sequence
	t.author "Author Bob"
    # Assuming you have put "require 'forgery' " in the correct place.  It could just be in your seeds.rb file.
	t.body Forgery::LoremIpsum.paragraphs(5)