# Rspec Controller Generator

**URL:** <https://www.ruby-forum.com/t/rspec-controller-generator/169386>\
**Category:** Rails\
**Created:** [June 3, 2009, 4:59am UTC](https://www.ruby-forum.com/t/rspec-controller-generator/169386 "2009-06-03T04:59:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [June 3, 2009, 4:59am UTC](https://www.ruby-forum.com/t/rspec-controller-generator/169386/1 "2009-06-03T04:59:07Z")

</div>

I’m using Ruby 1.9.1-p129 on Windows  
Rails 2.3.2  
I have Rspec and Rspec\_generator and use Netbeans 6.5 IDE…

When I try to generate Rspec Controller, everything works except for the  
final view which errors out because it says it’s looking for view.rhtml

…in…

C:\Ruby\lib\ruby\gems\1.9.1\gems\rails-2.3.2\lib\rails\_generator\generators\components\controller\templates

…which…

won’t work because that contains view.html.erb which is the new format

So, to bypass that error I’ve been running Rspec Controller generator  
and then I follow it with generating a normal Controller which appears  
to work.

The question I have is does this create any potential issues? Is there  
another workaround that is better to use?

Many thanks.

---

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [June 3, 2009, 7:02am UTC](https://www.ruby-forum.com/t/rspec-controller-generator/169386/2 "2009-06-03T07:02:37Z")

</div>

J. D. wrote:

> I’m using Ruby 1.9.1-p129 on Windows  
> Rails 2.3.2  
> I have Rspec and Rspec\_generator and use Netbeans 6.5 IDE…

Rspec\_generator? What’s that? I’ve never heard of it.

> When I try to generate Rspec Controller, everything works except for the  
> final view which errors out because it says it’s looking for view.rhtml  
> […]

I use RSpec on all my projects, and I can assure you that this is not  
normal behavior. Perhaps you’re using an older version of rspec-rails  
that doesn’t know about current template naming conventions. Try  
upgrading your RSpec installation.

## Best,

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

---

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [June 3, 2009, 3:29pm UTC](https://www.ruby-forum.com/t/rspec-controller-generator/169386/3 "2009-06-03T15:29:25Z")

</div>

Marnen Laibow-Koser wrote:

> J. D. wrote:
> 
> > I’m using Ruby 1.9.1-p129 on Windows  
> > Rails 2.3.2  
> > I have Rspec and Rspec\_generator and use Netbeans 6.5 IDE…
> 
> Rspec\_generator? What’s that? I’ve never heard of it.
> 
> > When I try to generate Rspec Controller, everything works except for the  
> > final view which errors out because it says it’s looking for view.rhtml  
> > […]
> 
> I use RSpec on all my projects, and I can assure you that this is not  
> normal behavior. Perhaps you’re using an older version of rspec-rails  
> that doesn’t know about current template naming conventions. Try  
> upgrading your RSpec installation.
> 
> ## Best,
> 
> Marnen Laibow-Koser  
> [http://www.marnen.org](http://www.marnen.org)  
> removed\_email\_address@domain.invalid

Hi Marnen,

I really appreciate you responding to my post.

On my system I have the following gems:

rspec (0.5.15)  
rspec\_generator (0.5.15)

I use netbeans IDE and so it helps automating some of the tasks while  
using rails. When I want to create an Rspec Controller by generating it  
through netbeans, if a generator is not installed with netbeans, I can  
select a generator and it installs the gem for that piece.

I didn’t even have rspec-rails so I just did a gem install for that and  
now I see:

rspec (1.2.6, 0.5.15)  
rspec-rails (1.2.6)  
rspec\_generator (0.5.15)

… so it appears I had an older version of rspec and didn’t realise  
that. I didn’t even have rspec-rails installed. I’ll have to test it  
out again through netbeans to see if it works. If it does not then I  
believe the issue is with the netbeans IDE using an older gem to  
generate rspec controllers.

I’ll test it shortly and post back with what I find out.

---

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [June 3, 2009, 3:45pm UTC](https://www.ruby-forum.com/t/rspec-controller-generator/169386/4 "2009-06-03T15:45:50Z")

</div>

Okay I figured it out - thanks to your direction!

I uninstalled rspec\_generator gem (very outdated)

I copied rspec and rspec-rails to the vendor/plugins directory and now  
netbeans IDE sees the correct generators.

If anyone else has this same issue - that’s the fix.

---

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [June 3, 2009, 3:32pm UTC](https://www.ruby-forum.com/t/rspec-controller-generator/169386/5 "2009-06-03T15:32:48Z")

</div>

Yes, that is the issue.

The Netbeans IDE 6.5 interface which I use to generate Rspec controllers  
uses a gem called rspec\_generator which is outdated and uses the old  
format (which makes sense considering the version numbers match the  
“old” version numbers). I’ll try to find a newer version of that gem  
somewhere that matches 1.2.6 so that the IDE works properly again.

Many thanks!

---

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [June 3, 2009, 3:50pm UTC](https://www.ruby-forum.com/t/rspec-controller-generator/169386/6 "2009-06-03T15:50:43Z")

</div>

J. D. wrote:

> Yes, that is the issue.
> 
> The Netbeans IDE 6.5 interface which I use to generate Rspec controllers  
> uses a gem called rspec\_generator which is outdated and uses the old  
> format (which makes sense considering the version numbers match the  
> “old” version numbers). I’ll try to find a newer version of that gem  
> somewhere that matches 1.2.6  
> I doubt that you will have much luck with that. As I said, I’ve never  
> heard of it despite using RSpec regularly, so I assume its place has  
> been taken by rspec-rails.

> so that the IDE works properly again.
> 
> Many thanks!

If NetBeans is expecting the rspec\_generator gem, perhaps you should  
upgrade its Rails tools…or switch IDEs…or just do without an IDE as  
such. Unlike, say, J2EE, Rails doesn’t really need most of the stuff  
that IDEs are good at (although I plan to try NetBeans myself sometime),  
and if NetBeans is expecting a particular setup that’s no longer  
accurate, then it’s actually hurting your productivity, not helping it.

## Best,

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

---

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [June 3, 2009, 4:29pm UTC](https://www.ruby-forum.com/t/rspec-controller-generator/169386/7 "2009-06-03T16:29:23Z")

</div>

Marnen Laibow-Koser wrote:

> if NetBeans is expecting a particular setup that’s no longer  
> accurate, then it’s actually hurting your productivity, not helping it.
> 
> ## Best,
> 
> Marnen Laibow-Koser  
> [http://www.marnen.org](http://www.marnen.org)  
> removed\_email\_address@domain.invalid

It wasn’t hurting me - I just didn’t realize some of the extra steps I  
needed to do. Netbeans is really a great IDE (and I’ve tried a lot of  
them). I stayed with netbeans because it created the least amount of  
problems for me.

In this particular case the issue was not to automatically download the  
generator file but to just copy the correct gems into the plugins  
directory so that they were up to date. After I did this, everything is  
working flawlessly and no more issues.

Keep in mind that I’m using Ruby 1.9.1-p129 with Windows Vista so  
there’s always a ton of issues present with that install platform right  
now. Luckily, I’ve gotten past all of the hoops and hurdles. I have  
mysql, sqlite3 installed (those were the toughest to get installed using  
this platform). I have the latest rails and now my rspec is up to date  
and working properly. So, I feel one more step closer to virtual  
bliss…

---

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [June 3, 2009, 11:13pm UTC](https://www.ruby-forum.com/t/rspec-controller-generator/169386/8 "2009-06-03T23:13:09Z")

</div>

On Jun 3, 2009, at 7:29 AM, J. D. wrote:

> > removed\_email\_address@domain.invalid  
> > everything is  
> > and working properly. So, I feel one more step closer to virtual  
> > bliss…

FWIW, I would recommend using the gems instead of the plugins. You can  
put the configs in your config/environments/test.rb as such:

config.gem ‘rspec’, :version =\> “\>=1.2.6” , :lib =\> false  
config.gem ‘rspec-rails’, :version =\> ‘\>=1.2.6’, :lib =\> false  
config.gem ‘webrat’, :version =\> ‘\>=0.4.4’, :lib =\> false  
config.gem ‘faker’, :version =\> ‘\>=0.3.1’, :lib =\> ‘faker’  
config.gem ‘notahat-machinist’, :version =\> ‘\>=0.3.1’, :lib =\>  
‘machinist’, :source =\>‘[http://gems.github.com](http://gems.github.com)’

The nice thing about gems is that you can include them on a per-  
environment basis. Plugins load by default in all environments.

I also use webrat, faker, and machinist … you may want to check  
these out.

Once you’ve updated your config file, just:

rake gems RAILS\_ENV=test

and you will see that some of the gems are not installed. To install  
them, either do it manually, or let Rails help out:

rake gems:install RAILS\_ENV=test

Finally, when you want to generate a controller and spec, just:

ruby script/generate rspec\_controller some\_controller\_name

and when you want a model and spec:

ruby script/generate rspec\_model some\_model\_name

These aren’t scaffolding generators; they just create the empty spec  
files and they don’t clutter up your test directory with tests you  
won’t use because you’re writing specs instead.
