• 09
  • Aug

as you probaby know, ruby on rails has a very handy test integration. you can easily write unit tests for your rich domain model and some functional tests (that can be roughly compared to http-units in the java world, but with integrated webserver) for the controller and views.

unfortunately, one part of rails basic implementation architecture cannot be tested as easy as the above mentioned components: the view helpers. actually they are used to extract view functionality and keep the view templates clean from ruby scriptlets. of course, you can test them indirectly through your functional tests, but rails provides no pure way to test them individually. an obvious approach is to write some unit-tests for each helper class. this works fine as long as you are not using some methods provided by rails, i.e. link_to, url_for, all the input tag methods and so on.

so here is an example of a simple view helper. the method time_link_to returns a link including the current date as parameter in the form http://www.yourhost.com/railscontroller/year/month/day.

# Methods added to this helper will be
# available to all templates in the application.
module ApplicationHelper

  def time_link_to(controller_name, name, date, html_options = nil)
    if html_options
      html_options = html_options.stringify_keys
      convert_options_to_javascript!(html_options)
      tag_options = tag_options(html_options)
    else
      tag_options = nil
    end
    url = url_for(:controller => controller_name) +
           "/#{date.year}/#{date.month}/#{date.day}"
    "<a href=\"#{url}\"#{tag_options}>#{name || url}</a>"
  end

end

since the method url_for is provided by the controller that is executed when the view and therefore the helper is evaluated, you have to fake it for the unit test. this can be done in the setup method of the unit test like this:

class ApplicationHelperTest < Test::Unit::TestCase

  include ActionView::Helpers::AssetTagHelper
  include ActionView::Helpers::UrlHelper
  include ActionView::Helpers::TagHelper
  include ApplicationHelper

  # called before every single test
  def setup
    # creating a dummy controller with the method url_for that
    # returns the url assigned to the controller
    @controller = Class.new do
      attr_accessor :url, :request
      def url_for(options, *parameters_for_method_reference)
        url
      end
    end
    @controller = @controller.new
    # setting the url of the controller
    @controller.url = "http://www.example.com"
  end

  # testing the view method
  def test_time_link_to
    assert_equal "<a href=\"http://www.example.com/testcontroller/" +
      "#{Date.today.year}/#{Date.today.month}/" +
      "#{Date.today.day}\">test</a>",
      time_link_to("testcontroller", "test", Date.today)
    assert_equal "<a href=\"http://www.example.com/testcontroller/" +
      "#{Date.today.year}/#{Date.today.month}/" +
      "#{Date.today.day}\" id=\"test_id\">test</a>",
      time_link_to("testcontroller", "test",
        Date.today, {:id => "test_id"})
  end
end
  • 29
  • Jul

dieses jahr wars die 25. rheinkultur, also ein kleines jubiläum. vielleicht lags auch daran, dass bei diesem mal das line up ein paar sehr bekannte namen enthielt.

IMG_0966.jpgIMG_0971.jpgIMG_0984.jpgIMG_0989.jpg
[gallerie]

wie auch im letzten jahr war es allerdings wieder ein chaos bei der an- und abreise. ich glaube, die veranstalter werden dieses problem nie in den griff bekommen. den abend konnte dieses negativ-erlebnis aber nicht trügen.

Medium: www.youtube.com

die haupt-acts sick of it all auf der roten und fanta4 auf der blauen bühne waren wirklich sehenswert. auch ein besuch bei der breakzone war dieses mal ein echtes highlight. im sonnenuntergang konnte man den massen beim hemmungslosen abfeiern zusehen. alles in allem also eine runde sache…

  • 16
  • Jun

wow, really nice moves.

Medium: www.youtube.com

  • 16
  • Jun

neulich im vorbeigehen gehört und für gut befunden:

die beastie boys bringen mit The Mix-up ein schickes neues instrumental-album auf den markt. auf youtube gibts zwei stücke davon bereits zum probehören:

Off the grid

The Rat Cage

viel spass beim reinhören. mehr gibts übrigens auch bei myspace.

  • 30
  • May

