Skip to content

Instantly share code, notes, and snippets.

View nerdinand's full-sized avatar
💭
wat

Ferdinand Niedermann nerdinand

💭
wat
View GitHub Profile
@nerdinand
nerdinand / rot13.rb
Last active December 29, 2015 14:43 — forked from rwoeber/rot13.rb
Ruby rot13
# or simply:
'foobar'.tr 'A-Za-z','N-ZA-Mn-za-m'
# rot(x)
class String
def rot(num = 13)
return self.split('').collect do|ch|
if /^[a-z]$/ === ch
((ch.ord + num - 'a'.ord) % 26 + 'a'.ord).chr
#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)