Skip to content

Instantly share code, notes, and snippets.

@hieuns
Last active March 23, 2021 08:53
Show Gist options
  • Save hieuns/6c225769c94c159933f4e2a490376d0a to your computer and use it in GitHub Desktop.
Save hieuns/6c225769c94c159933f4e2a490376d0a to your computer and use it in GitHub Desktop.
Personal Atom snippets
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
# 'Console log':
# 'prefix': 'log'
# 'body': 'console.log $1'
#
# Each scope (e.g. '.source.coffee' above) can only be declared once.
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it in the
# Atom Flight Manual:
# http://flight-manual.atom.io/using-atom/sections/basic-customization/#_cson
".source.ruby":
"Magic comment":
"prefix": "fsl"
"body": "# frozen_string_literal: true"
"Nocov":
"prefix": "nocov"
"body": """
# :nocov:
$1
# :nocov:
"""
"Class inheritance":
"prefix": "clai"
"body": """
class $1 < $2
$3
end
"""
"RSpec.shared_examples":
"prefix": "Rsx"
"body": """
RSpec.shared_examples '$1' do
$2
end$3
"""
"shared_examples":
"prefix": "sx"
"body": """
shared_examples '$1' do
$2
end$3
"""
"RSpec.shared_context":
"prefix": "Rsctx"
"body": """
RSpec.shared_context '$1' do
$2
end$3
"""
"shared_context":
"prefix": "sctx"
"body": """
shared_context '$1' do
$2
end$3
"""
"RSpec.describe":
"prefix": "Rsdes"
"body": """
RSpec.describe $1 do
$2
end
"""
"RSpec.describe with type":
"prefix": "Rsdt"
"body": """
RSpec.describe $1, type: :$2 do
$3
end
"""
"Rspec let - 1 line":
"prefix": "rle"
"body": "let(:$1) { $2 }$3"
"Rspec let - n line":
"prefix": "rlem"
"body": """
let(:$1) do
$2
end$3
"""
"Rspec let! - 1 line":
"prefix": "rleb"
"body": "let!(:$1) { $2 }$3"
"Rspec let! - n line":
"prefix": "rlebm"
"body": """
let!(:$1) do
$2
end$3
"""
"Rspec describe":
"prefix": "descrb"
"body": """
describe '$1' do
$2
end$3
"""
"Rspec context":
"prefix": "contx"
"body": """
context '$1' do
$2
end$3
"""
"Rspec allow":
"prefix": "ral"
"body": "allow($1).to receive(:$2).and_return $3"
"Rspec allow with params":
"prefix": "rarw"
"body": "allow($1).to receive(:$2).with($3).and_return $4"
"Rspec allow to receive messages":
"prefix": "rams"
"body": "allow($1).to receive_messages($2)$3"
"Rspec allow_any_instance_of":
"prefix": "raio"
"body": "allow_any_instance_of($1).to receive(:$2).and_return $3"
"Rspec allow_any_instance_of receive messages":
"prefix": "raims"
"body": "allow_any_instance_of($1).to receive_messages($2)$3"
"Rspec expect to receive":
"prefix": "rer"
"body": "expect($1).to receive(:$2).and_return $3"
"Rspec expect to receive with params":
"prefix": "rew"
"body": "expect($1).to receive(:$2).with($3).and_return $4"
"Rspec before - 1 line":
"prefix": "rbef"
"body": "before { $1 }$2"
"Rspec before - n lines":
"prefix": "rbem"
"body": """
before do
$1
end$2
"""
"Rspec after - 1 line":
"prefix": "raf"
"body": "after { $1 }$2"
"Rspec after - n lines":
"prefix": "ram"
"body": """
after do
$1
end$2
"""
"Rspec subject - 1 line":
"prefix": "rsub"
"body": "subject { $1 }$2"
"Rspec subject - n line":
"prefix": "rsum"
"body": """
subject do
$1
end$2
"""
"Rspec it should - 1 line":
"prefix": "itsh"
"body": "it { should $1 }$2"
"Rspec it should - n lines":
"prefix": "itshm"
"body": """
it "$1" do
should $2
end$3
"""
"Rspec it should - no comment":
"prefix": "itshn"
"body": """
it do
should $1
end$2
"""
"Rspec it should not - 1 line":
"prefix": "itnsh"
"body": "it { should_not $1 }$2"
"Rspec it should not - n lines":
"prefix": "itnshm"
"body": """
it "$1" do
should_not $2
end$3
"""
"Rspec it should not - no comment":
"prefix": "itnshn"
"body": """
it do
should_not $1
end$2
"""
"Rspec it expect 1 line":
"prefix": "ite"
"body": "it { expect($1).to $2 }$3"
"Rspec it expect 1 line with {}":
"prefix": "itec"
"body": "it { expect{$1}.to $2 }$3"
"Rspec it expect n lines":
"prefix": "item"
"body": """
it "$1" do
expect($2).to $3
end$4
"""
"Rspec it expect n lines with {}":
"prefix": "itemc"
"body": """
it "$1" do
expect { $2 }.to $3
end$4
"""
"Rspec it expect no comment":
"prefix": "iten"
"body": """
it do
expect($1).to $2
end$3
"""
"Rspec it expect no comment with {}":
"prefix": "itenc"
"body": """
it do
expect { $1 }.to $2
end$3
"""
"Rspec it is expected to - 1 line":
"prefix": "itie"
"body": "it { is_expected.to $1 }$2"
"Rspec it is expected to - n lines":
"prefix": "itiem"
"body": """
it "$1" do
is_expected.to $2
end$3
"""
"Rspec it is expected to - no comment":
"prefix": "itien"
"body": """
it do
is_expected.to $1
end$2
"""
"Rspec it is expected to eq - 1 line":
"prefix": "itieq"
"body": "it { is_expected.to eq $1 }$2"
"Rspec it is expected to eq - n lines":
"prefix": "itieqm"
"body": """
it "$1" do
is_expected.to eq $2
end$3
"""
"Rspec it is expected to eq - no comment":
"prefix": "itieqn"
"body": """
it do
is_expected.to eq $1
end$2
"""
"Rspec it is expected not to - 1 line":
"prefix": "itine"
"body": "it { is_expected.not_to $1 }$2"
"Rspec it is expected not to - n lines":
"prefix": "itinem"
"body": """
it "$1" do
is_expected.not_to $2
end$3
"""
"Rspec it is expected not to - no comment":
"prefix": "itinen"
"body": """
it do
is_expected.not_to $1
end$2
"""
"Rspec it is expected not to eq - 1 line":
"prefix": "itneq"
"body": "it { is_expected.not_to eq $1 }$2"
"Rspec it is expected not to eq - n lines":
"prefix": "itneqm"
"body": """
it "$1" do
is_expected.not_to eq $2
end$3
"""
"Rspec it is expected not to eq - no comment":
"prefix": "itneqn"
"body": """
it do
is_expected.not_to eq $1
end$2
"""
"Rspec it is expected to validate presence of - 1 line":
"prefix": "itvp"
"body": "it { is_expected.to validate_presence_of :$1 }$2"
"Rspec it is expected to validate presence of - n lines":
"prefix": "itvpm"
"body": """
it "$1" do
is_expected.to validate_presence_of :$2
end$3
"""
"Rspec it is expected to validate presence of - no comment":
"prefix": "itvpn"
"body": """
it do
is_expected.to validate_presence_of :$1
end$2
"""
"Rspec it is expected to not validate presence of - 1 line":
"prefix": "itnvp"
"body": "it { is_expected.not_to validate_presence_of :$1 }$2"
"Rspec it is expected to not validate presence of - n lines":
"prefix": "itnvpm"
"body": """
it "$1" do
is_expected.not_to validate_presence_of :$2
end$3
"""
"Rspec it is expected to not validate presence of - no comment":
"prefix": "itnnvp"
"body": """
it do
is_expected.not_to validate_presence_of :$1
end$2
"""
"Rspec it is expected to validate uniqueness of - 1 line":
"prefix": "itvu"
"body": "it { is_expected.to validate_uniqueness_of $1 }$2"
"Rspec it is expected to validate uniqueness of - n lines":
"prefix": "itvum"
"body": """
it "$1" do
is_expected.to validate_uniqueness_of $2
end$3
"""
"Rspec it is expected to validate uniqueness of - no comment":
"prefix": "itvun"
"body": """
it do
is_expected.to validate_uniqueness_of $1
end$2
"""
"Rspec it is expected to validate inclusion of - 1 line":
"prefix": "itvi"
"body": "it { is_expected.to validate_inclusion_of(:$1).in_array $2 }$3"
"Rspec it is expected to validate inclusion of - n lines":
"prefix": "itvim"
"body": """
it "$1" do
is_expected.to validate_inclusion_of(:$2).in_array $3
end$4
"""
"Rspec it is expected to validate inclusion of - no comment":
"prefix": "itvin"
"body": """
it do
is_expected.to validate_inclusion_of(:$1).in_array $2
end$3
"""
"Rspec its(:attr) is expected to eq":
"prefix": "itsieq"
"body": "its(:$1) { is_expected.to eq $2 }$3"
".source.python":
"Stop and interact with code":
"prefix": "pry"
"body": """
import code
code.interact(local=dict(globals(), **locals()))
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment