Donnerstag, 21. Oktober 2010

Woooha. Real BDD using rspec in real life!


hi there...

long time no see. Well, I did continue with my learning tests but that's nothing that might be interesting for anyone except me...

But today I learned new stuff
a) there is no 1.9 ruby for cygwin (yet). I use v1.8.7 :-(
b) I cant use this
inst_section = {
  cello:    'string'
  clarinet: 'woodwind',
  ...
}
This is the new feature "New literal hash syntax" in ruby. See http://svn.ruby-lang.org/repos/ruby/tags/v1_9_1_0/NEWS
d) also have a look here: http://www.ruby-lang.org/de/news/2009/02/01/ruby-1-9-1-verffentlicht/ and here: http://www.ruby-lang.org/de/news/2010/08/24/ruby-1-9-2-verffentlicht/
  
But the coolest part I stubled across when I looked for v1.8 / v1.9 differences:  http://www.rubyspec.org/ These guys are using rubys rspec to write a (or maybe _the_) comprehensive ruby spec! As executable BDD code! COOL!.

Wanna see an example of the spec? Have a look here, even I a am still on page #21 in my ruby bible I am able to understand this spec! Great, imagin every business analyst would write such a spec!!! http://github.com/rubyspec/rubyspec/blob/master/core/array/flatten_spec.rb

Montag, 4. Oktober 2010

what would I have done without a book? Let's praise Mr. Gutenberg...

Yeah, I got my book. And learning this way is muuuuch more efficient compared to googling and reading the spec :) For now the most relevant and new aspects for me were
[Thomas, p15]
ruby is "genuine" object-oriented language. For instance
num = -1234          // Java code
abs = Math.abs(num)  // abs is 1234

num = -1234          # ruby code
abs = num.abs        # abs is 1234
                     # abs() is called on num! Not on Math

[Thomas, p16]
puts say_goodnight("John-Boy")
puts(say_goodnight("John-Boy"))
--> both lines are equivalent
--> precedence rules can make it difficult to know which argument goes with wich method invocation
--> so we recommend using parantheses in all but the simplest cases

But I also spent some time browsing the www. Focus this time: BDD. Have a look here: http://blog.dannorth.net/introducing-bdd/
and here: http://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-part-i/