Skip to content

Commit ceb7232

Browse files
committed
Doc coverage.
* Many things are private. * Added docs tend to be terrible, I don't have enough context to flesh them out. * Still some warnings in here I don't know what to do about. * What do we do about CI? Can rspec-dev add it for us?
1 parent 8e6554c commit ceb7232

33 files changed

+134
-95
lines changed

lib/generators/rspec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
require 'rails/generators/named_base'
22

3+
# Weirdly named generators namespace (should be `RSpec`) for compatability with
4+
# rails loading.
35
module Rspec
6+
# @private
47
module Generators
8+
# @private
59
class Base < ::Rails::Generators::NamedBase
610
def self.source_root
711
@_rspec_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'rspec', generator_name, 'templates'))
@@ -16,8 +20,10 @@ def module_namespacing
1620
end
1721
end
1822

23+
# @private
1924
module Rails
2025
module Generators
26+
# @private
2127
class GeneratedAttribute
2228
def input_type
2329
@input_type ||= if type == :text

lib/generators/rspec/controller/controller_generator.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module Rspec
44
module Generators
5+
# @private
56
class ControllerGenerator < Base
67
argument :actions, :type => :array, :default => [], :banner => "action action"
78

lib/generators/rspec/feature/feature_generator.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module Rspec
44
module Generators
5+
# @private
56
class FeatureGenerator < Base
67
class_option :feature_specs, :type => :boolean, :default => true, :desc => "Generate feature specs"
78

lib/generators/rspec/helper/helper_generator.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module Rspec
44
module Generators
5+
# @private
56
class HelperGenerator < Base
67
class_option :helper_specs, :type => :boolean, :default => true
78

lib/generators/rspec/install/install_generator.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Rspec
22
module Generators
3+
# @private
34
class InstallGenerator < ::Rails::Generators::Base
45

56
desc <<DESC

lib/generators/rspec/integration/integration_generator.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module Rspec
44
module Generators
5+
# @private
56
class IntegrationGenerator < Base
67
class_option :request_specs, :type => :boolean, :default => true, :desc => "Generate request specs"
78

lib/generators/rspec/mailer/mailer_generator.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module Rspec
44
module Generators
5+
# @private
56
class MailerGenerator < Base
67
argument :actions, :type => :array, :default => [], :banner => "method method"
78

lib/generators/rspec/model/model_generator.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module Rspec
44
module Generators
5+
# @private
56
class ModelGenerator < Base
67
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
78
class_option :fixture, :type => :boolean

lib/generators/rspec/observer/observer_generator.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module Rspec
44
module Generators
5+
# @private
56
class ObserverGenerator < Base
67
def generate_observer_spec
78
template 'observer_spec.rb',

lib/generators/rspec/scaffold/scaffold_generator.rb

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
module Rspec
55
module Generators
6+
# @private
67
class ScaffoldGenerator < Base
78
include ::Rails::Generators::ResourceHelpers
89
source_paths << File.expand_path("../../helper/templates", __FILE__)

lib/generators/rspec/view/view_generator.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module Rspec
44
module Generators
5+
# @private
56
class ViewGenerator < Base
67
argument :actions, :type => :array, :default => [], :banner => "action action"
78

lib/rspec-rails.rb

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# Namespace for all core RSpec projects.
12
module RSpec
3+
# Namespace for rspec-rails code.
24
module Rails
5+
# Railtie to hook into Rails.
36
class Railtie < ::Rails::Railtie
47
# Rails-3.0.1 requires config.app_generators instead of 3.0.0's config.generators
58
generators = config.respond_to?(:app_generators) ? config.app_generators : config.generators

lib/rspec/rails/adapters.rb

