Skip to content

Commit

Permalink
more rdoc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Dec 8, 2011
1 parent 80febb5 commit c1f0eab
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 68 deletions.
1 change: 1 addition & 0 deletions .yardopts
Expand Up @@ -2,6 +2,7 @@
--exclude features
--exclude lib/generators/**/*_spec.rb
--markup markdown
--template-path yard/template/
-
README.md
Changelog.md
Expand Down
15 changes: 0 additions & 15 deletions README.md
Expand Up @@ -58,21 +58,6 @@ gem "webrat"
gem "capybara"
```

### Autotest

The `rspec:install` generator creates an `.rspec` file, which tells Autotest
that you're using RSpec and Rails. You'll also need to add the ZenTest gem to
your Gemfile:

```ruby
gem "ZenTest"
```

At this point, if all of the gems in your Gemfile are installed in system
gems, you can just type `autotest`. If, however, Bundler is managing any gems
for you directly (i.e. you've got `:git` or `:path` attributes in the `Gemfile`),
you'll need to run `bundle exec autotest`.

## Living on edge

Bundler makes it a snap to use the latest code for any gem your app depends on. For
Expand Down
43 changes: 21 additions & 22 deletions lib/rspec/rails/example/controller_example_group.rb
Expand Up @@ -18,28 +18,27 @@ def controller_class
described_class
end

# Supports a simple DSL for specifying behaviour of
# ApplicationController. Creates an anonymous subclass of
# ApplicationController and evals the +body+ in that context. Also sets
# up implicit routes for this controller, that are separate from those
# defined in <tt>config/routes.rb</tt>.
# Supports a simple DSL for specifying behavior of ApplicationController.
# Creates an anonymous subclass of ApplicationController and evals the
# `body` in that context. Also sets up implicit routes for this
# controller, that are separate from those defined in "config/routes.rb".
#
# ## Examples
# @example
#
# describe ApplicationController do
# controller do
# def index
# raise ApplicationController::AccessDenied
# end
# end
# describe ApplicationController do
# controller do
# def index
# raise ApplicationController::AccessDenied
# end
# end
#
# describe "handling AccessDenied exceptions" do
# it "redirects to the /401.html page" do
# get :index
# response.should redirect_to("/401.html")
# end
# end
# end
# describe "handling AccessDenied exceptions" do
# it "redirects to the /401.html page" do
# get :index
# response.should redirect_to("/401.html")
# end
# end
# end
#
# If you would like to spec a subclass of ApplicationController, call
# controller like so:
Expand All @@ -49,10 +48,10 @@ def controller_class
# end
#
# NOTICE: Due to Ruby 1.8 scoping rules in anoymous subclasses, constants
# defined in +ApplicationController+ must be fully qualified (e.g.
# 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
# `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)
base_class ||= RSpec.configuration.infer_base_class_for_anonymous_controllers? ?
Expand Down
36 changes: 18 additions & 18 deletions lib/rspec/rails/example/view_example_group.rb
Expand Up @@ -35,27 +35,27 @@ module InstanceMethods
# The only addition is that you can call render with no arguments, and RSpec
# will pass the top level description to render:
#
# describe "widgets/new.html.erb" do
# it "shows all the widgets" do
# render # => view.render(:file => "widgets/new.html.erb")
# ...
# describe "widgets/new.html.erb" do
# it "shows all the widgets" do
# render # => view.render(:file => "widgets/new.html.erb")
# # ...
# end
# end
# end
def render(options={}, local_assigns={}, &block)
options = {:template => _default_file_to_render} if Hash === options and options.empty?
super(options, local_assigns, &block)
end

# The instance of +ActionView::Base+ that is used to render the template.
# Use this to stub methods _before_ calling +render+.
# The instance of `ActionView::Base` that is used to render the template.
# Use this to stub methods _before_ calling `render`.
#
# describe "widgets/new.html.erb" do
# it "shows all the widgets" do
# view.stub(:foo) { "foo" }
# render
# ...
# describe "widgets/new.html.erb" do
# it "shows all the widgets" do
# view.stub(:foo) { "foo" }
# render
# # ...
# end
# end
# end
def view
_view
end
Expand All @@ -65,28 +65,28 @@ def view
# help isolate view examples from partials rendered by the view template
# that is the subject of the example.
#
# ## Example
# @example
#
# stub_template("widgets/_widget.html.erb" => "This content.")
# stub_template("widgets/_widget.html.erb" => "This content.")
def stub_template(hash)
view.view_paths.unshift(ActionView::FixtureResolver.new(hash))
end

