Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Writing a good spec.

Reply
Thread Tools

Writing a good spec.

 
 
Ch Ba
Guest
Posts: n/a
 
      12-18-2008
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/.

 
Reply With Quote
 
 
 
 
ara.t.howard
Guest
Posts: n/a
 
      12-18-2008

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




 
Reply With Quote
 
 
 
 
Ch Ba
Guest
Posts: n/a
 
      12-18-2008

> 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/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how good is voice writing for computers? LMC Society Computer Information 16 03-16-2007 10:18 PM
Is writing to the event log in Application_BeginRequest a good idea? Nemisis ASP .Net 2 02-28-2007 03:17 PM
Any problems with writing the information into a file - Multi-users perform writing the same file at the same time ???? HNguyen ASP .Net 4 12-21-2004 01:53 PM
Is Java good for writing simple, yet sleek GUI apps? Love Rhino Java 28 09-25-2004 05:24 PM
Questionare: Which IDE you think is good one for writing Java Applet? M Java 3 06-02-2004 07:39 PM



Advertisments