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
The latest Rspec gems don't require the old generator mentioned above, basically on giving rails g in your rails app you would get all the list of generators with your app.
Thus, once you have installed the Rspec related gems, then give a rails g to your app, you need to basically run only one of the generator command from the modified list that you would get, which is rspec:install and this would be enough to get you up & running at least with a proof of concept(poc).
Related
I've installed rails using rvm. I've loaded rvm using ~/.bahsrc.
rails is working fine.
which rails
/home/user/.rvm/gems/ruby-2.1.0/bin/rails
but in that rails project folder which command says
/home/dinesh/.rvm/gems/ruby-2.0.0-p353#something/bin/rails
How's this happening? How to make my rails work in that folder?
If you are in the root of a rails project you may use
./script/rails --version # (or whatever rails command you want to call)
to be sure to use the rails version that corresponds to your project. Usually rails magic will apply inside a rails project and "happen" to find the correct version of rails, but there seems to be a number of things that can go wrong about that.
I just upgraded to rails 3.2.5 and now when I generate new controllers I don't get rspec tests generated by default.
I can do rails g controller foo -t rspec, but I'd prefer to just do rails g controller foo.
How do I fix that default?
You need to do rails g rspec:install inside your project folder (presuming you have rspec in your gem file/bundle). That will activate the generators for you.
Mark of Mark's Blog has an excellent article on it here.
I'm working through Michael Hartl's excellent Rails 3 Tutorial book, but I am stuck at section 3.2.2. in which he refers to rspec tests being auto-generated from
rails generate Pages home contact
rails generate rspec:install
I've noticed a few points in which the current releases of gems differ, and that's expected, but all I see in my spec directory is a file called 'spec_helper.rb'. So I'm missing the following directories that, according to the tutorial, should exits:
spec/helpers
spec/views
spec/controllers
Is this something RSpec or Rails no longer generates?
You must be using the 3.0 version of the tutorial - you'll be much happier if you use the 3.2 version instead. It's so new that it might actually still be in beta, but I'm almost done with it now and pretty much everything has worked exactly as listed, which is awesome.
(I also did the 3.0 version a month or so ago and had the same issues as you with things being out of date here and there. The testing suite in particular is majorly different between the two versions.)
I have installed rails 3.1 on my system but currently I have to work on rails 3.0 project. How can I run it. Otherwise it suggests me to use bundle exec for every command.
Secondly, it is showing me the following error :-
Command 'exiftool' not found.
How to get rid of these errors. Please guide.
Thanx.
Command 'exiftool' not found.
Upgrading to Rails 3.1 (screencast, first few minutes if you don't need Asset Pipeline)
Consider using RVM. With this thingumajig you can have different gemset (including rails, rusty and shiny) and even ruby version for each of your applications. Start from here.
I'm sure this is astonishingly straightforward, and I'm just inexperienced with Rails 3, but I can't figure out how to make it work.
I'm trying to install the paper_trail plugin into my Rails 3 app; but the instructions seem designed for Rails 2. I'm running under Windows, and don't have git available.
I've tried putting gem 'paper_trail' into my Gemfile and running bundle install, which picked up the gem correctly; but rails generate paper_trail (which I assume is the new form of script/generate paper_trail fails with Could not find generator paper_trail.
Can anyone give me some step-by-step instructions to get this working?
A little late to the party. I am writing this since I found the thread through Google. Here is how I got it to work with Rail 3.0.9. I was getting the same error with
bundle exec rails generate paper_trail
as well as
bundle exec rails g paper_trail
and
rails generate paper_trail
Turns out, you need to run
bundle exec rails generate paper_trail:install
that generated the migration file for me and a
bundle exec rake db:migrate
created the table.
As of 11 October, rails generate paper_trail works as you would expect.
I've managed to make this work by simply downloading the zipped code from github, unpacking it into vendor/plugins, installing the gem (through Gemfile and bundle install), and then copy-pasting the migration code in paper_trail's generator into a blank migration of the same name.