+10-18
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ module Rails
77
if ::Rails::VERSION::STRING >= '4.1.0'
88
gem 'minitest'
99
require 'minitest/assertions'
10+
# Constant aliased to either Minitest or TestUnit, depending on what is
11+
# loaded.
1012
Assertions = Minitest::Assertions
1113
else
1214
begin
@@ -16,12 +18,13 @@ module Rails
1618
require 'rubysl-test-unit' if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
1719
require 'test/unit/assertions'
1820
end
21+
# Constant aliased to either Minitest or TestUnit, depending on what is
22+
# loaded.
1923
Assertions = Test::Unit::Assertions
2024
end
2125

22-
# @api private
26+
# @private
2327
class AssertionDelegator < Module
24-
# @api private
2528
def initialize(*assertion_modules)
2629
assertion_class = Class.new(SimpleDelegator) do
2730
include ::RSpec::Rails::Assertions
@@ -30,12 +33,10 @@ def initialize(*assertion_modules)
3033
end
3134

3235
super() do
33-
# @api private
3436
define_method :build_assertion_instance do
3537
assertion_class.new(self)
3638
end
3739

38-
# @api private
3940
def assertion_instance
4041
@assertion_instance ||= build_assertion_instance
4142
end
@@ -54,7 +55,7 @@ def assertion_instance
5455

5556
# Adapts example groups for `Minitest::Test::LifecycleHooks`
5657
#
57-
# @api private
58+
# @private
5859
module MinitestLifecycleAdapter
5960
extend ActiveSupport::Concern
6061

@@ -82,26 +83,22 @@ def after_teardown
8283
end
8384
end
8485

85-
# @api private
86+
# @private
8687
module MinitestCounters
87-
# @api private
8888
def assertions
8989
@assertions ||= 0
9090
end
9191

92-
# @api private
9392
def assertions=(assertions)
9493
@assertions = assertions
9594
end
9695
end
9796

98-
# @api private
97+
# @private
9998
module SetupAndTeardownAdapter
10099
extend ActiveSupport::Concern
101100

102101
module ClassMethods
103-
# @api private
104-
#
105102
# Wraps `setup` calls from within Rails' testing framework in `before`
106103
# hooks.
107104
def setup(*methods)
@@ -123,7 +120,6 @@ def teardown(*methods)
123120
end
124121
end
125122

126-
# @api private
127123
def method_name
128124
@example
129125
end
@@ -133,9 +129,8 @@ def method_name
133129
module MinitestAssertionAdapter
134130
extend ActiveSupport::Concern
135131

132+
# @private
136133
module ClassMethods
137-
# @api private
138-
#
139134
# Returns the names of assertion methods that we want to expose to
140135
# examples without exposing non-assertion methods in Test::Unit or
141136
# Minitest.
@@ -144,7 +139,6 @@ def assertion_method_names
144139
[:build_message]
145140
end
146141

147-
# @api private
148142
def define_assertion_delegators
149143
assertion_method_names.each do |m|
150144
define_method(m.to_sym) do |*args, &block|
@@ -154,13 +148,11 @@ def define_assertion_delegators
154148
end
155149
end
156150

157-
# @api private
158151
class AssertionDelegator
159152
include ::RSpec::Rails::Assertions
160153
include ::RSpec::Rails::MinitestCounters
161154
end
162155

163-
# @api private
164156
def assertion_delegator
165157
@assertion_delegator ||= AssertionDelegator.new
166158
end
@@ -173,7 +165,7 @@ def assertion_delegator
173165
# Backwards compatibility. It's unlikely that anyone is using this
174166
# constant, but we had forgotten to mark it as `@private` earlier
175167
#
176-
# @api private
168+
# @private
177169
TestUnitAssertionAdapter = MinitestAssertionAdapter
178170
end
179171
end

lib/rspec/rails/configuration.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def self.initialize_configuration(config)
1313
config.include RSpec::Rails::ViewExampleGroup, :type => :view
1414
config.include RSpec::Rails::FeatureExampleGroup, :type => :feature
1515

16-
if defined?(RSpec::Rails::MailerExampleGroup)
16+
if defined?(ActionMailer)
1717
config.include RSpec::Rails::MailerExampleGroup, :type => :mailer
1818
end
1919

