Loading ...
Sorry, an error occurred while loading the content.

TDD in Ruby Project

Expand Messages
  • Jack Tang
    Hi list What do you use in ruby project driven by TDD. Unit test in stdlib, ZenTest or RSpec? Regards /Jack -- Jack Tang Software Engineer at Vobile Email:
    Message 1 of 5 , Jan 7, 2009
    • 0 Attachment
      Hi list

      What do you use in ruby project driven by TDD. Unit test in stdlib,
      ZenTest or RSpec?

      Regards
      /Jack
      --
      Jack Tang
      Software Engineer at Vobile

      Email: himars@...
      http://www.linkedin.com/in/jacktang
    • Phlip
      ... We use assert{ 2.0 }. It s much easier to write than those systems for _low_level_ TDD, because you write normal Ruby, not some smarmy syntax. Whatever you
      Message 2 of 5 , Jan 8, 2009
      • 0 Attachment
        Jack Tang wrote:

        > What do you use in ruby project driven by TDD. Unit test in stdlib,
        > ZenTest or RSpec?

        We use assert{ 2.0 }.

        It's much easier to write than those systems for _low_level_ TDD, because you
        write normal Ruby, not some smarmy syntax.

        Whatever you write into the assert{} block, when it fails, you get an elaborate,
        readable, formatted report on all the variables and expressions inside, complete
        with their names and return values.

        For example, this assertion tests that one records should have just been deleted:

        assert{ SomeRecord.count() == ( former_count - 1 ) }
        --> false
        SomeRecord.count() --> 3
        former_count --> 3
        ( former_count - 1 ) --> 2.

        The assertion prints out the complete name and value of each terminal and
        expression in its block, formatted for easy scanning. If one of those methods
        were a complex aggregate, the diagnostic would pretty_print it all and line it
        up in columns.

        The major benefit over RSpec (or other BDD systems) is developers can focus on
        developing, without constantly rebuilding their ordinary programming statements
        as elaborate ".should" method calls.

        Instead, we can focus on writing whatever statement accurately asserts our
        situation, without worrying about its diagnostic when it fails. BDD is for
        customer-acceptance testing, so civilian customers can read our test cases.

        I have a new version of assert{ 2.0 } ready to work with Ruby 1.9.1, and I will
        release it as soon as I write stubs for Ruby 1.8.7. (That breaks the reflection
        library I use for 1.8.6, and 1.9 uses a new reflection library, Ripper.)

        --
        Phlip
      • Adam Sroka
        ... Interesting. I have always used RSpec, but that is because I was first (indirectly) introduced to Ruby by Dave Astels (Who is one of the original
        Message 3 of 5 , Jan 8, 2009
        • 0 Attachment
          On Thu, Jan 8, 2009 at 7:32 AM, Phlip <phlip2005@...> wrote:
          > Jack Tang wrote:
          >
          >> What do you use in ruby project driven by TDD. Unit test in stdlib,
          >> ZenTest or RSpec?
          >
          > We use assert{ 2.0 }.
          >
          > It's much easier to write than those systems for _low_level_ TDD, because
          > you
          > write normal Ruby, not some smarmy syntax.

          Interesting. I have always used RSpec, but that is because I was first
          (indirectly) introduced to Ruby by Dave Astels (Who is one of the
          original developers of RSpec.)

          >
          > The major benefit over RSpec (or other BDD systems) is developers can focus
          > on
          > developing, without constantly rebuilding their ordinary programming
          > statements
          > as elaborate ".should" method calls.
          >

          But, with (T|B)DD I don't have "ordinary programming statements" until
          I have specified what I want my objects to do. This "benefit" seems
          overly test-centric.

          > Instead, we can focus on writing whatever statement accurately asserts our
          > situation, without worrying about its diagnostic when it fails. BDD is for
          > customer-acceptance testing, so civilian customers can read our test cases.
          >

          A-ha! I see what you are saying now. You don't like RSpec as much
          because with RSpec you need to care about what output is produced so
          that you get useful failure messages. I admit that this is a downside
          to RSpec, but I have never found it overly cumbersome.

          > I have a new version of assert{ 2.0 } ready to work with Ruby 1.9.1, and I
          > will
          > release it as soon as I write stubs for Ruby 1.8.7. (That breaks the
          > reflection
          > library I use for 1.8.6, and 1.9 uses a new reflection library, Ripper.)
          >

          I'm intrigued. I will have to give it a try.
        • Phlip
          ... Near term, make sure you have Ruby 1.8.6 (not 1.8.7 or higher), and then gem install assert2!
          Message 4 of 5 , Jan 8, 2009
          • 0 Attachment
            > I'm intrigued. I will have to give it a try.

            Near term, make sure you have Ruby 1.8.6 (not 1.8.7 or higher), and then gem
            install assert2!
          • Shlomi Fish
            ... I m using RSpec, but it s only because I watched a video presentation about it. It s supposedly Behaviour-Driven Development, but BDD is essentially the
            Message 5 of 5 , Jan 9, 2009
            • 0 Attachment
              On Thursday 08 January 2009 08:45:13 Jack Tang wrote:
              > Hi list
              >
              > What do you use in ruby project driven by TDD. Unit test in stdlib,
              > ZenTest or RSpec?
              >

              I'm using RSpec, but it's only because I watched a video presentation about
              it. It's supposedly Behaviour-Driven Development, but BDD is essentially the
              same as Test-Driven Development, with a fancier name. (see
              http://community.livejournal.com/shlomif_tech/15203.html ). Still, it's pretty
              nice.

              Note that I haven't really done anything serious in Ruby - just Project Euler
              programs and a small program I haven't finished.

              Regards,

              Shlomi Fish

              > Regards
              > /Jack

              --
              -----------------------------------------------------------------
              Shlomi Fish http://www.shlomifish.org/
              Interview with Ben Collins-Sussman - http://xrl.us/bjn8s

              Shlomi, so what are you working on? Working on a new wiki about unit testing
              fortunes in freecell? -- Ran Eilam
            Your message has been successfully submitted and would be delivered to recipients shortly.