Skip to content

Commit

Permalink
rdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Dec 8, 2011
1 parent c1f0eab commit 0e6b185
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 29 deletions.
32 changes: 18 additions & 14 deletions README.md
Expand Up @@ -2,19 +2,23 @@


rspec-2 for rails-3 with lightweight extensions to each rspec-2 for rails-3 with lightweight extensions to each


NOTE: Use rspec-rails-1.3.x for rails-2. Note: Use [rspec-rails-1.3](http://github.com/dchelimsky/rspec-rails) for rails-2.


## Install ## Install


gem install rspec-rails ```
gem install rspec-rails
```


This installs the following gems: This installs the following gems:


rspec ```
rspec-core rspec
rspec-expectations rspec-core
rspec-mocks rspec-expectations
rspec-rails rspec-mocks
rspec-rails
```


## Configure ## Configure


Expand All @@ -31,7 +35,9 @@ tasks without having to type `RAILS_ENV=test`.


Now you can run: Now you can run:


rails generate rspec:install ```
rails generate rspec:install
```


This adds the spec directory and some skeleton files, including This adds the spec directory and some skeleton files, including
the "rake spec" task. the "rake spec" task.
Expand Down Expand Up @@ -116,9 +122,7 @@ Controller specs live in spec/controllers, and mix in
ActionController::TestCase::Behavior, which is the basis for Rails' functional ActionController::TestCase::Behavior, which is the basis for Rails' functional
tests. tests.


## Examples ## with fixtures

### with fixtures


```ruby ```ruby
describe WidgetsController do describe WidgetsController do
Expand All @@ -133,7 +137,7 @@ describe WidgetsController do
end end
``` ```


### with a factory ## with a factory


```ruby ```ruby
describe WidgetsController do describe WidgetsController do
Expand Down Expand Up @@ -162,7 +166,7 @@ describe WidgetsController do
end end
``` ```


## Matchers ## matchers


In addition to the stock matchers from rspec-expectations, controller In addition to the stock matchers from rspec-expectations, controller
specs add these matchers, which delegate to rails' assertions: specs add these matchers, which delegate to rails' assertions:
Expand All @@ -175,7 +179,7 @@ response.should redirect_to(destination)
# => delegates to assert_redirected_to(destination) # => delegates to assert_redirected_to(destination)
``` ```


## Isolation from views ## isolation from views


RSpec's preferred approach to spec'ing controller behaviour is to isolate RSpec's preferred approach to spec'ing controller behaviour is to isolate
the controller from its collaborators. By default, therefore, controller the controller from its collaborators. By default, therefore, controller
Expand Down
1 change: 1 addition & 0 deletions lib/generators/rspec/integration/integration_generator.rb
Expand Up @@ -16,6 +16,7 @@ def generate_request_spec


protected protected


# @deprecated Use `--webrat` instead.
def webrat? def webrat?
RSpec.deprecate("the --webrat-matchers option", "--webrat") if options[:webrat_matchers] RSpec.deprecate("the --webrat-matchers option", "--webrat") if options[:webrat_matchers]
options[:webrat] || options[:webrat_matchers] options[:webrat] || options[:webrat_matchers]
Expand Down
1 change: 1 addition & 0 deletions lib/generators/rspec/scaffold/scaffold_generator.rb
Expand Up @@ -51,6 +51,7 @@ def generate_routing_spec


protected protected


# @deprecated Use `--webrat` instead.
def webrat? def webrat?
RSpec.deprecate("--webrat-matchers", "--webrat") if options[:webrat_matchers] RSpec.deprecate("--webrat-matchers", "--webrat") if options[:webrat_matchers]
options[:webrat] || options[:webrat_matchers] options[:webrat] || options[:webrat_matchers]
Expand Down
22 changes: 11 additions & 11 deletions lib/rspec/rails/example/controller_example_group.rb
Expand Up @@ -13,7 +13,7 @@ module ControllerExampleGroup
include RSpec::Rails::Matchers::RoutingMatchers include RSpec::Rails::Matchers::RoutingMatchers


module ClassMethods module ClassMethods
# @api private # @private
def controller_class def controller_class
described_class described_class
end end
Expand All @@ -23,6 +23,13 @@ def controller_class
# `body` in that context. Also sets up implicit routes for this # `body` in that context. Also sets up implicit routes for this
# controller, that are separate from those defined in "config/routes.rb". # controller, that are separate from those defined in "config/routes.rb".
# #
# @note Due to Ruby 1.8 scoping rules in anoymous subclasses, constants
# defined in `ApplicationController` must be fully qualified (e.g.
# `ApplicationController::AccessDenied`) in the block passed to the
# `controller` method. Any instance methods, filters, etc, that are
# defined in `ApplicationController`, however, are accessible from
# within the block.
#
# @example # @example
# #
# describe ApplicationController do # describe ApplicationController do
Expand All @@ -43,16 +50,9 @@ def controller_class
# If you would like to spec a subclass of ApplicationController, call # If you would like to spec a subclass of ApplicationController, call
# controller like so: # controller like so:
# #
# controller(ApplicationControllerSubclass) do # controller(ApplicationControllerSubclass) do
# # .... # # ....
# end # end
#
# NOTICE: Due to Ruby 1.8 scoping rules in anoymous subclasses, constants
# defined in `ApplicationController` must be fully qualified (e.g.
# ApplicationController::AccessDenied) in the block passed to the
# `controller` method. Any instance methods, filters, etc, that are
# defined in `ApplicationController`, however, are accessible from within
# the block.
def controller(base_class = nil, &body) def controller(base_class = nil, &body)
base_class ||= RSpec.configuration.infer_base_class_for_anonymous_controllers? ? base_class ||= RSpec.configuration.infer_base_class_for_anonymous_controllers? ?
controller_class : controller_class :
Expand Down
4 changes: 2 additions & 2 deletions lib/rspec/rails/example/view_example_group.rb
Expand Up @@ -80,13 +80,13 @@ def params
controller.params controller.params
end end


# @deprecated # use `view` instead. # @deprecated Use `view` instead.
def template def template
RSpec.deprecate("template","view") RSpec.deprecate("template","view")
view view
end end


# @deprecated # use `rendered` instead. # @deprecated Use `rendered` instead.
def response def response
RSpec.deprecate("response", "rendered") RSpec.deprecate("response", "rendered")
rendered rendered
Expand Down
3 changes: 2 additions & 1 deletion lib/rspec/rails/module_inclusion.rb
@@ -1,6 +1,7 @@
module RSpec::Rails module RSpec::Rails
module ModuleInclusion module ModuleInclusion
# Deprecated as of rspec-rails-2.4 # @deprecated No replacement.
#
# Will be removed from rspec-rails-3.0 # Will be removed from rspec-rails-3.0
# #
# This was never intended to be a public API and is no longer needed # This was never intended to be a public API and is no longer needed
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/rails/view_rendering.rb
Expand Up @@ -39,7 +39,7 @@ def render_views(true_or_false=true)
metadata_for_rspec_rails[:render_views] = true_or_false metadata_for_rspec_rails[:render_views] = true_or_false
end end


# @deprecated use render_views # @deprecated Use `render_views` instead.
def integrate_views def integrate_views
RSpec.deprecate("integrate_views","render_views") RSpec.deprecate("integrate_views","render_views")
render_views render_views
Expand Down
16 changes: 16 additions & 0 deletions yard/template/default/fulldoc/html/css/rspec.css
@@ -1,4 +1,20 @@
.notetag {
background-color: #FFE5E5;
}

code { code {
background-color: #F0F0F0; background-color: #F0F0F0;
padding: 0 2px 0 2px; padding: 0 2px 0 2px;
} }

.deprecated code {
background-color: #FFA8A8;
}

.summary_desc code {
background-color: #F0F0F0;
}

.notetag code {
background-color: #FFA8A8;
}

0 comments on commit 0e6b185

Please sign in to comment.