doc/src/tools/rails.page in rspec-0.5.4 vs doc/src/tools/rails.page in rspec-0.5.5

- old
+ new

@@ -1,9 +1,75 @@ --- -title: Rails Integration +title: RSpec on Rails inMenu: true --- -h2. Rails Integration +h2. RSpec on Rails -Rspec's support for Rails is in a very early and experimental stage. -If you are adventurous, you can check out the branches/ar_fixtures_facade branch in Subversion. -See the downloads page for details. +RSpec's rspec_generator Rubygem brings RSpec to Rails. + +h3. Features + +* Integrated fixture loading +* Uses many of the controller-test integration features +* Special generators for models and controllers that generate specs instead of tests. + +h3. Installation + +RSpec support for rails lives in a separate gem. Install that gem: +<pre> +gem install rspec_generator +</pre> + +Once the gem is installed, you must configure you Rails app. Stand in the root of your Rails app and run: +<pre> +ruby script/generate rspec +</pre> + +Now, you can generate models and controllers in a similar fashion to Rails' builtin generators. Example: + +<pre> +ruby script/generate rspec_model person +</pre> + +or + +<pre> +ruby script/generate rspec_controller person +</pre> + +For more information on each generator, just run them without any arguments. + +h3. Running specs + +Model specs can be run with +<pre> +rake spec:models +</pre> + +Controller specs can be run with +<pre> +rake spec:controllers +</pre> + +To see all the RSpec related tasks, run +<pre> +rake --tasks spec +</pre> + +h3. Naming conventions + +When you use Rails without RSpec (with Test::Unit), tests for models end up in tests/unit and tests for controllers +end up in tests/functional. + +In order to make things more consistent, RSpec chooses a slightly different naming convention for direcotries and +Rake tasks. So you will find model specs under specs/models, and controller specs under specs/controllers. The +Rake tasks are named accordingly. + +h3. Examples + +RSpec on Rails adds several methods to your specs with a look and feel similar to Test::Unit. Example: + +Model: +<ruby file="../vendor/rspec_on_rails/spec/models/person_spec.rb"/> + +Controller: +<ruby file="../vendor/rspec_on_rails/spec/controllers/person_controller_spec.rb"/>