# Provides access to the params hash that will be available within the
# view:
#
# params[:foo] = 'bar'
# params[:foo] = 'bar'
def params
controller.params
end

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

# @deprecated # use +rendered+ instead.
# @deprecated # use `rendered` instead.
def response
RSpec.deprecate("response", "rendered")
rendered
Expand Down
6 changes: 3 additions & 3 deletions lib/rspec/rails/extensions/active_record/base.rb
Expand Up @@ -3,9 +3,9 @@ module Rails
if defined?(ActiveRecord)
module Extensions
module ActiveRecord
# Extension to enhance +should have+ on AR Model classes
# Extension to enhance `should have` on AR Model classes
#
# ## Examples:
# @example
#
# ModelClass.should have(:no).records
# ModelClass.should have(1).record
Expand All @@ -30,7 +30,7 @@ module ::ActiveModel::Validations
#
# You can also use this to specify the content of the error messages.
#
# ## Examples:
# @example
#
# model.should have(:no).errors_on(:attribute)
# model.should have(1).error_on(:attribute)
Expand Down
4 changes: 2 additions & 2 deletions lib/rspec/rails/matchers/be_a_new.rb
Expand Up @@ -10,7 +10,7 @@ def matches?(actual)

# Use this to specify the specific attributes to match on the new record.
#
# ## Examples:
# @example
#
# it "assigns a new Thing with the submitted attributes" do
# post :create, :thing => { :name => "Illegal Value" }
Expand Down Expand Up @@ -60,7 +60,7 @@ def unmatched_attributes
# `persisted?`. Typically used to specify instance variables assigned to
# views by controller actions
#
# ## Examples:
# @example
#
# get :new
# assigns(:thing).should be_a_new(Thing)
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/rails/matchers/be_new_record.rb
Expand Up @@ -10,7 +10,7 @@ def matches?(actual)

# Passes if actual returns `false` for `persisted?`.
#
# ## Examples:
# @example
#
# get :new
# assigns(:thing).should be_new_record
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/rails/matchers/redirect_to.rb
Expand Up @@ -28,7 +28,7 @@ def failure_message_for_should_not

# Delegates to `assert_redirected_to`
#
# ## Examples:
# @example
#
# response.should redirect_to(:action => "new")
def redirect_to(target)
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/rails/matchers/render_template.rb
Expand Up @@ -29,7 +29,7 @@ def failure_message_for_should_not

# Delegates to `assert_template`
#
# ## Examples:
# @example
#
# response.should render_template("new")
def render_template(options, message=nil)
Expand Down
4 changes: 2 additions & 2 deletions lib/rspec/rails/matchers/routing_matchers.rb
Expand Up @@ -37,7 +37,7 @@ def failure_message_for_should
# Delegates to `assert_recognizes`. Supports short-hand controller/action
# declarations (e.g. `"controller#action"`).
#
# ## Examples
# @example
#
# { :get => "/things/special" }.should route_to(
# :controller => "things",
Expand Down Expand Up @@ -78,7 +78,7 @@ def failure_message_for_should_not
# the declarations in `config/routes.rb`. Delegates to
# `RouteSet#recognize_path`.
#
# ## Examples:
# @example
#
# You can use route helpers provided by rspec-rails.
# {:get => "/a/path"}.should be_routable
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/rails/mocks.rb
Expand Up @@ -200,7 +200,7 @@ def connection
# helper), it is especially useful in view examples, which are
# inherently more state-based than interaction-based.
#
# ## Examples
# @example
#
# stub_model(Person)
# stub_model(Person).as_new_record
Expand Down
4 changes: 2 additions & 2 deletions lib/rspec/rails/view_assigns.rb
Expand Up @@ -7,9 +7,9 @@ module InstanceMethods
# Assigns a value to an instance variable in the scope of the
# view being rendered.
#
# ## Examples
# @example
#
# assign(:widget, stub_model(Widget))
# assign(:widget, stub_model(Widget))
def assign(key, value)
_encapsulated_assigns[key] = value
end
Expand Down
4 changes: 4 additions & 0 deletions yard/template/default/fulldoc/html/css/rspec.css
@@ -0,0 +1,4 @@
code {
background-color: #F0F0F0;
padding: 0 2px 0 2px;
}
6 changes: 6 additions & 0 deletions yard/template/default/layout/html/setup.rb
@@ -0,0 +1,6 @@
# Docs suggest I don't need this, but ...
YARD::Server::Commands::StaticFileCommand::STATIC_PATHS << File.expand_path("../../../fulldoc/html/", __FILE__)

def stylesheets
super + ['css/rspec.css']
end

0 comments on commit c1f0eab

Please sign in to comment.