Skip to content

Commit

Permalink
Convert the docs to AsciiDoc and Antora
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed May 28, 2020
1 parent 382e8ac commit 0d50317
Show file tree
Hide file tree
Showing 11 changed files with 4,214 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ rubocop-rspec is available on Code Climate as part of the rubocop engine. [Learn

## Documentation

You can read more about RuboCop-RSpec in its [official manual](http://rubocop-rspec.readthedocs.io).
You can read more about RuboCop-RSpec in its [official manual](https://docs.rubocop.org/rubocop-rspec).

## Inspecting files that don't end with `_spec.rb`

Expand Down
5 changes: 5 additions & 0 deletions docs/antora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: rubocop-rspec
title: RuboCop RSpec
version: master
nav:
- modules/ROOT/nav.adoc
9 changes: 9 additions & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* xref:index.adoc[Home]
* xref:installation.adoc[Installation]
* xref:usage.adoc[Usage]
* xref:cops.adoc[Cops]
* Cops Documentation
** xref:cops_capybara.adoc[Capybara]
** xref:cops_factorybot.adoc[FactoryBot]
** xref:cops_rails.adoc[Rails]
** xref:cops_rspec.adoc[RSpec]
99 changes: 99 additions & 0 deletions docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// START_COP_LIST

==== Department xref:cops_capybara.adoc[Capybara]

* link:cops_capybara.md#capybaracurrentpathexpectation[Capybara/CurrentPathExpectation]
* link:cops_capybara.md#capybarafeaturemethods[Capybara/FeatureMethods]
* link:cops_capybara.md#capybaravisibilitymatcher[Capybara/VisibilityMatcher]

==== Department xref:cops_factorybot.adoc[FactoryBot]

* link:cops_factorybot.md#factorybotattributedefinedstatically[FactoryBot/AttributeDefinedStatically]
* link:cops_factorybot.md#factorybotcreatelist[FactoryBot/CreateList]
* link:cops_factorybot.md#factorybotfactoryclassname[FactoryBot/FactoryClassName]

==== Department xref:cops_rspec.adoc[RSpec]

* link:cops_rspec.adoc#rspecalignleftletbrace[RSpec/AlignLeftLetBrace]
* link:cops_rspec.adoc#rspecalignrightletbrace[RSpec/AlignRightLetBrace]
* link:cops_rspec.adoc#rspecanyinstance[RSpec/AnyInstance]
* link:cops_rspec.adoc#rspecaroundblock[RSpec/AroundBlock]
* link:cops_rspec.adoc#rspecbe[RSpec/Be]
* link:cops_rspec.adoc#rspecbeeql[RSpec/BeEql]
* link:cops_rspec.adoc#rspecbeforeafterall[RSpec/BeforeAfterAll]
* link:cops_rspec.adoc#rspeccontextmethod[RSpec/ContextMethod]
* link:cops_rspec.adoc#rspeccontextwording[RSpec/ContextWording]
* link:cops_rspec.adoc#rspecdescribeclass[RSpec/DescribeClass]
* link:cops_rspec.adoc#rspecdescribemethod[RSpec/DescribeMethod]
* link:cops_rspec.adoc#rspecdescribesymbol[RSpec/DescribeSymbol]
* link:cops_rspec.adoc#rspecdescribedclass[RSpec/DescribedClass]
* link:cops_rspec.adoc#rspecdescribedclassmodulewrapping[RSpec/DescribedClassModuleWrapping]
* link:cops_rspec.adoc#rspecdialect[RSpec/Dialect]
* link:cops_rspec.adoc#rspecemptyexamplegroup[RSpec/EmptyExampleGroup]
* link:cops_rspec.adoc#rspecemptyhook[RSpec/EmptyHook]
* link:cops_rspec.adoc#rspecemptylineafterexample[RSpec/EmptyLineAfterExample]
* link:cops_rspec.adoc#rspecemptylineafterexamplegroup[RSpec/EmptyLineAfterExampleGroup]
* link:cops_rspec.adoc#rspecemptylineafterfinallet[RSpec/EmptyLineAfterFinalLet]
* link:cops_rspec.adoc#rspecemptylineafterhook[RSpec/EmptyLineAfterHook]
* link:cops_rspec.adoc#rspecemptylineaftersubject[RSpec/EmptyLineAfterSubject]
* link:cops_rspec.adoc#rspecexamplelength[RSpec/ExampleLength]
* link:cops_rspec.adoc#rspecexamplewithoutdescription[RSpec/ExampleWithoutDescription]
* link:cops_rspec.adoc#rspecexamplewording[RSpec/ExampleWording]
* link:cops_rspec.adoc#rspecexpectactual[RSpec/ExpectActual]
* link:cops_rspec.adoc#rspecexpectchange[RSpec/ExpectChange]
* link:cops_rspec.adoc#rspecexpectinhook[RSpec/ExpectInHook]
* link:cops_rspec.adoc#rspecexpectoutput[RSpec/ExpectOutput]
* link:cops_rspec.adoc#rspecfilepath[RSpec/FilePath]
* link:cops_rspec.adoc#rspecfocus[RSpec/Focus]
* link:cops_rspec.adoc#rspechookargument[RSpec/HookArgument]
* link:cops_rspec.adoc#rspechooksbeforeexamples[RSpec/HooksBeforeExamples]
* link:cops_rspec.adoc#rspecimplicitblockexpectation[RSpec/ImplicitBlockExpectation]
* link:cops_rspec.adoc#rspecimplicitexpect[RSpec/ImplicitExpect]
* link:cops_rspec.adoc#rspecimplicitsubject[RSpec/ImplicitSubject]
* link:cops_rspec.adoc#rspecinstancespy[RSpec/InstanceSpy]
* link:cops_rspec.adoc#rspecinstancevariable[RSpec/InstanceVariable]
* link:cops_rspec.adoc#rspecinvalidpredicatematcher[RSpec/InvalidPredicateMatcher]
* link:cops_rspec.adoc#rspecitbehaveslike[RSpec/ItBehavesLike]
* link:cops_rspec.adoc#rspeciteratedexpectation[RSpec/IteratedExpectation]
* link:cops_rspec.adoc#rspecleadingsubject[RSpec/LeadingSubject]
* link:cops_rspec.adoc#rspecleakyconstantdeclaration[RSpec/LeakyConstantDeclaration]
* link:cops_rspec.adoc#rspecletbeforeexamples[RSpec/LetBeforeExamples]
* link:cops_rspec.adoc#rspecletsetup[RSpec/LetSetup]
* link:cops_rspec.adoc#rspecmessagechain[RSpec/MessageChain]
* link:cops_rspec.adoc#rspecmessageexpectation[RSpec/MessageExpectation]
* link:cops_rspec.adoc#rspecmessagespies[RSpec/MessageSpies]
* link:cops_rspec.adoc#rspecmissingexamplegroupargument[RSpec/MissingExampleGroupArgument]
* link:cops_rspec.adoc#rspecmultipledescribes[RSpec/MultipleDescribes]
* link:cops_rspec.adoc#rspecmultipleexpectations[RSpec/MultipleExpectations]
* link:cops_rspec.adoc#rspecmultiplesubjects[RSpec/MultipleSubjects]
* link:cops_rspec.adoc#rspecnamedsubject[RSpec/NamedSubject]
* link:cops_rspec.adoc#rspecnestedgroups[RSpec/NestedGroups]
* link:cops_rspec.adoc#rspecnottonot[RSpec/NotToNot]
* link:cops_rspec.adoc#rspecoverwritingsetup[RSpec/OverwritingSetup]
* link:cops_rspec.adoc#rspecpending[RSpec/Pending]
* link:cops_rspec.adoc#rspecpredicatematcher[RSpec/PredicateMatcher]
* link:cops_rspec.adoc#rspecreceivecounts[RSpec/ReceiveCounts]
* link:cops_rspec.adoc#rspecreceivenever[RSpec/ReceiveNever]
* link:cops_rspec.adoc#rspecrepeateddescription[RSpec/RepeatedDescription]
* link:cops_rspec.adoc#rspecrepeatedexample[RSpec/RepeatedExample]
* link:cops_rspec.adoc#rspecrepeatedexamplegroupbody[RSpec/RepeatedExampleGroupBody]
* link:cops_rspec.adoc#rspecrepeatedexamplegroupdescription[RSpec/RepeatedExampleGroupDescription]
* link:cops_rspec.adoc#rspecreturnfromstub[RSpec/ReturnFromStub]
* link:cops_rspec.adoc#rspecscatteredlet[RSpec/ScatteredLet]
* link:cops_rspec.adoc#rspecscatteredsetup[RSpec/ScatteredSetup]
* link:cops_rspec.adoc#rspecsharedcontext[RSpec/SharedContext]
* link:cops_rspec.adoc#rspecsharedexamples[RSpec/SharedExamples]
* link:cops_rspec.adoc#rspecsingleargumentmessagechain[RSpec/SingleArgumentMessageChain]
* link:cops_rspec.adoc#rspecsubjectstub[RSpec/SubjectStub]
* link:cops_rspec.adoc#rspecunspecifiedexception[RSpec/UnspecifiedException]
* link:cops_rspec.adoc#rspecvariabledefinition[RSpec/VariableDefinition]
* link:cops_rspec.adoc#rspecvariablename[RSpec/VariableName]
* link:cops_rspec.adoc#rspecverifieddoubles[RSpec/VerifiedDoubles]
* link:cops_rspec.adoc#rspecvoidexpect[RSpec/VoidExpect]
* link:cops_rspec.adoc#rspecyield[RSpec/Yield]

==== Department xref:cops_rails.adoc[Rails]

* link:cops_rails.adoc#railshttpstatus[Rails/HttpStatus]

// END_COP_LIST
149 changes: 149 additions & 0 deletions docs/modules/ROOT/pages/cops_capybara.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
= Capybara

== Capybara/CurrentPathExpectation

|===
| Enabled by default | Supports autocorrection

| Enabled
| Yes
|===

Checks that no expectations are set on Capybara's `current_path`.

The `have_current_path` matcher (https://www.rubydoc.info/github/
teamcapybara/capybara/master/Capybara/RSpecMatchers#have_current_path-
instance_method) should be used on `page` to set expectations on
Capybara's current path, since it uses Capybara's waiting
functionality (https://github.com/teamcapybara/capybara/blob/master/
README.md#asynchronous-javascript-ajax-and-friends) which ensures that
preceding actions (like `click_link`) have completed.

=== Examples

[source,ruby]
----
# bad
expect(current_path).to eq('/callback')
expect(page.current_path).to match(/widgets/)
# good
expect(page).to have_current_path("/callback")
expect(page).to have_current_path(/widgets/)
----

=== References

* https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/CurrentPathExpectation

== Capybara/FeatureMethods

|===
| Enabled by default | Supports autocorrection

| Enabled
| Yes
|===

Checks for consistent method usage in feature specs.

By default, the cop disables all Capybara-specific methods that have
the same native RSpec method (e.g. are just aliases). Some teams
however may prefer using some of the Capybara methods (like `feature`)
to make it obvious that the test uses Capybara, while still disable
the rest of the methods, like `given` (alias for `let`), `background`
(alias for `before`), etc. You can configure which of the methods to
be enabled by using the EnabledMethods configuration option.

=== Examples

[source,ruby]
----
# bad
feature 'User logs in' do
given(:user) { User.new }
background do
visit new_session_path
end
scenario 'with OAuth' do
# ...
end
end
# good
describe 'User logs in' do
let(:user) { User.new }
before do
visit new_session_path
end
it 'with OAuth' do
# ...
end
end
----

=== Configurable attributes

|===
| Name | Default value | Configurable values

| EnabledMethods
| `[]`
| Array
|===

=== References

* https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/FeatureMethods

== Capybara/VisibilityMatcher

|===
| Enabled by default | Supports autocorrection

| Enabled
| No
|===

Checks for boolean visibility in capybara finders.

Capybara lets you find elements that match a certain visibility using
the `:visible` option. `:visible` accepts both boolean and symbols as
values, however using booleans can have unwanted effects. `visible:
false` does not find just invisible elements, but both visible and
invisible elements. For expressiveness and clarity, use one of the
symbol values, `:all`, `:hidden` or `:visible`.
(https://www.rubydoc.info/gems/capybara/Capybara%2FNode%2FFinders:all)

=== Examples

[source,ruby]
----
# bad
expect(page).to have_selector('.foo', visible: false)
expect(page).to have_css('.foo', visible: true)
expect(page).to have_link('my link', visible: false)
# good
expect(page).to have_selector('.foo', visible: :visible)
expect(page).to have_css('.foo', visible: :all)
expect(page).to have_link('my link', visible: :hidden)
----

=== Configurable attributes

|===
| Name | Default value | Configurable values

| VersionAdded
| `1.39`
| String
|===

=== References

* https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/VisibilityMatcher
Loading

2 comments on commit 0d50317

@pirj
Copy link
Member

@pirj pirj commented on 0d50317 Jun 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bbatsov
Copy link
Contributor Author

@bbatsov bbatsov commented on 0d50317 Jun 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we need to write more documentation. 😉

Please sign in to comment.