Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cucumber on Scala

Cucumber on Scala

Quick introduction to Scala for Ruby developers. I showcased Cucumber running in a Play (Scala) application.

Presentation I gave for the Ruby user group in Vienna.

Sebastian Nozzi

September 05, 2013
Tweet

More Decks by Sebastian Nozzi

Other Decks in Programming

Transcript

  1. Background • Working with Java since 2001 • Flirting with

    Smalltalk all these years • Developing with Rails since September 2012 • Hooked with Scala since January 2013 • Developing with Play since June 2013 viernes 6 de septiembre
  2. class Greeter(var name: String = "World") { def sayHi {

    println(s"Hello $name!") } def sayBye { println(s"Bye $name, come back soon.") } } val g = new Greeter greeter.sayHi >> "Hello World!" greeter.name = "vienna.rb" greeter.sayHi >> "Hello vienna.rb!" greeter.name >> "vienna.rb" viernes 6 de septiembre
  3. Similarities: Ruby / Scala • Object Oriented • Mixins /

    Traits • Blocks / First-class Functions • Powerful Collection APIs • method_missing / Dynamic trait • Console / REPL • More Elegant than predecessor (Perl / Java) viernes 6 de septiembre
  4. Cultural Impact of Ruby / Rails • Developer happiness matters

    • Productivity matters • Elegance matters • Lambdas are a must • DSLs are cool viernes 6 de septiembre
  5. • Borrows heavily from Rails • Convention over Configuration •

    Routes • REST / MVC • Models, Controllers, Fragments, Helpers, etc. • Save + Reload viernes 6 de septiembre
  6. Feature: Posting status updates The goal of the system is

    keep co-workers informed by posting status updates. Background: Given that user "manager" exists And that user "manager" posted | first day at work | | meeting people | | working like crazy | Scenario: Posts are ordered chronologically (newest on top) When I go to the posts page of user "manager" Then the post nr. 1 should contain "working" And the post nr. 2 should contain "meeting" And the post nr. 3 should contain "first" Feature name Description These steps get executed before each Scenario Steps in a Scenario Scenario name viernes 6 de septiembre
  7. And("""^press "([^"]*)"$""") { (buttonLabel: String) => ... ... } triple-quotes

    triple-quotes allows using unescaped quotes viernes 6 de septiembre
  8. And("""^press "([^"]*)"$""") { (buttonLabel: String) => ... ... } capturing

    group corresponding parameter viernes 6 de septiembre
  9. Then("""^the user should have (\d+) posts$""") { (amountPosts: Int) =>

    ... ... ... } capturing group corresponding parameter notice the type viernes 6 de septiembre
  10. Conclusion • Ruby / Rails influcence is everywhere • Possible

    for me to have some the Ruby coolness • Other languages (ahem, Scala) have cool ideas/concepts too ;-) • Ruby / Rails source of innovation and inspiration Keep innovating and making the world cool! viernes 6 de septiembre