# Re: new --pattern option

**URL:** <https://www.ruby-forum.com/t/re-new-pattern-option/138731>\
**Category:** RSpec\
**Created:** [May 27, 2008, 9:38am UTC](https://www.ruby-forum.com/t/re-new-pattern-option/138731 "2008-05-27T09:38:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kasutaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5fc32e/32.png) [@kasutaja](https://www.ruby-forum.com/u/kasutaja)\
**Post date:** [May 27, 2008, 9:38am UTC](https://www.ruby-forum.com/t/re-new-pattern-option/138731/1 "2008-05-27T09:38:37Z")

</div>

Hello.

You’re saying that:  
To get rspec to behave as it did before this change, use this:

–pattern “\*\*/\*.rb”

I tried like this (rspec 1.03) and it wasn’t same as before (rspec  
1.08).  
Now it also loads all other files in current directory and in all  
subdirectories and not only from directory and subdirectories given to  
spec  
as a parameter.

So, for example, I have something like this:  
.\some\_file.rb (which I don’t want to load)  
.\some\_dir\some\_other\_dir\some\_other\_files.rb (I don’t want to load  
these  
also)  
.\my\_test\_dir (has many subdirs and rb files in it - I want to load all  
.rb  
files from THIS dir)

now, I execute rspec like this: spec -p \*\*/\*.rb my\_test\_dir (and having  
working directory . of course).

Now I get some errors and things (some of them need input parameters and  
so  
on) from the files I did not want to include and they weren’t included  
with  
previous versions. For example, it is going to load all rb files from  
“.”  
and from “some\_dir” and subdirectories. What’s wrong and how can I avoid  
that?

I made simple test, created files called “main\_spec.rb” to follow your  
naming convention. It had only one line in it:  
puts "spec: " + File.dirname( **FILE** )

Now, I executed spec without -p (–pattern) switch to have it to use  
default  
option (which is \*\*/_\_spec.rb). Everything worked as with version 1.08.  
But  
NOW, if I executed spec with -p \*\*/_\_spec.rb (which is SAME as default  
option!) it loaded ALL \*\_spec.rb files from working directory and from  
every  
subdirectories (as supposed to all \*\_spec.rb files from directories and  
subdirectories given to spec as input parameter). It seems to be some  
bug.  
Any ideas?

One way is to change working directory to “my\_test\_dir” prior executing  
rspec but it’s not comfortable also. Other way would be to rename all my  
tests to \_spec.rb, which wouldn’t be also too big of a job. But the  
question  
still remains.

Jarmo.

David C.-2 wrote:

> Cheers,  
> David
> 
> * * *
> 
> rspec-users mailing list  
> removed\_email\_address@domain.invalid  
> [http://rubyforge.org/mailman/listinfo/rspec-users](http://rubyforge.org/mailman/listinfo/rspec-users)

–  
View this message in context:  
[http://www.nabble.com/new---pattern-option-tp14983923p17484038.html](http://www.nabble.com/new---pattern-option-tp14983923p17484038.html)  
Sent from the rspec-users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![kasutaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5fc32e/32.png) [@kasutaja](https://www.ruby-forum.com/u/kasutaja)\
**Post date:** [May 27, 2008, 1:39pm UTC](https://www.ruby-forum.com/t/re-new-pattern-option/138731/2 "2008-05-27T13:39:59Z")

</div>

On May 27, 2008, at 2:35 AM, kasutaja wrote:

> Hello.
> 
> You’re saying that:  
> To get rspec to behave as it did before this change, use this:
> 
> –pattern “\*\*/\*.rb”

That was an error. Use this instead:

–pattern “spec/\*\*/\*.rb”

or this if you want to avoid loading files other than spec files:

–pattern “spec/\*\*/\*\_spec.rb”

This one is actually the default, so if that’s what you want you don’t  
need to use the option.

I updated my blog post to reflect this:  
[http://blog.davidchelimsky.net/articles/2008/01/20/rspec-new-pattern-option](http://blog.davidchelimsky.net/articles/2008/01/20/rspec-new-pattern-option)

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![kasutaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5fc32e/32.png) [@kasutaja](https://www.ruby-forum.com/u/kasutaja)\
**Post date:** [May 27, 2008, 2:44pm UTC](https://www.ruby-forum.com/t/re-new-pattern-option/138731/3 "2008-05-27T14:44:00Z")

</div>

On 27 May 2008, at 12:37, David C. wrote:

> I updated my blog post to reflect this: [http://blog.davidchelimsky.net/articles/2008/01/20/rspec-new-pattern-option](http://blog.davidchelimsky.net/articles/2008/01/20/rspec-new-pattern-option)

Just out of curiosity, how come multiple patterns are specified comma-  
separated? It means I have to go and rename all the files I saved  
with extension “.rb,” 😉

Ashley

–

> **[PatchSpace](http://www.patchspace.co.uk/)**

> **[影视资源聚合平台](http://www.aviewfromafar.net/)**
>
> 为您提供高清电影、电视剧、动漫和综艺内容，支持在线观看与内容筛选。

---

<div class="post-metadata">

**Author:** ![kasutaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5fc32e/32.png) [@kasutaja](https://www.ruby-forum.com/u/kasutaja)\
**Post date:** [May 27, 2008, 2:59pm UTC](https://www.ruby-forum.com/t/re-new-pattern-option/138731/4 "2008-05-27T14:59:53Z")

</div>

On 27 May 2008, at 13:45, David C. wrote:

> How would you do it?

Everywhere I’ve seen something similar, it’s just been space-  
delimited, no punctuation. For example, this from the rsync man page:  
rsync -av host:‘dir1/file1 dir2/file2’ /dest

Not quite the same thing but it’s the closest I can think of off the  
top of my head.

It doesn’t affect me really, I just noticed the syntax and thought it  
looked odd.

Ashley

–

> **[PatchSpace](http://www.patchspace.co.uk/)**

> **[影视资源聚合平台](http://www.aviewfromafar.net/)**
>
> 为您提供高清电影、电视剧、动漫和综艺内容，支持在线观看与内容筛选。

---

<div class="post-metadata">

**Author:** ![kasutaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5fc32e/32.png) [@kasutaja](https://www.ruby-forum.com/u/kasutaja)\
**Post date:** [May 27, 2008, 2:45pm UTC](https://www.ruby-forum.com/t/re-new-pattern-option/138731/5 "2008-05-27T14:45:46Z")

</div>

On May 27, 2008, at 7:41 AM, Ashley M. wrote:

> On 27 May 2008, at 12:37, David C. wrote:
> 
> > I updated my blog post to reflect this: [http://blog.davidchelimsky.net/articles/2008/01/20/rspec-new-pattern-option](http://blog.davidchelimsky.net/articles/2008/01/20/rspec-new-pattern-option)
> 
> Just out of curiosity, how come multiple patterns are specified  
> comma-separated? It means I have to go and rename all the files I  
> saved with extension “.rb,” 😉

How would you do it?

---

<div class="post-metadata">

**Author:** ![kasutaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5fc32e/32.png) [@kasutaja](https://www.ruby-forum.com/u/kasutaja)\
**Post date:** [May 27, 2008, 4:12pm UTC](https://www.ruby-forum.com/t/re-new-pattern-option/138731/6 "2008-05-27T16:12:41Z")

</div>

On 27 May 2008, at 14:06, David C. wrote:

> I was thinking more of ant patternsets (from my java days). I think  
> they support comma or space separated, but all the examples I ever  
> saw (or wrote) used commas.

Ah ok, I guess it depends on your heritage. I’m lucky to have not had  
to build any serious Java projects. I did a lot with NAnt once upon a  
time, but I’ve successfully blocked that out of my mind. The therapy  
must have worked…

> You said something about having to rename files - not sure I get it.

Ignore me, I was just being stupid 🙂 I don’t really put commas at  
the end of my filenames. I’m sure I’ve seen something that does  
though, but I can’t remember what.

Ashley

–

> **[PatchSpace](http://www.patchspace.co.uk/)**

> **[影视资源聚合平台](http://www.aviewfromafar.net/)**
>
> 为您提供高清电影、电视剧、动漫和综艺内容，支持在线观看与内容筛选。

---

<div class="post-metadata">

**Author:** ![kasutaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5fc32e/32.png) [@kasutaja](https://www.ruby-forum.com/u/kasutaja)\
**Post date:** [May 27, 2008, 4:18pm UTC](https://www.ruby-forum.com/t/re-new-pattern-option/138731/7 "2008-05-27T16:18:01Z")

</div>

On Tue, May 27, 2008 at 10:12 AM, Ashley M.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ignore me, I was just being stupid 🙂 I don’t really put commas at the end  
> of my filenames. I’m sure I’ve seen something that does though, but I can’t  
> remember what.

RCS?

–  
Avdi

Home: [http://avdi.org](http://avdi.org)  
Developer Blog: [avdi.codes – Avdi Grimm, Code Cleric](http://avdi.org/devblog/)  
Twitter: [http://twitter.com/avdi](http://twitter.com/avdi)  
Journal: [http://avdi.livejournal.com](http://avdi.livejournal.com)

---

<div class="post-metadata">

**Author:** ![kasutaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5fc32e/32.png) [@kasutaja](https://www.ruby-forum.com/u/kasutaja)\
**Post date:** [May 27, 2008, 3:11pm UTC](https://www.ruby-forum.com/t/re-new-pattern-option/138731/8 "2008-05-27T15:11:39Z")

</div>

On May 27, 2008, at 7:59 AM, Ashley M. wrote:

> On 27 May 2008, at 13:45, David C. wrote:
> 
> > How would you do it?
> 
> Everywhere I’ve seen something similar, it’s just been space-  
> delimited, no punctuation. For example, this from the rsync man  
> page:  
> rsync -av host:‘dir1/file1 dir2/file2’ /dest

I was thinking more of ant patternsets (from my java days). I think  
they support comma or space separated, but all the examples I ever saw  
(or wrote) used commas.

You said something about having to rename files - not sure I get it.

---

<div class="post-metadata">

**Author:** ![kasutaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5fc32e/32.png) [@kasutaja](https://www.ruby-forum.com/u/kasutaja)\
**Post date:** [May 27, 2008, 4:21pm UTC](https://www.ruby-forum.com/t/re-new-pattern-option/138731/9 "2008-05-27T16:21:35Z")

</div>

On 27 May 2008, at 15:15, Avdi G. wrote:

> RCS?

Yes! Something else I’ve never had the pleasure of using.

I doubt any rspec users use RCS, but you never know.

Ashley

–

> **[PatchSpace](http://www.patchspace.co.uk/)**

> **[影视资源聚合平台](http://www.aviewfromafar.net/)**
>
> 为您提供高清电影、电视剧、动漫和综艺内容，支持在线观看与内容筛选。
