Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixup formatting of @example YARD comments.
- No blank line after `@example`; YARD renders that
  as a blank line of code.
- Standardize on 2 spaces.
  • Loading branch information
myronmarston committed Feb 23, 2015
1 parent 8d071d5 commit 62236cd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 54 deletions.
11 changes: 1 addition & 10 deletions lib/rspec/mocks/argument_matchers.rb
Expand Up @@ -17,7 +17,6 @@ module ArgumentMatchers
# Acts like an arg splat, matching any number of args at any point in an arg list.
#
# @example
#
# expect(object).to receive(:message).with(1, 2, any_args)
#
# # matches any of these:
Expand All @@ -31,7 +30,6 @@ def any_args
# Matches any argument at all.
#
# @example
#
# expect(object).to receive(:message).with(anything)
def anything
AnyArgMatcher::INSTANCE
Expand All @@ -40,7 +38,6 @@ def anything
# Matches no arguments.
#
# @example
#
# expect(object).to receive(:message).with(no_args)
def no_args
NoArgsMatcher::INSTANCE
Expand All @@ -49,7 +46,6 @@ def no_args
# Matches if the actual argument responds to the specified messages.
#
# @example
#
# expect(object).to receive(:message).with(duck_type(:hello))
# expect(object).to receive(:message).with(duck_type(:hello, :goodbye))
def duck_type(*args)
Expand All @@ -59,7 +55,6 @@ def duck_type(*args)
# Matches a boolean value.
#
# @example
#
# expect(object).to receive(:message).with(boolean())
def boolean
BooleanMatcher::INSTANCE
Expand All @@ -69,7 +64,6 @@ def boolean
# Ignores any additional keys.
#
# @example
#
# expect(object).to receive(:message).with(hash_including(:key => val))
# expect(object).to receive(:message).with(hash_including(:key))
# expect(object).to receive(:message).with(hash_including(:key, :key2 => val2))
Expand All @@ -81,7 +75,6 @@ def hash_including(*args)
# Ignores duplicates and additional values
#
# @example
#
# expect(object).to receive(:message).with(array_including(1,2,3))
# expect(object).to receive(:message).with(array_including([1,2,3]))
def array_including(*args)
Expand All @@ -92,7 +85,6 @@ def array_including(*args)
# Matches a hash that doesn't include the specified key(s) or key/value.
#
# @example
#
# expect(object).to receive(:message).with(hash_excluding(:key => val))
# expect(object).to receive(:message).with(hash_excluding(:key))
# expect(object).to receive(:message).with(hash_excluding(:key, :key2 => :val2))
Expand All @@ -105,7 +97,6 @@ def hash_excluding(*args)
# Matches if `arg.instance_of?(klass)`
#
# @example
#
# expect(object).to receive(:message).with(instance_of(Thing))
def instance_of(klass)
InstanceOf.new(klass)
Expand All @@ -114,8 +105,8 @@ def instance_of(klass)
alias_method :an_instance_of, :instance_of

