Skip to content

Instantly share code, notes, and snippets.

View drselump14's full-sized avatar
:octocat:
Focusing

Slamet Kristanto drselump14

:octocat:
Focusing
  • Tokyo, Japan
View GitHub Profile
#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)
#coding: utf-8
#別名メソッドに気をつけよう。
#たとえば
#array.mapとarray.collectは同じメソッドです。
#自己破壊メソッドはポインタ参照が変わらないため、変数bは変数aの内容を表示する。
a = [1,2,3]
b = a
a.reverse!
p b