# Oh no! I have a "Spec" model

**URL:** <https://www.ruby-forum.com/t/oh-no-i-have-a-spec-model/182360>\
**Category:** Rails\
**Created:** [January 27, 2010, 12:52am UTC](https://www.ruby-forum.com/t/oh-no-i-have-a-spec-model/182360 "2010-01-27T00:52:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [January 27, 2010, 12:52am UTC](https://www.ruby-forum.com/t/oh-no-i-have-a-spec-model/182360/1 "2010-01-27T00:52:57Z")

</div>

I am trying to use cucumber but my application has a “Spec” model (I  
followed the RailsSpace book). So now I am getting an error when  
running cucumber (below). I think because cucumber does not like a  
model named “Spec.” But I have “Spec” and “spec(s)” everywhere in my  
application now. A universal text change is a huge pain. Some  
innocent text contains the string “spec”, e.g. “aspect”. So I have to  
look at each replacement. What can I do? Please help. Thanks.

Spec is not a class (TypeError)  
/Volumes/Data/Beo/Documents/RailsSpace/app/models/spec.rb:1  
/opt/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:31:in  
`gem_original_require' /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`polyglot\_original\_require’  
/opt/local/lib/ruby/gems/1.8/gems/polyglot-0.2.9/lib/polyglot.rb:70:in  
`require' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:158:in`require’  
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/  
active\_support/dependencies.rb:265:in `require_or_load' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:224:in`depend\_on’  
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/  
active\_support/dependencies.rb:136:in `require_dependency' /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb: 414:in`load\_application\_classes’  
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:  
413:in `each' /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb: 413:in`load\_application\_classes’  
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:  
411:in `each' /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb: 411:in`load\_application\_classes’  
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:  
197:in `process' /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb: 113:in`send’  
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:  
113:in `run' /Volumes/Data/Beo/Documents/OptiDev/config/environment.rb:9 /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`gem\_original\_require’  
/opt/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:31:in  
`polyglot_original_require' /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.2.9/lib/polyglot.rb:70:in`require’  
/Volumes/Data/Beo/Documents/OptiDev/features/support/env.rb:8  
/opt/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:31:in  
`gem_original_require' /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`polyglot\_original\_require’  
/opt/local/lib/ruby/gems/1.8/gems/polyglot-0.2.9/lib/polyglot.rb:70:in  
`require' /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.6.1/bin/../lib/cucumber/ rb_support/rb_language.rb:124:in`load\_code\_file’  
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.6.1/bin/…/lib/cucumber/  
step\_mother.rb:84:in `load_code_file' /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.6.1/bin/../lib/cucumber/ step_mother.rb:76:in`load\_code\_files’  
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.6.1/bin/…/lib/cucumber/  
step\_mother.rb:75:in `each' /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.6.1/bin/../lib/cucumber/ step_mother.rb:75:in`load\_code\_files’  
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.6.1/bin/…/lib/cucumber/  
cli/main.rb:48:in `execute!' /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.6.1/bin/../lib/cucumber/ cli/main.rb:20:in`execute’  
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.6.1/bin/cucumber:8  
/opt/local/bin/cucumber:19:in `load’  
/opt/local/bin/cucumber:19

---

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [January 27, 2010, 1:58am UTC](https://www.ruby-forum.com/t/oh-no-i-have-a-spec-model/182360/2 "2010-01-27T01:58:31Z")

</div>

On Jan 26, 6:51 pm, Vincent P [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am trying to use cucumber but my application has a “Spec” model (I  
> followed the RailsSpace book).

…which is quite out of date.

> So now I am getting an error when  
> running cucumber (below). I think because cucumber does not like a  
> model named “Spec.”

Actually, I think that would be more of a proble for RSpec. But I  
could be wrong.

> But I have “Spec” and “spec(s)” everywhere in my  
> application now. A universal text change is a huge pain. Some  
> innocent text contains the string “spec”, e.g. “aspect”. So I have to  
> look at each replacement.

Well, you should look at each replacement anyway.

> What can I do? Please help.

Try a regular expression search and replace, so that you don’t hit  
innocent words.

> Thanks.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [January 27, 2010, 2:10am UTC](https://www.ruby-forum.com/t/oh-no-i-have-a-spec-model/182360/3 "2010-01-27T02:10:49Z")

</div>

Thanks. So the problem is the “Spec” model name? There is no other  
way but to change “Spec” to something else?

I started with RailsSpace as a starting point a while back but my  
application has evolved since.

---

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [January 27, 2010, 3:43am UTC](https://www.ruby-forum.com/t/oh-no-i-have-a-spec-model/182360/4 "2010-01-27T03:43:14Z")

</div>

Learn by Doing wrote:

> Thanks. So the problem is the “Spec” model name?

Most likely.

> There is no other  
> way but to change “Spec” to something else?

Probably not. And this should not be difficult.

> I started with RailsSpace as a starting point a while back but my  
> application has evolved since.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [January 27, 2010, 8:07am UTC](https://www.ruby-forum.com/t/oh-no-i-have-a-spec-model/182360/5 "2010-01-27T08:07:09Z")

</div>

Learn by Doing wrote:

> Thanks Marnen. I am trying to use regular expression to replace the  
> text “spec” in TextMate with “mug”. I am trying to avoid instances of  
> “spec” where it does not mean the name of the model, e.g. “aspect”.  
> So I use the following regular expression: [^a-zA-Z]spec . That  
> would catch “@spec” which is what I want. But if I tell TextMate to  
> replace that with “mug”, I lose the character before “spec”. TextMate  
> replaces “@spec” with “mug” . How can I make it replace @spec with  
> @mug ?

Most regexp syntaxes support backreferences in the replace string, which  
is what you need. Check TextMate’s documentation to see how it  
implements backreferences.

> Thanks.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [January 27, 2010, 9:17am UTC](https://www.ruby-forum.com/t/oh-no-i-have-a-spec-model/182360/6 "2010-01-27T09:17:26Z")

</div>

Thanks Marnen!

I will surely look into back references next time. Before I got your  
answer, I managed to do this manually by replacing “Spec” then “spec”  
when  
preceded with each of the special characters: @ : ’ " / - ! space. I  
downloaded and used “Name Mangler” to replace “spec” in file names.  
While  
tedious, you are right that it is not too difficult. Cucumber seems to  
work  
now. I am ready to dive into BDD.

Thank you so much for your help.

Vincent

On Tue, Jan 26, 2010 at 11:07 PM, Marnen Laibow-Koser

---

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [January 29, 2010, 9:53pm UTC](https://www.ruby-forum.com/t/oh-no-i-have-a-spec-model/182360/7 "2010-01-29T21:53:39Z")

</div>

Marnen!

Thank you so much for motivating me to use Cucumber. It makes  
functional and integration testing so easy!

Vincent.

---

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [January 30, 2010, 12:11am UTC](https://www.ruby-forum.com/t/oh-no-i-have-a-spec-model/182360/8 "2010-01-30T00:11:15Z")

</div>

Learn by Doing wrote:

> Marnen!
> 
> Thank you so much for motivating me to use Cucumber. It makes  
> functional and integration testing so easy!

You’re most welcome. It’s amazing, isn’t it?

> Vincent.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [January 27, 2010, 6:13am UTC](https://www.ruby-forum.com/t/oh-no-i-have-a-spec-model/182360/9 "2010-01-27T06:13:06Z")

</div>

Thanks Marnen. I am trying to use regular expression to replace the  
text “spec” in TextMate with “mug”. I am trying to avoid instances of  
“spec” where it does not mean the name of the model, e.g. “aspect”.  
So I use the following regular expression: [^a-zA-Z]spec . That  
would catch “@spec” which is what I want. But if I tell TextMate to  
replace that with “mug”, I lose the character before “spec”. TextMate  
replaces “@spec” with “mug” . How can I make it replace @spec with  
@mug ?

Thanks.
