Rspec Controller Generator

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.

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
[email protected]

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
[email protected]

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.

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.

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!

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
[email protected]

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
[email protected]

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…

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

[email protected]
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

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.