# Matches if `arg.kind_of?(klass)`
# @example
#
# @example
# expect(object).to receive(:message).with(kind_of(Thing))
def kind_of(klass)
KindOf.new(klass)
Expand Down
5 changes: 0 additions & 5 deletions lib/rspec/mocks/configuration.rb
Expand Up @@ -19,7 +19,6 @@ def yield_receiver_to_any_instance_implementation_blocks?
# Defaults to `true`.
#
# @example
#
# RSpec.configure do |rspec|
# rspec.mock_with :rspec do |mocks|
# mocks.yield_receiver_to_any_instance_implementation_blocks = false
Expand All @@ -35,7 +34,6 @@ def yield_receiver_to_any_instance_implementation_blocks?
# the process.
#
# @example
#
# RSpec.configure do |rspec|
# rspec.mock_with :rspec do |mocks|
# mocks.add_stub_and_should_receive_to Delegator
Expand All @@ -55,7 +53,6 @@ def add_stub_and_should_receive_to(*modules)
# disable `expect` syntax.
#
# @example
#
# RSpec.configure do |rspec|
# rspec.mock_with :rspec do |mocks|
# mocks.syntax = [:expect, :should]
Expand All @@ -81,7 +78,6 @@ def syntax=(*values)
# that are enabled.
#
# @example
#
# unless RSpec::Mocks.configuration.syntax.include?(:expect)
# raise "this RSpec extension gem requires the rspec-mocks `:expect` syntax"
# end
Expand All @@ -107,7 +103,6 @@ def verify_doubled_constant_names?
# Provides a way to perform customisations when verifying doubles.
#
# @example
#
# RSpec::Mocks.configuration.when_declaring_verifying_double do |ref|
# ref.some_method!
# end
Expand Down
25 changes: 7 additions & 18 deletions lib/rspec/mocks/example_methods.rb
Expand Up @@ -24,7 +24,6 @@ module ExampleMethods
# hash of message/return-value pairs.
#
# @example
#
# book = double("book", :title => "The RSpec Book")
# book.title #=> "The RSpec Book"
#
Expand Down Expand Up @@ -219,7 +218,6 @@ def allow_message_expectations_on_nil
# @return [Object] the stubbed value of the constant
#
# @example
#
# stub_const("MyClass", Class.new) # => Replaces (or defines) MyClass with a new class object.
# stub_const("SomeModel::PER_PAGE", 5) # => Sets SomeModel::PER_PAGE to 5.
#
Expand Down Expand Up @@ -253,7 +251,6 @@ def stub_const(constant_name, value, options={})
# The current constant scoping at the point of call is not considered.
#
# @example
#
# hide_const("MyClass") # => MyClass is now an undefined constant
def hide_const(constant_name)
ConstantMutator.hide(constant_name)
Expand All @@ -271,7 +268,6 @@ def hide_const(constant_name)
# called.
#
# @example
#
# invitation = double('invitation', accept: true)
# user.accept_invitation(invitation)
# expect(invitation).to have_received(:accept)
Expand All @@ -290,7 +286,6 @@ def have_received(method_name, &block)
# on it.
#
# @example
#
# expect(obj).to receive(:foo).with(5).and_return(:return_value)
#
# @note This method is usually provided by rspec-expectations. However,
Expand All @@ -303,7 +298,6 @@ def have_received(method_name, &block)
# on it.
#
# @example
#
# allow(dbl).to receive(:foo).with(5).and_return(:return_value)
#
# @note If you disable the `:expect` syntax this method will be undefined.
Expand All @@ -313,7 +307,6 @@ def have_received(method_name, &block)
# on instances of it.
#
# @example
#
# expect_any_instance_of(MyClass).to receive(:foo)
#
# @note If you disable the `:expect` syntax this method will be undefined.
Expand All @@ -323,7 +316,6 @@ def have_received(method_name, &block)
# on instances of it.
#
# @example
#
# allow_any_instance_of(MyClass).to receive(:foo)
#
# @note This is only available when you have enabled the `expect` syntax.
Expand All @@ -336,7 +328,6 @@ def have_received(method_name, &block)
# times, and configure how the object should respond to the message.
#
# @example
#
# expect(obj).to receive(:hello).with("world").exactly(3).times
#
# @note If you disable the `:expect` syntax this method will be undefined.
Expand All @@ -349,7 +340,6 @@ def have_received(method_name, &block)
# interface.
#
# @example
#
# allow(obj).to receive_messages(:speak => "Hello World")
# allow(obj).to receive_messages(:speak => "Hello", :meow => "Meow")
#
Expand All @@ -373,16 +363,15 @@ def have_received(method_name, &block)
# implementation calls `foo.baz.bar`, the stub will not work.
#
# @example
# allow(double).to receive_message_chain("foo.bar") { :baz }
# allow(double).to receive_message_chain(:foo, :bar => :baz)
# allow(double).to receive_message_chain(:foo, :bar) { :baz }
#
# allow(double).to receive_message_chain("foo.bar") { :baz }
# allow(double).to receive_message_chain(:foo, :bar => :baz)
# allow(double).to receive_message_chain(:foo, :bar) { :baz }
#
# # Given any of ^^ these three forms ^^:
# double.foo.bar # => :baz
# # Given any of ^^ these three forms ^^:
# double.foo.bar # => :baz
#
# # Common use in Rails/ActiveRecord:
# allow(Article).to receive_message_chain("recent.published") { [Article.new] }
# # Common use in Rails/ActiveRecord:
# allow(Article).to receive_message_chain("recent.published") { [Article.new] }
#
# @note If you disable the `:expect` syntax this method will be undefined.

Expand Down
38 changes: 17 additions & 21 deletions lib/rspec/mocks/syntax.rb
Expand Up @@ -214,11 +214,10 @@ class BasicObject
# the end of the example.
#
# @example
#
# logger = double('logger')
# thing_that_logs = ThingThatLogs.new(logger)
# logger.should_receive(:log)
# thing_that_logs.do_something_that_logs_a_message
# logger = double('logger')
# thing_that_logs = ThingThatLogs.new(logger)
# logger.should_receive(:log)
# thing_that_logs.do_something_that_logs_a_message
#
# @note This is only available when you have enabled the `should` syntax.
# @see RSpec::Mocks::ExampleMethods#expect
Expand All @@ -232,10 +231,9 @@ class BasicObject
# Tells the object to respond to the message with the specified value.
#
# @example
#
# counter.stub(:count).and_return(37)
# counter.stub(:count => 37)
# counter.stub(:count) { 37 }
# counter.stub(:count).and_return(37)
# counter.stub(:count => 37)
# counter.stub(:count) { 37 }
#
# @note This is only available when you have enabled the `should` syntax.
# @see RSpec::Mocks::ExampleMethods#allow
Expand Down Expand Up @@ -269,10 +267,9 @@ class BasicObject
# implementation calls `foo.baz.bar`, the stub will not work.
#
# @example
#
# double.stub_chain("foo.bar") { :baz }
# double.stub_chain(:foo, :bar => :baz)
# double.stub_chain(:foo, :bar) { :baz }
# double.stub_chain("foo.bar") { :baz }
# double.stub_chain(:foo, :bar => :baz)
# double.stub_chain(:foo, :bar) { :baz }
#
# # Given any of ^^ these three forms ^^:
# double.foo.bar # => :baz
Expand Down Expand Up @@ -311,15 +308,14 @@ class Class
# class.
#
# @example
# Car.any_instance.should_receive(:go)
# race = Race.new
# race.cars << Car.new
# race.go # assuming this delegates to all of its cars
# # this example would pass
#
# Car.any_instance.should_receive(:go)
# race = Race.new
# race.cars << Car.new
# race.go # assuming this delegates to all of its cars
# # this example would pass
#
# Account.any_instance.stub(:balance) { Money.new(:USD, 25) }
# Account.new.balance # => Money.new(:USD, 25))
# Account.any_instance.stub(:balance) { Money.new(:USD, 25) }
# Account.new.balance # => Money.new(:USD, 25))
#
# @return [Recorder]
#
Expand Down

0 comments on commit 62236cd

Please sign in to comment.