How to use rspec_scaffold generator with latest rspec gem

Hi,

I am a newbie to Rails 3 and Rspec. Kindly excuse my being a novice.

I am trying to use RSpec with Rails 3. I am using rails 3.0.3 and ruby
1.9.2 on ubuntu 10.04 os.

I am currently referring to the tutorial on :-
http://www.railsfire.com/article/rspec-behaviour-driven-development-testing-framework.
This tutorial not only uses old plugins , but old Rails version of 2.x
also.

I am unable to use the old rspec generator ( rspec_scaffold ) with rspec
2.5 and rspec-rails 2.5 gem. As expected I get the following error as
given below.

mohnish@mohnish-desktop:~/rails_testing/10Mar11/rspec_demo3$ rails g

rspec_scaffold post title:string body:text
Could not find generator rspec_scaffold.
mohnish@mohnish-desktop:~/rails_testing/10Mar11/rspec_demo3$

Could you please tell me how should I give to accordingly for it to work
for me using the above RoR configuration.

Thanks

On Mar 10, 2011, at 7:49 AM, Mohnish J. wrote:

also.
Could you please tell me how should I give to accordingly for it to work
for me using the above RoR configuration.

rails generate rspec:install
rails generate scaffold

In Rails 3, once you run the rspec:install generator, the Rails
generators delegate out to rspec-rails to generate the spec files.

You might also want to check out http://ruby.railstutorial.org/.

Cheers,
David

On Thu, Mar 10, 2011 at 7:49 AM, Mohnish J. [email protected]
wrote:

for me using the above RoR configuration.

Hi Mohnish,

The rails generator script will produce a list of it’s generators if
you simply type ‘rails g’ you can get further assistance by typing
‘rails g generator --help’ such as ‘rails g scaffold --help’ I
suspect that you are wanting to generate a scaffold with all of the
rspec tests as well, because rails 3 went modular you no longer need a
special command to get rspec tests, simply by installing the gem and
including it in both :development and :test environments in your
Gemfile, your scaffold generator will automatically produce rspec
tests for you. First check to make sure the rspec:install generator
is listed under ‘rails g’ and that you have run that generator first,
then you can ‘rails g scaffold’ and the model/controller/views and
necessary specs will be generated.

Rspec 2 docs are a bit of a work in progress at the moment as I
understand it but there is much to be gleaned from referencing
http://relishapp.com/rspec before you email the list. Specifically
the rspec-rails section.

Hope that helps,
Cole

Hi Cole,

Thanks for the link and yorr reply. Yep , I did want to generate a
scaffold with all rspec tests.

Pixel wrote in post #986740:

On Thu, Mar 10, 2011 at 7:49 AM, Mohnish J. [email protected]
wrote:

for me using the above RoR configuration.

Hi Mohnish,

The rails generator script will produce a list of it’s generators if
you simply type ‘rails g’ you can get further assistance by typing
‘rails g generator --help’ such as ‘rails g scaffold --help’ I
suspect that you are wanting to generate a scaffold with all of the
rspec tests as well, because rails 3 went modular you no longer need a
special command to get rspec tests, simply by installing the gem and
including it in both :development and :test environments in your
Gemfile, your scaffold generator will automatically produce rspec
tests for you. First check to make sure the rspec:install generator
is listed under ‘rails g’ and that you have run that generator first,
then you can ‘rails g scaffold’ and the model/controller/views and
necessary specs will be generated.

Rspec 2 docs are a bit of a work in progress at the moment as I
understand it but there is much to be gleaned from referencing
http://relishapp.com/rspec before you email the list. Specifically
the rspec-rails section.

Hope that helps,
Cole

David C. wrote in post #986732:

On Mar 10, 2011, at 7:49 AM, Mohnish J. wrote:

also.
Could you please tell me how should I give to accordingly for it to work
for me using the above RoR configuration.

rails generate rspec:install
rails generate scaffold

In Rails 3, once you run the rspec:install generator, the Rails
generators delegate out to rspec-rails to generate the spec files.

You might also want to check out http://ruby.railstutorial.org/.

Cheers,
David

Hi David,

I have posted the same question stackoverflow.com(
ruby on rails 3 - How to use rspec_scaffold generator with latest rspec gem - Stack Overflow
). It being posted around the same time that you had given your solution
on this forum. Kindly post your answer in stackoverflow.com so that you
could get your rightful credit for the answer to the question.

I shall accept the answer once you have posted the same.

Thanks again for your support.

David C. wrote in post #986732:

On Mar 10, 2011, at 7:49 AM, Mohnish J. wrote:

also.
Could you please tell me how should I give to accordingly for it to work
for me using the above RoR configuration.

rails generate rspec:install
rails generate scaffold

In Rails 3, once you run the rspec:install generator, the Rails
generators delegate out to rspec-rails to generate the spec files.

You might also want to check out http://ruby.railstutorial.org/.

Cheers,
David

Hi David,

Thank you very much for you reply, I now understand that this isn’t
needed anymore with Rails 3. I had in another post on the same forum
mentioned about one of your blogs:-

http://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-part-i/.

I am unable to find Part 2 of your tutorial. Could you please tell me
where could I find the same.

Thanks again…:slight_smile: