Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 58f3821

Browse files
peaghaJonRowe
authored andcommitted
Use RSpec module on describe calls in docs. (#2571)
1 parent 4f8abda commit 58f3821

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

features/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
rspec-core provides the structure for RSpec code examples:
22

3-
describe Account do
3+
RSpec.describe Account do
44
it "has a balance of zero when first opened" do
55
# example code goes here - for more on the
66
# code inside the examples, see rspec-expectations

lib/rspec/core/configuration.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1106,15 +1106,15 @@ def spec_files_with_failures
11061106
#
11071107
# # This lets you do this:
11081108
#
1109-
# describe Thing do
1109+
# RSpec.describe Thing do
11101110
# pending "does something" do
11111111
# thing = Thing.new
11121112
# end
11131113
# end
11141114
#
11151115
# # ... which is the equivalent of
11161116
#
1117-
# describe Thing do
1117+
# RSpec.describe Thing do
11181118
# it "does something", :pending => true do
11191119
# thing = Thing.new
11201120
# end
@@ -1167,7 +1167,7 @@ def alias_example_group_to(new_name, *args)
11671167
#
11681168
# # allows the user to include a shared example group like:
11691169
#
1170-
# describe Entity do
1170+
# RSpec.describe Entity do
11711171
# it_has_behavior 'sortability' do
11721172
# let(:sortable) { Entity.new }
11731173
# end
@@ -1718,7 +1718,7 @@ def raise_on_warning=(value)
17181718
# rspec.expose_current_running_example_as :example
17191719
# end
17201720
#
1721-
# describe MyClass do
1721+
# RSpec.describe MyClass do
17221722
# before do
17231723
# # `example` can be used here because of the above config.
17241724
# do_something if example.metadata[:type] == "foo"

lib/rspec/core/example_group.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Core
77
# ExampleGroup and {Example} are the main structural elements of
88
# rspec-core. Consider this example:
99
#
10-
# describe Thing do
10+
# RSpec.describe Thing do
1111
# it "does something" do
1212
# end
1313
# end
@@ -90,7 +90,7 @@ def self.description
9090
# Returns the class or module passed to the `describe` method (or alias).
9191
# Returns nil if the subject is not a class or module.
9292
# @example
93-
# describe Thing do
93+
# RSpec.describe Thing do
9494
# it "does something" do
9595
# described_class == Thing
9696
# end

lib/rspec/core/hooks.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ module Hooks
7474
# end
7575
# end
7676
#
77-
# describe Something, :authorized => true do
77+
# RSpec.describe Something, :authorized => true do
7878
# # The before hook will run in before each example in this group.
7979
# end
8080
#
81-
# describe SomethingElse do
81+
# RSpec.describe SomethingElse do
8282
# it "does something", :authorized => true do
8383
# # The before hook will run before this example.
8484
# end
@@ -159,7 +159,7 @@ module Hooks
159159
#
160160
# @example before(:example) declared in an {ExampleGroup}
161161
#
162-
# describe Thing do
162+
# RSpec.describe Thing do
163163
# before(:example) do
164164
# @thing = Thing.new
165165
# end
@@ -171,7 +171,7 @@ module Hooks
171171
#
172172
# @example before(:context) declared in an {ExampleGroup}
173173
#
174-
# describe Parser do
174+
# RSpec.describe Parser do
175175
# before(:context) do
176176
# File.open(file_to_parse, 'w') do |f|
177177
# f.write <<-CONTENT

lib/rspec/core/memoized_helpers.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module MemoizedHelpers
1010
# @note `subject` was contributed by Joe Ferris to support the one-liner
1111
# syntax embraced by shoulda matchers:
1212
#
13-
# describe Widget do
13+
# RSpec.describe Widget do
1414
# it { is_expected.to validate_presence_of(:name) }
1515
# # or
1616
# it { should validate_presence_of(:name) }
@@ -23,7 +23,7 @@ module MemoizedHelpers
2323
# @example
2424
#
2525
# # Explicit declaration of subject.
26-
# describe Person do
26+
# RSpec.describe Person do
2727
# subject { Person.new(:birthdate => 19.years.ago) }
2828
# it "should be eligible to vote" do
2929
# subject.should be_eligible_to_vote
@@ -32,15 +32,15 @@ module MemoizedHelpers
3232
# end
3333
#
3434
# # Implicit subject => { Person.new }.
35-
# describe Person do
35+
# RSpec.describe Person do
3636
# it "should be eligible to vote" do
3737
# subject.should be_eligible_to_vote
3838
# # ^ ^ explicit reference to subject not recommended
3939
# end
4040
# end
4141
#
4242
# # One-liner syntax - expectation is set on the subject.
43-
# describe Person do
43+
# RSpec.describe Person do
4444
# it { is_expected.to be_eligible_to_vote }
4545
# # or
4646
# it { should be_eligible_to_vote }
@@ -67,7 +67,7 @@ def subject
6767
#
6868
# @example
6969
#
70-
# describe Person do
70+
# RSpec.describe Person do
7171
# it { should be_eligible_to_vote }
7272
# end
7373
#
@@ -86,7 +86,7 @@ def should(matcher=nil, message=nil)
8686
#
8787
# @example
8888
#
89-
# describe Person do
89+
# RSpec.describe Person do
9090
# it { should_not be_eligible_to_vote }
9191
# end
9292
#
@@ -270,7 +270,7 @@ module ClassMethods
270270
#
271271
# @example
272272
#
273-
# describe Thing do
273+
# RSpec.describe Thing do
274274
# let(:thing) { Thing.new }
275275
#
276276
# it "does something" do
@@ -323,7 +323,7 @@ def let(name, &block)
323323
# end
324324
# end
325325
#
326-
# describe Thing do
326+
# RSpec.describe Thing do
327327
# after(:example) { Thing.reset_count }
328328
#
329329
# context "using let" do
@@ -379,13 +379,13 @@ def let!(name, &block)
379379
#
380380
# @example
381381
#
382-
# describe CheckingAccount, "with $50" do
382+
# RSpec.describe CheckingAccount, "with $50" do
383383
# subject { CheckingAccount.new(Money.new(50, :USD)) }
384384
# it { is_expected.to have_a_balance_of(Money.new(50, :USD)) }
385385
# it { is_expected.not_to be_overdrawn }
386386
# end
387387
#
388-
# describe CheckingAccount, "with a non-zero starting balance" do
388+
# RSpec.describe CheckingAccount, "with a non-zero starting balance" do
389389
# subject(:account) { CheckingAccount.new(Money.new(50, :USD)) }
390390
# it { is_expected.not_to be_overdrawn }
391391
# it "has a balance equal to the starting balance" do
@@ -433,7 +433,7 @@ def subject(name=nil, &block)
433433
# end
434434
# end
435435
#
436-
# describe Thing do
436+
# RSpec.describe Thing do
437437
# after(:example) { Thing.reset_count }
438438
#
439439
# context "using subject" do

lib/rspec/core/metadata.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Core
77
# In addition to metadata that is used internally, this also stores
88
# user-supplied metadata, e.g.
99
#
10-
# describe Something, :type => :ui do
10+
# RSpec.describe Something, :type => :ui do
1111
# it "does something", :slow => true do
1212
# # ...
1313
# end

lib/rspec/core/shared_example_group.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module SharedExampleGroup
7676
# end
7777
# end
7878
#
79-
# describe Account do
79+
# RSpec.describe Account do
8080
# it_behaves_like "auditable" do
8181
# let(:auditable) { Account.new }
8282
# end

0 commit comments

Comments
 (0)