if you can watch german tv, you probably came across one of those emigrant-series, which are quite popular at present. the plot of every episode is nearly the same: a couple or family want’s to start a new life in a foreign country and therefore has to leave all behind. in many cases they have had enough of germany, are frustrated of their current job situation or their salary progression. with the dream of a better life in mind the breadwinners quit their jobs, sell all their disposable belongings and plan how to transfer their remaining stuff to their new home.

the whole story get’s interesting when the folks arrive at the new place. in many cases everything seems quite different to what they had expected earlier. the language barrier for instance is one of the reasons for quite a few problems. it becomes even serious for those families with only basic language skills and no assured job or income. in this context it really hurts to see, how naive some of them could be to think that all will work out without fundamental preparation. but there are also a number of really successful and impressing stories which demonstrate as well that you can achieve a great deal if you are willing to take some risk.

one of my good friends is in a comparable situation right now. he has left germany and moved with his wife from bonn to washington dc in the us. in his blog he documents his experiences in the form of a field report which is far more interesting and entertaining than the above mentioned tv series. try out the stories about the hollywood principle for finding a job or the garbage disposal

  • 06
  • May

hey, ever wanted to get rid of your headset and use your mobile device for skype? last year i came across an application, which looked promising, but was really crap.

the piece of software i talk about is called im+ for skype. it let’s you conntect your device with your local pc, where skype is installed, over a mobile data connection. so in order to use it your pc has to be turned on, your skype must be up and running and your firewall has to accept incoming connections. what a miserable situation!

now i discovered a way better solution: with fring, you can use your mobile device to make voip-calls not only to users of skype, but also to googletalk, msn and sip endpoints. after you have installed a small mobile application (which was quite easy and well guided) you are ready to use your skype account without the need of further pc software. i have used it with my local wlan on a nokia e61 and it works quite perfect. you even don’t need a fast mobile connection like umts, because fring consumes only about 8mb for a 60 minutes voip-call and about 10kb (!!) per hour connectivity.

Medium: www.youtube.com

  • 03
  • May

as you probably know, second life is one of the most famous virtual communities of today. and as i wrote some time ago, there is also an evolving virtual economy which significantly affects real life businesses. therefore many well known companies (i.e. adidas, toyota, sony and ibm) started a virtual counterpart.

but the last thing i expected was that the company i work for gets to second life as well, because i could’t really think of a useful application. but an email, which reached me today, quickly disabused me. now there is also a quite impressing equivalent of the deutsche post in second life :-)

you can send a post card of your avatar’s face or some other theme via second life to a real world address. i don’t know if this is really useful, but it’s a quite cool idea ;)

avatar01.jpg

  • 29
  • Apr

ich verfolge seit längerem mit großem interesse den blog nuku.de, in dem der deutsche student florian über sein leben und die erfahrungen in südkorea schreibt. ich selbst habe aufgrund meiner beziehung mit einer südkoreanerin bereits einige interessante kulturelle erfahrungen gesammelt, wobei für mich - genauso wie für den autoren des oben genannten blogs - die hintergründe des denkens und handelns dieser fremden welt nicht immer ganz klar waren oder noch sind.

Read the rest of this entry …

  • 05
  • Apr

on projectmanagement source there is a nice post on how to become a better public speaker. they list up 27 hints in form of best practices which can help to improve one’s presentation performance. i think there are two more important aspects:

28. try to get feedback: once you’ve finished your speech try to get feedback from your audience in form of a standardised questionnaire that you can hand out before. you can ask about

  • the form or quality of your presentation,
  • the innovativeness regarding the topic,
  • the auditors’ gain of experience,
  • the auditors’ readiness to recommend your speech to friends,
  • the auditors’ overall opinion,
  • and suggestions for improvement.

this gives you some important information about the things you still have to work on, and an impression on how successful your presentation really was.

29. be prepared for equipment failure: let’s assume you want to use some state-of-the-art presentation equipment like a mike, a notebook, a beamer, powerpoint and a wireless presenter mouse. the first thing is that you should allow for some extra time before you start your speech in order to get all this stuff working. if you encounter problems, you must be ready for an alternative solution (i.e. slices for an overhead projector).

there’s also a website which deals with “the art of speaking” and has some more nice hints.

  • 04
  • Apr

want to know what’s in the desert?

try these coordinates with google maps: 15.298683 19.429651

:-)