[rspec-users] Cucumber - but really ruby

David Chelimsky dchelimsky at gmail.com
Tue Feb 3 14:03:00 EST 2009

On Tue, Feb 3, 2009 at 12:49 PM, James Byrne <lists at ruby-forum.com> wrote:
> In the cucumber rake task I see this construct:
>    t.rcov_opts = %w{--rails --exclude
> lib\/ruby,lib64\/ruby,\/usr,osx\/objc,gems\/,test\/,spec\/,features\/}
>    t.rcov_opts << %[--output "coverage"]
> My questions is:  What do %w and % represent with respect to the
> "block"? in the first case and the "array"? in the second?  I cannot
> find an explanation of either usage in the documentation.

They're not really a block and an array - the %w can be followed by
the delimiter of your choice, and makes an array of the words between
the first and next instance of that delimiter. For example, each of

%w{these words}
%w[these words]
%w|these words|
%w%these words%

... all produce this array:



> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list