Writing a good spec.

Discussion in 'Ruby' started by Ch Ba, Dec 18, 2008.

  1. Ch Ba

    Ch Ba Guest

    So I have a piece of code that I didn't write a spec for, and now rcov
    is yelling at me about it. The problem is that I'm not really sure how I
    should do it.

    def build_structure(paths)
    unless File::exists?('specdoc')
    Dir.mkdir('specdoc')
    end
    paths.each do |path|
    FileUtils.makedirs("specdoc/#{strip_file(path)}")
    end
    end

    I want to make sure I have good coverage, but should I just come up with
    some random paths, make it make them and then delete them? I just don't
    know how to come at this one to get a good spec. Any ideas?
    --
    Posted via http://www.ruby-forum.com/.
    Ch Ba, Dec 18, 2008
    #1
    1. Advertising

  2. Ch Ba

    ara.t.howard Guest

    On Dec 17, 2008, at 8:40 PM, Ch Ba wrote:

    > So I have a piece of code that I didn't write a spec for, and now rcov
    > is yelling at me about it. The problem is that I'm not really sure
    > how I
    > should do it.
    >
    > def build_structure(paths)
    > unless File::exists?('specdoc')
    > Dir.mkdir('specdoc')
    > end
    > paths.each do |path|
    > FileUtils.makedirs("specdoc/#{strip_file(path)}")
    > end
    > end
    >
    > I want to make sure I have good coverage, but should I just come up
    > with
    > some random paths, make it make them and then delete them? I just
    > don't
    > know how to come at this one to get a good spec. Any ideas?
    > --



    first off, specdoc needs to be parameterizable - for instance

    def build_structure *args

    options = args.pop if args.last.is_a?(Hash)
    paths = args.flatten.compact

    root = Namespace.root

    end

    which sets you up to be able to do

    Namespace.root = 'test/specdoc'

    also, the method could return the directories created, which helps
    testing a good deal.

    some ideas...

    a @ http://codeforpeople.com/
    --
    we can deny everything, except that we have the possibility of being
    better. simply reflect on that.
    h.h. the 14th dalai lama
    ara.t.howard, Dec 18, 2008
    #2
    1. Advertising

  3. Ch Ba

    Ch Ba Guest


    > first off, specdoc needs to be parameterizable - for instance


    > also, the method could return the directories created, which helps
    > testing a good deal.
    >
    > some ideas...
    >
    > a @ http://codeforpeople.com/


    Thanks, I'll swing that in there!

    --
    Posted via http://www.ruby-forum.com/.
    Ch Ba, Dec 18, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rp
    Replies:
    0
    Views:
    1,205
  2. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    VS2005 minimum spec

    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Oct 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    381
    Juan T. Llibre
    Oct 6, 2005
  3. Ron de Waard
    Replies:
    2
    Views:
    12,553
    HansDampf
    Oct 5, 2007
  4. bruce phipps

    ISO9000/ASA9100 spec writing advice

    bruce phipps, Aug 3, 2004, in forum: Java
    Replies:
    1
    Views:
    1,073
    Oscar kind
    Aug 3, 2004
  5. Andrew Chen
    Replies:
    1
    Views:
    180
    David Chelimsky
    Mar 25, 2008
Loading...

Share This Page