Skip to content
pas edited this page Oct 25, 2012 · 8 revisions

Remove branches on remote

Sometimes you want to remove your branch on github.com. For that you can use:

git push origin :name_of_your_branch

Installing the DevKit on Windows

Some gems can't be installed on Windows without the DevKit.

  1. Go to http://rubyinstaller.org/downloads/ and install the DeveloptmentKit: "DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe"

  2. Double click and extract the file to the path you want

  3. Change in commandline into the directory you installed it and use

    ruby dk.rb init ruby dk.rb install

For more information an troubleshooting see here: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

Test for exceptions

Sometimes you want to check if an exception is thrown. For that you can use assert_raise

assert_raise(RuntimeError) { #Code that should throw a RuntimeError }

Use setup and teardown in tests to initialize your testdata

setup is always called before a test starts and teardown when the test is finished. So you can write

@user

def setup
  @user = Models::User.created(..data)
end

def teardown
  @user.clear
end

def test1
  #Do something with @user
end

Instead of

def test1
  user = Models::User.created(..data)
  #Do something with user
  user.clear
end

# ... A lot of tests using a user ...

def test100
  user = Models::User.created(..data)
  #Do something with user
  user.clear
end

Make links to post a form

Use java-script for that

<form action='/unregister' name='data' method='POST'></form>
<a href="javascript:data.submit()">Delete Account</a>

See our Menu for an example

Retrieve a fileversion from a previous commit

Use

git log

to see commit and write down the hash on the top of the commit

commit 584f0c4b4704fb11a45cb8c1351cb33
Merge: ce32bd5 bdaa84e
Author: Pas <[email protected]>
Date:   Mon Oct 8 12:29:42 2012 +0200

Merge branch 'master' of https://github.com/ese-unibe-ch/ese2012-team1

Then checkout the file

git checkout 584f0c4b4704fb11a45cb8c1351cb33 path/to/your/file.rb

And commit the retrieved file

Using the error Page

use the follwing code:

begin
  critical command
rescue
  redirect "/error/ERRORCODE"
end

in file sites.rb look for

get '/error/:title' do

add another if-block for the new error code with error message. e.g.

if params[:title] == "ERRORCODE"
  msg = "ERRORCODE depending message"
end
Clone this wiki locally