サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
ノーベル賞
cheat.errtheblog.com
Capybara ======== Webrat alternative which aims to support all browser simulators. API === Navigating ---------- visit articles_path Clicking links and buttons -------------------------- click 'Link Text' click_button click_link Interacting with forms ---------------------- attach_file fill_in 'First Name', :with => 'John' check 'A checkbox' uncheck 'A checkbox' choose 'A radio button' select 'Pet
Mocking a class method product = Product.new Product.expects(:find).with(1).returns(product) assert_equal product, Product.find(1) Mocking an instance method on a real object product = Product.new product.expects(:save).returns(true) assert product.save Stubbing instance methods on real object prices = [stub(:pence => 1000), stub(:pence => 2000)] product = Product.new product.stubs(:prices).return
Shoulda Rspec Matchers For more information on rspec, rspec-rails, shoulda $ cheat rspec $ cheat rspec_on_rails_matchers $ cheat shoulda Models Matchers Data it { should_not have_db_column(:admin).of_type(:boolean) } it { should have_db_column(:salary). of_type(:decimal). with_options(:precision => 10, :scale => 2) } Associations it { should belong_to(:parent) } it { should have_many(:friends) } i
"Rinari Is Not A Rails IDE" Actually, it kind of is. Rinari's a set of Emacs libraries to help work with Rails. Moving around in Rinari: C-c ; f c rinari-find-controller C-c ; f e rinari-find-environment C-c ; f f rinari-find-file-in-project C-c ; f h rinari-find-helper C-c ; f i rinari-find-migration C-c ; f j rinari-find-javascript C-c ; f l rinari-find-plugin C-c ; f m rinari-find-model C-c ; f
CONSOLE COMMANDS help show all the console commands (same as this section) show dbs show database names show collections show collections in current database show users show users in current database show profile show most recent system.profile entries with time >= 1ms use <db name> set curent database to <db name> db.help() help on DB methods db.foo.help() help on collection methods db.foo.find()
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: require 'factory_girl' to your test_helper.rb or spec_helper.rb Defining factories: # This will guess the User class Factory.define :user do |u| u.first_name 'John' u.
=== General Commands help # show this usage version # show the gem version list # list your apps create [<name>] # create a new app keys # show your user's public keys keys:add [<path to keyfile>] # add a public key keys:remove <keyname> # remove a key by name (user@host) keys:clear # remove all keys === App Commands (execute inside a checkout directory, or use --app <appname>) info # show app inf
= Webrat - Ruby Acceptance Testing for Web applications - http://gitrdoc.com/brynary/webrat - http://groups.google.com/group/webrat - http://webrat.lighthouseapp.com/ - http://github.com/brynary/webrat - #webrat on Freenode == Description Webrat lets you quickly write expressive and robust acceptance tests for a Ruby web application. == Features * Browser Simulator for expressive, high level accep
Starting ------- M-x magit-status Status Buffer ------------- l show history buffer starting from head L show history buffer starting from a specified point b check out a different branch B create and check out a new branch d compare working tree with specified branch m manual merge M automatic merge R rebase / continue to rebase F pull P push p show a buffer with push/pull command transcript g re
Install: >> ./script/plugin install http://svn.techno-weenie.net/projects/plugins/permalink_fu/ >> piston import http://svn.techno-weenie.net/projects/plugins/permalink_fu/ Modify table: >> ./script/generate migration add_permalink_to_article >> add_column :designers, :permalink, :string Model: class Article < ActiveRecord::Base # title is the field name you want to convert to a permalink
INSTALL ======= INSTALL rspec ============= $ sudo gem install rspec OR $ ./script/plugin install git://github.com/dchelimsky/rspec.git INSTALL rspec_on_rails plugin ============================= $ ./script/plugin install git://github.com/dchelimsky/rspec-rails.git BOOTSTRAP THE APP ================= $ ./script/generate rspec create spec create spec/spec_helper.rb create spec/spec.
DataMapper, the ruby object relational mapper website: http://www.datamapper.org git: git://github.com/sam/dm-core.git mail: http://groups.google.com/group/datamapper wiki: http://github.com/sam/dm-core/wikis now: http://www.twitter.com/datamapper Setting up a Connection DataMapper.setup(:default, "adapter://user:password@hostname/dbname") supported adapters: mysql, sqlite3, postgres, sqli
Setup ----- git clone <repo> clone the repository specified by <repo>; this is similar to "checkout" in some other version control systems such as Subversion and CVS Add colors to your ~/.gitconfig file: [color] ui = auto [color "branch"] current = yellow reverse local = yellow remote = green [color "diff"] meta = yellow bold frag = magenta bold old = red bold new = green bold [color "status"] add
Open a database require 'rubygems' require 'sequel' DB = Sequel.sqlite 'my_blog.db' DB = Sequel.connect('postgres://user:password@localhost/my_db') DB = Sequel.mysql 'my_db', :user => 'user', :password => 'password', :host => 'localhost' DB = Sequel.ado 'mydb' Open an SQLite memory database Without a filename argument, the sqlite adapter will setup a new sqlite database in RAM. DB = Sequel.sqlite
Setup ----- git clone <repo> clone the repository specified by <repo>; this is similar to "checkout" in some other version control systems such as Subversion and CVS Add colors to your ~/.gitconfig file: [color] branch = auto diff = auto status = auto [color "branch"] current = yellow reverse local = yellow remote = green [color "diff"] meta = yellow bold frag = magenta bold old = red bold new = g
http://www.dizzy.co.uk/cheatsheets This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 2.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/2.0/uk ########## Shell Commands ########## Installation: $ gem install capistrano Add your application to Capistrano (capify): $ capify . # NOTE: Rake access to capistrano is deprecat
Welcome. You've reached the central repository for cheat, the RubyGem which puts Ruby-centric cheat sheets right into your terminal. The inaugural blog entry is here. Get started: $ gem install cheat $ cheat strftimeA magnificent cheat sheet for Ruby's strftime method will be printed to your terminal. To get some help on cheat itself: $ cheat cheatHow meta. Cheat sheets are basically wiki pages ac
このページを最初にブックマークしてみませんか?
『$ command line ruby cheat sheets』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く