@@ -36,18 +36,26 @@ def self.initialize_configuration(config)
3636
# but requires this workaround:
3737
config.add_setting :rendering_views, :default => false
3838

39+
# @private
40+
# TODO: How to YARD this? Not actually private.
3941
def config.render_views=(val)
4042
self.rendering_views = val
4143
end
4244

45+
# @private
46+
# TODO: How to YARD this? Not actually private.
4347
def config.render_views
4448
self.rendering_views = true
4549
end
4650

51+
# @private
52+
# TODO: How to YARD this? Not actually private.
4753
def config.render_views?
4854
rendering_views
4955
end
5056

57+
# @private
58+
# TODO: How to YARD this? Not actually private.
5159
def config.infer_spec_type_from_file_location!
5260
{
5361
:controller => %w[spec controllers],

lib/rspec/rails/example/controller_example_group.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module RSpec::Rails
2+
# Container module for controller spec functionality.
23
module ControllerExampleGroup
34
extend ActiveSupport::Concern
45
include RSpec::Rails::RailsExampleGroup
@@ -9,6 +10,7 @@ module ControllerExampleGroup
910
include RSpec::Rails::Matchers::RoutingMatchers
1011
include RSpec::Rails::AssertionDelegator.new(ActionDispatch::Assertions::RoutingAssertions)
1112

13+
# Class-level DSL for controller specs.
1214
module ClassMethods
1315
# @private
1416
def controller_class
@@ -28,7 +30,6 @@ def controller_class
2830
# within the block.
2931
#
3032
# @example
31-
#
3233
# describe ApplicationController do
3334
# controller do
3435
# def index
@@ -97,7 +98,6 @@ def self.name
9798
# is most useful when testing Rails engines.
9899
#
99100
# @example
100-
#
101101
# describe MyEngine::PostsController do
102102
# routes { MyEngine::Engine.routes }
103103
#
@@ -112,12 +112,13 @@ def routes(&blk)
112112

113113
attr_reader :controller, :routes
114114

115-
# @api private
115+
# @private
116116
def routes=(routes)
117117
@routes = routes
118118
assertion_instance.instance_variable_set(:@routes, routes)
119119
end
120120

121+
# @private
121122
module BypassRescue
122123
def rescue_with_handler(exception)
123124
raise exception
@@ -130,7 +131,6 @@ def rescue_with_handler(exception)
130131
# conditions.
131132
#
132133
# @example
133-
#
134134
# describe ProfilesController do
135135
# it "raises a 403 when a non-admin user tries to view another user's profile" do
136136
# profile = create_profile

lib/rspec/rails/example/feature_example_group.rb

+5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
module RSpec::Rails
2+
# Container module for routing spec functionality.
23
module FeatureExampleGroup
34
extend ActiveSupport::Concern
45
include RSpec::Rails::RailsExampleGroup
56

7+
# Default host to be used in Rails route helpers if none is specified.
68
DEFAULT_HOST = "www.example.com"
79

810
included do
@@ -17,6 +19,9 @@ module FeatureExampleGroup
1719
end
1820
end
1921

22+
# Shim to check for presence of Capybara. Will delegate if present, raise
23+
# if not. We assume here that in most cases `visit` will be the first
24+
# Capybara method called in a spec.
2025
def visit(*)
2126
if defined?(super)
2227
super

lib/rspec/rails/example/helper_example_group.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
require 'rspec/rails/view_assigns'
22

33
module RSpec::Rails
4+
# Container module for helper specs.
45
module HelperExampleGroup
56
extend ActiveSupport::Concern
67
include RSpec::Rails::RailsExampleGroup
78
include ActionView::TestCase::Behavior
89
include RSpec::Rails::ViewAssigns
910

11+
# @private
1012
module ClassMethods
11-
# @api private
1213
def determine_default_helper_class(ignore)
1314
described_class
1415
end

0 commit comments

Comments
 (0)