You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Title branches as (feature/bug/chore/style)/(branch name)
Submitting Pull Requests
Have descriptive commit messages
Submit pull requests with a clear and concise title
Use - for points
Include a screen shot if any styles have changed
Include a link to the card that the PR covers
HTML
Prefer double quotes for attributes.
JavaScript
Prefer ES6 classes over prototypes.
Use strict equality checks (=== and !==) except when comparing against
(null or undefined).
Prefer arrow functions=>, over the function keyword except when
defining classes or methods.
Use semicolons at the end of each statement.
Prefer double quotes.
Two spaces
Use PascalCase for classes, lowerCamelCase for variables and functions,
SCREAMING_SNAKE_CASE for constants, _singleLeadingUnderscore for private
variables and functions.
Order factories.rb contents: sequences, traits, factory definitions.
Order factory attributes: implicit attributes, explicit attributes,
child factory definitions. Each section's attributes are alphabetical.
Order factory definitions alphabetically by factory name.
Use one factories.rb file per project.
Unit Tests
Don't prefix it block descriptions with should. Use Imperative mood
instead.
Use subject blocks to define objects for use in one-line specs.
Put one-liner specs at the beginning of the outer describe blocks.
Use .method to describe class methods and #method to describe instance
methods.
Use context to describe testing preconditions.
Use describe '#method_name' to group tests by method-under-test
Use a single, top-level describe ClassName block.
Order validation, association, and method tests in the same order that they
appear in the class.
describeSomeClassdocontext"when defining a subject"do# GOOD# it's okay to define a `subject` here:subject{"foo"}it{shouldeq"foo"}endcontext"when using an explicit subject"dosubject{"foo"}it"should equal foo"do# BAD# although it's valid RSpec code and this test passes,# it's not okay to use `subject` here:expect(subject).toeq"foo"endenddescribe'.some_class_method'doit'does something'do# ...endenddescribe'#some_instance_method'doit'does something'doexpect(something).toeq'something'endenddescribe'#another_instance_method'docontext'when in one case'doit'does something'do# ...endendcontext'when in other case'doit'does something else'do# ...endendendend
UNDECIDED Avoid let
# BADdescribeReportPolicydolet(:user){User.new(report_ids: [1,2])}let(:report){Report.new(id: 2)}describe"#allowed?"docontext"when user has access to report"doit"returns true"dopolicy=ReportPolicy.new(user,report)expect(policy).tobe_allowedendendcontext"when user does not have access to report"doit"returns false"doreport.id=3policy=ReportPolicy.new(user,report)expect(policy).not_tobe_allowedendendendend# GOODdescribeReportPolicydodescribe"#allowed?"docontext"when user has access to report"doit"returns true"dopolicy=build_policy(report_id: 2,allowed_report_ids: [1,2])expect(policy).tobe_allowedendendcontext"when user does not have access to report"doit"returns false"dopolicy=build_policy(report_id: 3,allowed_report_ids: [1,2])expect(policy).not_tobe_allowedendendenddefbuild_policy(report_id:,allowed_report_ids:)user=instance_double("User",report_ids: allowed_report_ids)report=instance_double("Report",id: report_id)ReportPolicy.new(user,report)endend