Skip to content

Commit

Permalink
rdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Nov 20, 2011
1 parent 08ceb6f commit 130c94f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
1 change: 1 addition & 0 deletions .yardopts
@@ -1,5 +1,6 @@
--no-private
--exclude features
--exclude lib/generators/**/*_spec.rb
--markup markdown
-
README.md
2 changes: 2 additions & 0 deletions Rakefile
Expand Up @@ -123,6 +123,8 @@ desc 'clobber generated files'
task :clobber do
rm_rf "pkg"
rm_rf "tmp"
rm_rf "doc"
rm_rf ".yardoc"
rm "Gemfile.lock" if File.exist?("Gemfile.lock")
end

Expand Down
50 changes: 31 additions & 19 deletions lib/rspec/rails/example/controller_example_group.rb
Expand Up @@ -3,24 +3,29 @@
end

module RSpec::Rails
# Extends ActionController::TestCase::Behavior to work with RSpec.
# Extends ActionController::TestCase::Behavior to work with RSpec, with
# some caveats.
#
# == Examples
# rspec-rails is designed to support separate specs for models, controllers,
# views (where appropriate) and helpers. Rails allows this separation, but
# discourages real isolation by rendering views in controller tests
#
# == with stubs
# ## Examples
#
# ### with fixtures
#
# describe WidgetsController do
# describe "GET index" do
# fixtures :widgets
#
# it "assigns all widgets to @widgets" do
# widget = stub_model(Widget)
# Widget.stub(:all) { widget }
# get :index
# assigns(:widgets).should eq([widget])
# assigns(:widgets).should eq(Widget.all)
# end
# end
# end
#
# === with a factory
# ### with a factory
#
# describe WidgetsController do
# describe "GET index" do
Expand All @@ -32,31 +37,31 @@ module RSpec::Rails
# end
# end
#
# === with fixtures
# ## with stubs
#
# describe WidgetsController do
# describe "GET index" do
# fixtures :widgets
#
# it "assigns all widgets to @widgets" do
# widget = stub_model(Widget)
# Widget.stub(:all) { widget }
# get :index
# assigns(:widgets).should eq(Widget.all)
# assigns(:widgets).should eq([widget])
# end
# end
# end
#
# == Matchers
# ## Matchers
#
# In addition to the stock matchers from rspec-expectations, controller
# specs add these matchers, which delegate to rails' assertions:
#
# response.should render_template(*args)
# => delegates to assert_template(*args)
# response.should render_template(*args)
# # => delegates to assert_template(*args)
#
# response.should redirect_to(destination)
# => delegates to assert_redirected_to(destination)
# response.should redirect_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
# the controller from its collaborators. By default, therefore, controller
Expand All @@ -68,7 +73,7 @@ module RSpec::Rails
# require the presence of the file at all. Due to changes in rails-3, this
# was no longer feasible in rspec-rails-2.
#
# == View rendering
# ## View rendering
#
# If you prefer a more integrated approach, similar to that of Rails'
# functional tests, you can tell controller groups to render the views in the
Expand All @@ -88,6 +93,7 @@ module ControllerExampleGroup
include RSpec::Rails::Matchers::RoutingMatchers

module ClassMethods
# @api private
def controller_class
describes
end
Expand All @@ -98,7 +104,7 @@ def controller_class
# up implicit routes for this controller, that are separate from those
# defined in <tt>config/routes.rb</tt>.
#
# == Examples
# ## Examples
#
# describe ApplicationController do
# controller do
Expand Down Expand Up @@ -158,10 +164,16 @@ def rescue_with_handler(exception)
end
end

# Extends the controller with a module that overrides
# `rescue_with_handler` to raise the exception passed to it. Use this to
# specify that an action _should_ raise an exception given appropriate
# conditions.
def bypass_rescue
controller.extend(BypassRescue)
end

# If method is a named_route, delegates to the RouteSet associated with
# this controller.
def method_missing(method, *args, &block)
if @orig_routes && @orig_routes.named_routes.helpers.include?(method)
controller.send(method, *args, &block)
Expand Down

0 comments on commit 130c94f

Please sign in to comment.