- Numbers in Ruby are Objects
- We can call methods on numbers
- We can define methods on numbers
- Tricks with Numbers
- Integer with Integer gives Integer
- Integer with Float gives Float
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
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
BEFORE: start trajectory story | |
* run specific tests wrote (eg: rspec spec/decorators/event_decorator_spec.rb:5) | |
rake | |
git status | |
git diff |
Add contributors pull requests to your origin remote
# .git/config
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
url = [email protected]:thoughtbot/[repo].git
Fetch and checkout the remote branch. Run bundle to make sure any new dependencies are installed.
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 AddHstoreExtension < ActiveRecord::Migration | |
def up | |
execute 'CREATE EXTENSION hstore' | |
end | |
def down | |
execute 'DROP EXTENSION hstore' | |
end | |
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
# Usage | |
# order = create(:order) | |
# | |
# expect { | |
# order.pay! | |
# }.to deliver_email(OrderMailer, :paid, order.id) | |
# | |
# |
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
sudo kill -9 `ps ax|grep 'coreaudio[a-z]' |awk '{print $1}'` |
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 "date" | |
class Month | |
include Comparable | |
MONTHS_PER_YEAR = 12 | |
def self.from_date(date) | |
self.from_parts(date.year, date.month) | |
end |