A simple rspec snippets to make life easier.
Enjoy!
rspec-new-rails-file
: Rails standard new spec file template.rspec-new-file
: New spec file template.rspec-new-shared-example
: New rspec shared example filerspec-new-shared-context
: New rspec shared context filerspec-include_context
: include_context shared contextrspec-describe-block
: Describe blockrspec-context-block
: Context blockrspec-it-block
: Rspec it blockrspec-it_behaves_like
: it_behaves_like shared examplesrspec-it-inline
: One liner it that uses subject
rspec-fixture
: Declared a file fixturerspec-fixture:size
: Get the file size of fixture filerspec-fixture:read
: Read fixture file as stringrspec-fixture:read-json
: Read fixture file as hash objectrspec-fixture:read-json-symbolize_keys
: Read fixture file as hash object with its key symbolizedrspec-fixture:read-json-array-symbolize_keys
: Read fixture file as array of hashes where the keys are symbolized
rspec-let
: Let declarationrspec-let-instance-double
: Let declaration of instance doublerspec-let-class-double
: Let declaration of class doublerspec-let-job-peform
: Let declaration that triggers the ActiveJobrspec-let-module
: Let you test methods in module by calling them directly
rspec-string
: Test stringrspec-array
: Test Arrayrspec-hash
: Test Hashrspec-numeric
: Test Numbersrspec-exception
: Test Exceptions
rspec-truthy
: be_truthy shortcutrspec-truthy-subject
: Inline test using subjectrspec-falsy
: be_falsy shortcutrspec-falsy-subject
: Inline test using subject
rspec-expect:mock-return
: Rspec expectition with mockrspec-expect:mock
: Rspec expectitionrspec-expect:execution-inline
: Rspec expect execution inline with "expect {}.to"rspec-expect:mock-minimum
: Rspec expectition minimumrspec-mock-rails-logger
: Mocks Rails logger to check if a message was sentrspec-instance-double
: Declare instance doublerspec-instance-double-new
: Initialize instance doublerspec-allow-receive-return
: Allow to receive and return valuerspec-allow-receive-with-and-return
: Allow to receive with param and return value
rspec-job-enqueued
: Check it see if a ActiveJob was enqueued after a code is executed
rspec-its(:size)
: Check the size of the hashrspec-its(:keys)
: Check all key names onlyrspec-its([:key])
: Check hash key valuerspec-its([:key1, :key2])
: subject { {key1: {key2: 3} } } | its([:key1, :key2]) { is_expected.to eq(3) }
rspec-allow_value
: Test usage ofallow_value
inlinerspec-allow_value-qualifiers
: Test usage ofallow_value
with qualifiersrspec-have_secure_password
: Test usage ofhave_secure_password
rspec-validate_absence_of
: Test usage of validates_absence_ofrspec-validate_acceptance_of
: Test usage of validates_acceptance_ofrspec-validate_confirmation_of
: Test usage of validates_confirmation_ofrspec-validate_exclusion_of
: Test usage ofvalidate_exclusion_of
rspec-validate_inclusion_of
: Test usage of validates_inclusion_ofrspec-validate_length_of
: Test usage of validates_length_ofrspec-validate_length_of:minimum
: Test usage ofvalidate_length_of
inlinerspec-validate_numericality_of
: Test usage of validates_numericality_ofrspec-validate_presence_of
: Test usage of validates_presence_of
rspec-accepts_nested_attributes_for
: Tests usage ofaccepts_nested_attributes_for
inlinerspec-accepts_nested_attributes_for-qualifiers
: Tests usage ofaccepts_nested_attributes_for
with qualifiersrspec-belongs_to
: Test usage of belongs_torspec-has_many
: Test usage of has_manyrspec-have_one
: Test usage of have_onerspec-validate_uniqueness_of
: Tests usage ofvalidate_uniqueness_of
rspec-permit
: Test controller paramsrspec-redirect
: Test redirectrspec-route
: Test routingrspec-render-template
: Test render templaterspec-render-partial
: Test partial templaterspec-respond-with
: Test http status coderspec-check-session
: Test session
For changelog see CHANGELOG.md