Created
July 9, 2025 10:21
-
-
Save hieuns/b13d71cfec23c22edb4f41f3c40f862f to your computer and use it in GitHub Desktop.
Ruby snippets for VSCode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
// { | |
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and | |
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope | |
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is | |
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. | |
// Placeholders with the same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "scope": "javascript,typescript", | |
// "prefix": "log", | |
// "body": [ | |
// "console.log(\"$1\");", | |
// "$2" | |
// ], | |
// "description": "Log output to console" | |
// } | |
// } | |
{ | |
"Ruby Shebang": { | |
"prefix": "rb", | |
"body": "#!/usr/bin/env ruby -wKU", | |
"description": "Ruby shebang line", | |
"scope": "ruby" | |
}, | |
"UTF-8 Encoding": { | |
"prefix": "utf8", | |
"body": "# encoding: ${1:UTF-8}", | |
"description": "UTF-8 encoding comment", | |
"scope": "ruby" | |
}, | |
"if-else-end": { | |
"prefix": "ife", | |
"body": "if ${1:condition}\n\t$2\nelse\n\t$3\nend", | |
"description": "if-else-end block", | |
"scope": "ruby" | |
}, | |
"if-end": { | |
"prefix": "if", | |
"body": "if ${1:condition}\n\t$0\nend", | |
"description": "if-end block", | |
"scope": "ruby" | |
}, | |
"RSpec it block": { | |
"prefix": "it", | |
"body": "it \"${1:text}\" do\n\t$0\nend", | |
"description": "RSpec it block", | |
"scope": "ruby" | |
}, | |
"case-when-end": { | |
"prefix": "case", | |
"body": "case ${1:object}\nwhen ${2:condition}\n\t$0\nend", | |
"description": "case-when-end block", | |
"scope": "ruby" | |
}, | |
"begin-rescue-end": { | |
"prefix": "beg", | |
"body": "begin\n\t$1\nrescue ${2:ExceptionName}\n\t$3\nend", | |
"description": "begin-rescue-end block", | |
"scope": "ruby" | |
}, | |
"refine block": { | |
"prefix": "ref", | |
"body": "refine ${1:ClassName} do\n\t$2\nend", | |
"description": "refine block", | |
"scope": "ruby" | |
}, | |
"using": { | |
"prefix": "usi", | |
"body": "using ${1:ModuleName}", | |
"description": "using statement", | |
"scope": "ruby" | |
}, | |
"Hash rocket pair": { | |
"prefix": "hp", | |
"body": ":${1:key} => ${2:\"${3:value}\"}${4:, }", | |
"description": "Hash key-value pair", | |
"scope": "ruby" | |
}, | |
"class definition": { | |
"prefix": "cla", | |
"body": "class ${1:ClassName}\n\t$0\nend", | |
"description": "class definition", | |
"scope": "ruby" | |
}, | |
"method definition": { | |
"prefix": "def", | |
"body": "def ${1:method_name}\n\t$0\nend", | |
"description": "method definition", | |
"scope": "ruby" | |
}, | |
"initialize method": { | |
"prefix": "defi", | |
"body": "def initialize${1:(${2:argument})}\n\t@${2:argument} = ${2:argument}$0\nend", | |
"description": "initialize method", | |
"scope": "ruby" | |
}, | |
"class method definition": { | |
"prefix": "defs", | |
"body": "def self.${1:class_method_name}\n\t$0\nend", | |
"description": "class method definition", | |
"scope": "ruby" | |
}, | |
"do-end block": { | |
"prefix": "do", | |
"body": "do\n\t$0\nend", | |
"description": "do-end block", | |
"scope": "ruby" | |
}, | |
"do-end block with params": { | |
"prefix": "dop", | |
"body": "do |${1:variable}|\n\t$0\nend", | |
"description": "do-end block with parameters", | |
"scope": "ruby" | |
}, | |
"each block": { | |
"prefix": "ea", | |
"body": "each { |${1:e}| $0 }", | |
"description": "each block", | |
"scope": "ruby" | |
}, | |
"map block": { | |
"prefix": "map", | |
"body": "map { |${1:e}| $0 }", | |
"description": "map block", | |
"scope": "ruby" | |
}, | |
"select block": { | |
"prefix": "sel", | |
"body": "select { |${1:e}| $0 }", | |
"description": "select block", | |
"scope": "ruby" | |
}, | |
"reject block": { | |
"prefix": "rej", | |
"body": "reject { |${1:e}| $0 }", | |
"description": "reject block", | |
"scope": "ruby" | |
}, | |
"unless block": { | |
"prefix": "unless", | |
"body": "unless ${1:condition}\n\t$0\nend", | |
"description": "unless block", | |
"scope": "ruby" | |
}, | |
"while block": { | |
"prefix": "while", | |
"body": "while ${1:condition}\n\t$0\nend", | |
"description": "while block", | |
"scope": "ruby" | |
}, | |
"until block": { | |
"prefix": "until", | |
"body": "until ${1:condition}\n\t$0\nend", | |
"description": "until block", | |
"scope": "ruby" | |
}, | |
"pry debugger": { | |
"prefix": "pry", | |
"body": "binding.pry", | |
"description": "Insert pry debugger", | |
"scope": "ruby" | |
}, | |
"ERB output tag": { | |
"prefix": "=", | |
"body": "<%= $1 %>", | |
"description": "ERB output tag", | |
"scope": "text.html.erb" | |
}, | |
"ERB execution tag": { | |
"prefix": "-", | |
"body": "<% $1 %>", | |
"description": "ERB execution tag", | |
"scope": "text.html.erb" | |
}, | |
"String interpolation": { | |
"prefix": "#", | |
"body": "#{$1}$2", | |
"description": "String interpolation", | |
"scope": "string.quoted.double.ruby" | |
}, | |
"Benchmark.bmbm": { | |
"prefix": "bm-", | |
"body": "TESTS = ${1:10_000}\nBenchmark.bmbm do |results|\n $0\nend", | |
"description": "Benchmark.bmbm block", | |
"scope": "ruby" | |
}, | |
"Dir.glob": { | |
"prefix": "Dirg", | |
"body": "Dir.glob(${1:\"${2:dir/glob/*}\"}) { |${3:file}| $0 }", | |
"description": "Dir.glob with block", | |
"scope": "ruby" | |
}, | |
"Dir[]": { | |
"prefix": "Dir", | |
"body": "Dir[${1:\"${2:glob/**/*.rb}\"}]", | |
"description": "Dir[] glob pattern", | |
"scope": "ruby" | |
}, | |
"File.foreach": { | |
"prefix": "Filef", | |
"body": "File.foreach(${1:\"${2:path/to/file}\"}) { |${3:line}| $0 }", | |
"description": "File.foreach with block", | |
"scope": "ruby" | |
}, | |
"File.read": { | |
"prefix": "File", | |
"body": "File.read(${1:\"${2:path/to/file}\"})", | |
"description": "File.read", | |
"scope": "ruby" | |
}, | |
"Hash.new with block": { | |
"prefix": "Hash", | |
"body": "Hash.new { |${1:hash}, ${2:key}| ${1:hash}[${2:key}] = $0 }", | |
"description": "Hash.new with default block", | |
"scope": "ruby" | |
}, | |
"Array.new": { | |
"prefix": "arr", | |
"body": "Array.new(${1:len,val})\n$0", | |
"description": "Array.new", | |
"scope": "ruby" | |
}, | |
"Array.new with block": { | |
"prefix": "arri", | |
"body": "Array.new(${1:len}) { |${2:i}| $0 }", | |
"description": "Array.new with block", | |
"scope": "ruby" | |
}, | |
"Marshal.dump": { | |
"prefix": "Md", | |
"body": "File.open(${1:\"${2:path/to/file}.dump\"}, \"wb\") { |${3:file}| Marshal.dump(${4:obj}, ${3:file}) }", | |
"description": "Marshal.dump to file", | |
"scope": "ruby" | |
}, | |
"Marshal.load": { | |
"prefix": "Ml", | |
"body": "File.open(${1:\"${2:path/to/file}.dump\"}, \"rb\") { |${3:file}| Marshal.load(${3:file}) }", | |
"description": "Marshal.load from file", | |
"scope": "ruby" | |
}, | |
"PStore.new": { | |
"prefix": "Pn-", | |
"body": "PStore.new(${1:\"${2:file_name.pstore}\"})", | |
"description": "PStore.new", | |
"scope": "ruby" | |
}, | |
"YAML.dump": { | |
"prefix": "Yd-", | |
"body": "File.open(${1:\"${2:path/to/file}.yaml\"}, \"w\") { |${3:file}| YAML.dump(${4:obj}, ${3:file}) }", | |
"description": "YAML.dump to file", | |
"scope": "ruby" | |
}, | |
"YAML.load": { | |
"prefix": "Yl-", | |
"body": "File.open(${1:\"${2:path/to/file}.yaml\"}) { |${3:file}| YAML.load(${3:file}) }", | |
"description": "YAML.load from file", | |
"scope": "ruby" | |
}, | |
"alias_method": { | |
"prefix": "am", | |
"body": "alias_method :${1:new_name}, :${0:old_name}", | |
"description": "alias_method", | |
"scope": "ruby" | |
}, | |
"all?": { | |
"prefix": "all", | |
"body": "all? { |${1:e}| $0 }", | |
"description": "all? with block", | |
"scope": "ruby" | |
}, | |
"any?": { | |
"prefix": "any", | |
"body": "any? { |${1:e}| $0 }", | |
"description": "any? with block", | |
"scope": "ruby" | |
}, | |
"application block": { | |
"prefix": "app", | |
"body": "if __FILE__ == \\$PROGRAM_NAME\n\t$0\nend", | |
"description": "Application main block", | |
"scope": "ruby" | |
}, | |
"assert_nothing_raised": { | |
"prefix": "asnr", | |
"body": "assert_nothing_raised(${1:Exception}) { $0 }", | |
"description": "assert_nothing_raised", | |
"scope": "ruby" | |
}, | |
"assert_nothing_thrown": { | |
"prefix": "asnt", | |
"body": "assert_nothing_thrown { $0 }", | |
"description": "assert_nothing_thrown", | |
"scope": "ruby" | |
}, | |
"assert_raise": { | |
"prefix": "asr", | |
"body": "assert_raise(${1:Exception}) { $0 }", | |
"description": "assert_raise", | |
"scope": "ruby" | |
}, | |
"assert_throws": { | |
"prefix": "ast", | |
"body": "assert_throws(:${1:expected}) { $0 }", | |
"description": "assert_throws", | |
"scope": "ruby" | |
}, | |
"attr_accessor": { | |
"prefix": "rw", | |
"body": "attr_accessor :${0:attr_names}", | |
"description": "attr_accessor", | |
"scope": "ruby" | |
}, | |
"attr_reader": { | |
"prefix": "r", | |
"body": "attr_reader :${0:attr_names}", | |
"description": "attr_reader", | |
"scope": "ruby" | |
}, | |
"attr_writer": { | |
"prefix": "w", | |
"body": "attr_writer :${0:attr_names}", | |
"description": "attr_writer", | |
"scope": "ruby" | |
}, | |
"Struct class": { | |
"prefix": "clast", | |
"body": "$1 = Struct.new(:${2:attr_names}) do\n\tdef ${3:method_name}\n\t\t$0\n\tend\n\t\n\t\nend", | |
"description": "Struct class definition", | |
"scope": "ruby" | |
}, | |
"eigenclass": { | |
"prefix": "clase", | |
"body": "class << ${1:self}\n\t$0\nend", | |
"description": "Eigenclass definition", | |
"scope": "ruby" | |
}, | |
"class_from_name": { | |
"prefix": "clafn", | |
"body": "split(\"::\").inject(Object) { |par, const| par.const_get(const) }", | |
"description": "class_from_name helper", | |
"scope": "ruby" | |
}, | |
"collect": { | |
"prefix": "col", | |
"body": "collect { |${1:e}| $0 }", | |
"description": "collect with block", | |
"scope": "ruby" | |
}, | |
"deep_copy": { | |
"prefix": "deec", | |
"body": "Marshal.load(Marshal.dump(${0:obj_to_copy}))", | |
"description": "Deep copy using Marshal", | |
"scope": "ruby" | |
}, | |
"test method": { | |
"prefix": "deft", | |
"body": "def test_${1:case_name}\n\t$0\nend", | |
"description": "Test method definition", | |
"scope": "ruby" | |
}, | |
"def_delegator": { | |
"prefix": "defd", | |
"body": "def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name}", | |
"description": "def_delegator", | |
"scope": "ruby" | |
}, | |
"def_delegators": { | |
"prefix": "defds", | |
"body": "def_delegators :${1:@del_obj}, :${0:del_methods}", | |
"description": "def_delegators", | |
"scope": "ruby" | |
}, | |
"delete_if": { | |
"prefix": "deli", | |
"body": "delete_if { |${1:e}| $0 }", | |
"description": "delete_if with block", | |
"scope": "ruby" | |
}, | |
"detect": { | |
"prefix": "det", | |
"body": "detect { |${1:e}| $0 }", | |
"description": "detect with block", | |
"scope": "ruby" | |
}, | |
"directory helper": { | |
"prefix": "dir", | |
"body": "File.dirname(__FILE__)", | |
"description": "Current directory helper", | |
"scope": "ruby" | |
}, | |
"each_byte": { | |
"prefix": "eab", | |
"body": "each_byte { |${1:byte}| $0 }", | |
"description": "each_byte with block", | |
"scope": "ruby" | |
}, | |
"each_char": { | |
"prefix": "eacha", | |
"body": "each_char { |${1:chr}| $0 }", | |
"description": "each_char with block", | |
"scope": "ruby" | |
}, | |
"each_cons": { | |
"prefix": "eacon", | |
"body": "each_cons(${1:2}) { |${2:group}| $0 }", | |
"description": "each_cons with block", | |
"scope": "ruby" | |
}, | |
"each_index": { | |
"prefix": "eai", | |
"body": "each_index { |${1:i}| $0 }", | |
"description": "each_index with block", | |
"scope": "ruby" | |
}, | |
"each_key": { | |
"prefix": "eak", | |
"body": "each_key { |${1:key}| $0 }", | |
"description": "each_key with block", | |
"scope": "ruby" | |
}, | |
"each_line": { | |
"prefix": "eal", | |
"body": "each_line$1 { |${2:line}| $0 }", | |
"description": "each_line with block", | |
"scope": "ruby" | |
}, | |
"each_pair": { | |
"prefix": "eap", | |
"body": "each_pair { |${1:name}, ${2:val}| $0 }", | |
"description": "each_pair with block", | |
"scope": "ruby" | |
}, | |
"each_slice": { | |
"prefix": "eas-", | |
"body": "each_slice(${1:2}) { |${2:group}| $0 }", | |
"description": "each_slice with block", | |
"scope": "ruby" | |
}, | |
"each_value": { | |
"prefix": "eav", | |
"body": "each_value { |${1:val}| $0 }", | |
"description": "each_value with block", | |
"scope": "ruby" | |
}, | |
"each_with_index": { | |
"prefix": "eawi", | |
"body": "each_with_index { |${1:e}, ${2:i}| $0 }", | |
"description": "each_with_index with block", | |
"scope": "ruby" | |
}, | |
"elsif": { | |
"prefix": "elsif", | |
"body": "elsif ${1:condition}\n\t$0", | |
"description": "elsif clause", | |
"scope": "ruby" | |
}, | |
"extend Forwardable": { | |
"prefix": "Forw", | |
"body": "extend Forwardable", | |
"description": "extend Forwardable", | |
"scope": "ruby" | |
}, | |
"find": { | |
"prefix": "fin", | |
"body": "find { |${1:e}| $0 }", | |
"description": "find with block", | |
"scope": "ruby" | |
}, | |
"find_all": { | |
"prefix": "fina", | |
"body": "find_all { |${1:e}| $0 }", | |
"description": "find_all with block", | |
"scope": "ruby" | |
}, | |
"flatten_once": { | |
"prefix": "flao", | |
"body": "inject(Array.new) { |${1:arr}, ${2:a}| ${1:arr}.push(*${2:a}) }", | |
"description": "flatten_once helper", | |
"scope": "ruby" | |
}, | |
"grep": { | |
"prefix": "gre", | |
"body": "grep(${1:/${2:pattern}/}) { |${3:match}| $0 }", | |
"description": "grep with block", | |
"scope": "ruby" | |
}, | |
"include Comparable": { | |
"prefix": "Comp", | |
"body": "include Comparable\n\ndef <=>(other)\n\t$0\nend", | |
"description": "include Comparable with spaceship", | |
"scope": "ruby" | |
}, | |
"include Enumerable": { | |
"prefix": "Enum", | |
"body": "include Enumerable\n\ndef each(&block)\n\t$0\nend", | |
"description": "include Enumerable with each", | |
"scope": "ruby" | |
}, | |
"loop": { | |
"prefix": "loo", | |
"body": "loop { $0 }", | |
"description": "loop block", | |
"scope": "ruby" | |
}, | |
"map_with_index": { | |
"prefix": "mapwi-", | |
"body": "enum_with_index.map { |${1:e}, ${2:i}| $0 }", | |
"description": "map_with_index helper", | |
"scope": "ruby" | |
}, | |
"max": { | |
"prefix": "max", | |
"body": "max { |a, b| $0 }", | |
"description": "max with block", | |
"scope": "ruby" | |
}, | |
"min": { | |
"prefix": "min", | |
"body": "min { |a, b| $0 }", | |
"description": "min with block", | |
"scope": "ruby" | |
}, | |
"module with module_function": { | |
"prefix": "modf", | |
"body": "module $1\n\tmodule_function\n\t\n\t$0\nend", | |
"description": "module with module_function", | |
"scope": "ruby" | |
}, | |
"module": { | |
"prefix": "mod", | |
"body": "module ${1:ModuleName}\n\t$0\nend", | |
"description": "module definition", | |
"scope": "ruby" | |
}, | |
"namespace": { | |
"prefix": "nam", | |
"body": "namespace :$1 do\n\t$0\nend", | |
"description": "namespace block", | |
"scope": "ruby" | |
}, | |
"partition": { | |
"prefix": "par", | |
"body": "partition { |${1:e}| $0 }", | |
"description": "partition with block", | |
"scope": "ruby" | |
}, | |
"path_from_here": { | |
"prefix": "patfh", | |
"body": "File.join(File.dirname(__FILE__), *%w[${1:rel path here}])", | |
"description": "path_from_here helper", | |
"scope": "ruby" | |
}, | |
"randomize": { | |
"prefix": "ran", | |
"body": "sort_by { rand }", | |
"description": "randomize array", | |
"scope": "ruby" | |
}, | |
"require": { | |
"prefix": "req", | |
"body": "require \"$0\"", | |
"description": "require statement", | |
"scope": "ruby" | |
}, | |
"test unit require": { | |
"prefix": "ts", | |
"body": "require \"test/unit\"\n\nrequire \"tc_${1:test_case_file}\"\nrequire \"tc_${2:test_case_file}\"\n", | |
"description": "Test::Unit require statements", | |
"scope": "ruby" | |
}, | |
"require_gem": { | |
"prefix": "reqg-", | |
"body": "require \"$0\"", | |
"description": "require_gem (legacy)", | |
"scope": "ruby" | |
}, | |
"Benchmark report": { | |
"prefix": "rep", | |
"body": "results.report(\"${1:name}:\") { TESTS.times { $0 } }", | |
"description": "Benchmark report block", | |
"scope": "ruby" | |
}, | |
"reverse_each": { | |
"prefix": "reve", | |
"body": "reverse_each { |${1:e}| $0 }", | |
"description": "reverse_each with block", | |
"scope": "ruby" | |
}, | |
"scan": { | |
"prefix": "sca", | |
"body": "scan(/${1:pattern}/) { |${2:match}| $0 }", | |
"description": "scan with block", | |
"scope": "ruby" | |
}, | |
"singleton_class": { | |
"prefix": "sinc", | |
"body": "class << self; self end", | |
"description": "singleton_class helper", | |
"scope": "ruby" | |
}, | |
"sort": { | |
"prefix": "sor", | |
"body": "sort { |a, b| $0 }", | |
"description": "sort with block", | |
"scope": "ruby" | |
}, | |
"sort_by": { | |
"prefix": "sorb", | |
"body": "sort_by { |${1:e}| $0 }", | |
"description": "sort_by with block", | |
"scope": "ruby" | |
}, | |
"Rake task": { | |
"prefix": "tas", | |
"body": "desc \"${1:Task description}\"\ntask :${2:${3:task_name} => ${4:[:${5:dependent, :tasks}]}} do\n\t$0\nend", | |
"description": "Rake task definition", | |
"scope": "ruby" | |
}, | |
"unix_filter": { | |
"prefix": "unif", | |
"body": "ARGF.each_line$1 do |${2:line}|\n\t$0\nend", | |
"description": "Unix filter pattern", | |
"scope": "ruby" | |
}, | |
"usage_if": { | |
"prefix": "usai", | |
"body": "if ARGV.$1\n\tabort \"Usage: #{\\$PROGRAM_NAME} ${2:ARGS_GO_HERE}\"\nend", | |
"description": "usage_if helper", | |
"scope": "ruby" | |
}, | |
"usage_unless": { | |
"prefix": "usau", | |
"body": "unless ARGV.$1\n\tabort \"Usage: #{\\$PROGRAM_NAME} ${2:ARGS_GO_HERE}\"\nend", | |
"description": "usage_unless helper", | |
"scope": "ruby" | |
}, | |
"when": { | |
"prefix": "when", | |
"body": "when ${1:condition}\n\t$0", | |
"description": "when clause", | |
"scope": "ruby" | |
}, | |
"xmlread": { | |
"prefix": "xml-", | |
"body": "REXML::Document.new(File.read(${1:\"${2:path/to/file}\"}))", | |
"description": "xmlread helper", | |
"scope": "ruby" | |
}, | |
"xpath": { | |
"prefix": "xpa", | |
"body": "elements.each(${1:\"${2://XPath}\"}) do |${3:node}|\n\t$0\nend", | |
"description": "xpath with block", | |
"scope": "ruby" | |
}, | |
"zip": { | |
"prefix": "zip", | |
"body": "zip(${1:enums}) { |${2:row}| $0 }", | |
"description": "zip with block", | |
"scope": "ruby" | |
}, | |
"yields comment": { | |
"prefix": "y", | |
"body": " :yields: ${0:arguments}", | |
"description": "YARD yields tag", | |
"scope": "ruby.comment" | |
}, | |
"ERB output after tag": { | |
"prefix": ">=", | |
"body": "><%= $1 %>", | |
"description": "ERB output after tag", | |
"scope": "text.html.erb" | |
}, | |
"ERB output after quote": { | |
"prefix": "\"=", | |
"body": "\"<%= $1 %>", | |
"description": "ERB output after quote", | |
"scope": "text.html.erb" | |
}, | |
"ERB execution after tag": { | |
"prefix": ">-", | |
"body": "><% $1 %>", | |
"description": "ERB execution after tag", | |
"scope": "text.html.erb" | |
}, | |
"ERB execution after quote": { | |
"prefix": "\"-", | |
"body": "\"<% $1 %>", | |
"description": "ERB execution after quote", | |
"scope": "text.html.erb" | |
}, | |
"Hash marker": { | |
"prefix": "#", | |
"body": "# => ", | |
"description": "Hash rocket marker", | |
"scope": "ruby" | |
}, | |
"Magic comment": { | |
"prefix": "fsl", | |
"body": "# frozen_string_literal: true", | |
"description": "Add frozen_string_literal magic comment", | |
"scope": "ruby" | |
}, | |
"Nocov": { | |
"prefix": "nocov", | |
"body": [ | |
"# :nocov:", | |
"$1", | |
"# :nocov:" | |
], | |
"description": "SimpleCov nocov block", | |
"scope": "ruby" | |
}, | |
"Class inheritance": { | |
"prefix": "clai", | |
"body": [ | |
"class $1 < $2", | |
" $3", | |
"end" | |
], | |
"description": "Class with inheritance", | |
"scope": "ruby" | |
}, | |
"RSpec.shared_examples": { | |
"prefix": "Rsx", | |
"body": [ | |
"RSpec.shared_examples \"$1\" do", | |
" $2", | |
"end$3" | |
], | |
"description": "RSpec shared examples block", | |
"scope": "ruby" | |
}, | |
"shared_examples": { | |
"prefix": "sx", | |
"body": [ | |
"shared_examples \"$1\" do", | |
" $2", | |
"end$3" | |
], | |
"description": "RSpec shared examples block (without RSpec namespace)", | |
"scope": "ruby" | |
}, | |
"RSpec.shared_context": { | |
"prefix": "Rsctx", | |
"body": [ | |
"RSpec.shared_context \"$1\" do", | |
" $2", | |
"end$3" | |
], | |
"description": "RSpec shared context block", | |
"scope": "ruby" | |
}, | |
"shared_context": { | |
"prefix": "sctx", | |
"body": [ | |
"shared_context \"$1\" do", | |
" $2", | |
"end$3" | |
], | |
"description": "RSpec shared context block (without RSpec namespace)", | |
"scope": "ruby" | |
}, | |
"RSpec.describe": { | |
"prefix": "Rsdes", | |
"body": [ | |
"RSpec.describe $1 do", | |
" $2", | |
"end" | |
], | |
"description": "RSpec describe block", | |
"scope": "ruby" | |
}, | |
"RSpec.describe with type": { | |
"prefix": "Rsdt", | |
"body": [ | |
"RSpec.describe $1, type: :$2 do", | |
" $3", | |
"end" | |
], | |
"description": "RSpec describe block with type", | |
"scope": "ruby" | |
}, | |
"Rspec let - 1 line": { | |
"prefix": "rle", | |
"body": "let(:$1) { $2 }$3", | |
"description": "RSpec let (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec let - n line": { | |
"prefix": "rlem", | |
"body": [ | |
"let(:$1) do", | |
" $2", | |
"end$3" | |
], | |
"description": "RSpec let (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec let! - 1 line": { | |
"prefix": "rleb", | |
"body": "let!(:$1) { $2 }$3", | |
"description": "RSpec let! (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec let! - n line": { | |
"prefix": "rlebm", | |
"body": [ | |
"let!(:$1) do", | |
" $2", | |
"end$3" | |
], | |
"description": "RSpec let! (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec describe": { | |
"prefix": "descrb", | |
"body": [ | |
"describe \"$1\" do", | |
" $2", | |
"end$3" | |
], | |
"description": "RSpec describe block", | |
"scope": "ruby" | |
}, | |
"Rspec context": { | |
"prefix": "contx", | |
"body": [ | |
"context \"$1\" do", | |
" $2", | |
"end$3" | |
], | |
"description": "RSpec context block", | |
"scope": "ruby" | |
}, | |
"Rspec allow": { | |
"prefix": "ral", | |
"body": "allow($1).to receive(:$2).and_return $3", | |
"description": "RSpec allow to receive", | |
"scope": "ruby" | |
}, | |
"Rspec allow with params": { | |
"prefix": "rarw", | |
"body": "allow($1).to receive(:$2).with($3).and_return $4", | |
"description": "RSpec allow to receive with params", | |
"scope": "ruby" | |
}, | |
"Rspec allow to receive messages": { | |
"prefix": "rams", | |
"body": "allow($1).to receive_messages($2)$3", | |
"description": "RSpec allow to receive multiple messages", | |
"scope": "ruby" | |
}, | |
"Rspec allow_any_instance_of": { | |
"prefix": "raio", | |
"body": "allow_any_instance_of($1).to receive(:$2).and_return $3", | |
"description": "RSpec allow_any_instance_of", | |
"scope": "ruby" | |
}, | |
"Rspec allow_any_instance_of receive messages": { | |
"prefix": "raims", | |
"body": "allow_any_instance_of($1).to receive_messages($2)$3", | |
"description": "RSpec allow_any_instance_of with multiple messages", | |
"scope": "ruby" | |
}, | |
"Rspec expect to receive": { | |
"prefix": "rer", | |
"body": "expect($1).to receive(:$2).and_return $3", | |
"description": "RSpec expect to receive", | |
"scope": "ruby" | |
}, | |
"Rspec expect to receive with params": { | |
"prefix": "rew", | |
"body": "expect($1).to receive(:$2).with($3).and_return $4", | |
"description": "RSpec expect to receive with params", | |
"scope": "ruby" | |
}, | |
"Rspec before - 1 line": { | |
"prefix": "rbef", | |
"body": "before { $1 }$2", | |
"description": "RSpec before hook (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec before - n lines": { | |
"prefix": "rbem", | |
"body": [ | |
"before do", | |
" $1", | |
"end$2" | |
], | |
"description": "RSpec before hook (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec after - 1 line": { | |
"prefix": "raf", | |
"body": "after { $1 }$2", | |
"description": "RSpec after hook (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec after - n lines": { | |
"prefix": "ram", | |
"body": [ | |
"after do", | |
" $1", | |
"end$2" | |
], | |
"description": "RSpec after hook (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec subject - 1 line": { | |
"prefix": "rsub", | |
"body": "subject { $1 }$2", | |
"description": "RSpec subject (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec subject - n line": { | |
"prefix": "rsum", | |
"body": [ | |
"subject do", | |
" $1", | |
"end$2" | |
], | |
"description": "RSpec subject (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it should - 1 line": { | |
"prefix": "itsh", | |
"body": "it { should $1 }$2", | |
"description": "RSpec it should (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it should - n lines": { | |
"prefix": "itshm", | |
"body": [ | |
"it \"$1\" do", | |
" should $2", | |
"end$3" | |
], | |
"description": "RSpec it should (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it should - no comment": { | |
"prefix": "itshn", | |
"body": [ | |
"it do", | |
" should $1", | |
"end$2" | |
], | |
"description": "RSpec it should (no comment)", | |
"scope": "ruby" | |
}, | |
"Rspec it should not - 1 line": { | |
"prefix": "itnsh", | |
"body": "it { should_not $1 }$2", | |
"description": "RSpec it should_not (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it should not - n lines": { | |
"prefix": "itnshm", | |
"body": [ | |
"it \"$1\" do", | |
" should_not $2", | |
"end$3" | |
], | |
"description": "RSpec it should_not (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it should not - no comment": { | |
"prefix": "itnshn", | |
"body": [ | |
"it do", | |
" should_not $1", | |
"end$2" | |
], | |
"description": "RSpec it should_not (no comment)", | |
"scope": "ruby" | |
}, | |
"Rspec it expect 1 line": { | |
"prefix": "ite", | |
"body": "it { expect($1).to $2 }$3", | |
"description": "RSpec it expect (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it expect 1 line with {}": { | |
"prefix": "itec", | |
"body": "it { expect{$1}.to $2 }$3", | |
"description": "RSpec it expect with block (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it expect n lines": { | |
"prefix": "item", | |
"body": [ | |
"it \"$1\" do", | |
" expect($2).to $3", | |
"end$4" | |
], | |
"description": "RSpec it expect (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it expect n lines with {}": { | |
"prefix": "itemc", | |
"body": [ | |
"it \"$1\" do", | |
" expect { $2 }.to $3", | |
"end$4" | |
], | |
"description": "RSpec it expect with block (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it expect no comment": { | |
"prefix": "iten", | |
"body": [ | |
"it do", | |
" expect($1).to $2", | |
"end$3" | |
], | |
"description": "RSpec it expect (no comment)", | |
"scope": "ruby" | |
}, | |
"Rspec it expect no comment with {}": { | |
"prefix": "itenc", | |
"body": [ | |
"it do", | |
" expect { $1 }.to $2", | |
"end$3" | |
], | |
"description": "RSpec it expect with block (no comment)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected to - 1 line": { | |
"prefix": "itie", | |
"body": "it { is_expected.to $1 }$2", | |
"description": "RSpec it is_expected.to (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected to - n lines": { | |
"prefix": "itiem", | |
"body": [ | |
"it \"$1\" do", | |
" is_expected.to $2", | |
"end$3" | |
], | |
"description": "RSpec it is_expected.to (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected to - no comment": { | |
"prefix": "itien", | |
"body": [ | |
"it do", | |
" is_expected.to $1", | |
"end$2" | |
], | |
"description": "RSpec it is_expected.to (no comment)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected to eq - 1 line": { | |
"prefix": "itieq", | |
"body": "it { is_expected.to eq $1 }$2", | |
"description": "RSpec it is_expected.to eq (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected to eq - n lines": { | |
"prefix": "itieqm", | |
"body": [ | |
"it \"$1\" do", | |
" is_expected.to eq $2", | |
"end$3" | |
], | |
"description": "RSpec it is_expected.to eq (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected to eq - no comment": { | |
"prefix": "itieqn", | |
"body": [ | |
"it do", | |
" is_expected.to eq $1", | |
"end$2" | |
], | |
"description": "RSpec it is_expected.to eq (no comment)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected not to - 1 line": { | |
"prefix": "itine", | |
"body": "it { is_expected.not_to $1 }$2", | |
"description": "RSpec it is_expected.not_to (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected not to - n lines": { | |
"prefix": "itinem", | |
"body": [ | |
"it \"$1\" do", | |
" is_expected.not_to $2", | |
"end$3" | |
], | |
"description": "RSpec it is_expected.not_to (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected not to - no comment": { | |
"prefix": "itinen", | |
"body": [ | |
"it do", | |
" is_expected.not_to $1", | |
"end$2" | |
], | |
"description": "RSpec it is_expected.not_to (no comment)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected not to eq - 1 line": { | |
"prefix": "itneq", | |
"body": "it { is_expected.not_to eq $1 }$2", | |
"description": "RSpec it is_expected.not_to eq (one-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected not to eq - n lines": { | |
"prefix": "itneqm", | |
"body": [ | |
"it \"$1\" do", | |
" is_expected.not_to eq $2", | |
"end$3" | |
], | |
"description": "RSpec it is_expected.not_to eq (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected not to eq - no comment": { | |
"prefix": "itneqn", | |
"body": [ | |
"it do", | |
" is_expected.not_to eq $1", | |
"end$2" | |
], | |
"description": "RSpec it is_expected.not_to eq (no comment)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected to validate presence of - 1 line": { | |
"prefix": "itvp", | |
"body": "it { is_expected.to validate_presence_of :$1 }$2", | |
"description": "RSpec validate presence (one-line)", | |
"scope": "ruby" | |
}, | |
"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" | |
], | |
"description": "RSpec validate presence (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected to validate presence of - no comment": { | |
"prefix": "itvpn", | |
"body": [ | |
"it do", | |
" is_expected.to validate_presence_of :$1", | |
"end$2" | |
], | |
"description": "RSpec validate presence (no comment)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected to not validate presence of - 1 line": { | |
"prefix": "itnvp", | |
"body": "it { is_expected.not_to validate_presence_of :$1 }$2", | |
"description": "RSpec not validate presence (one-line)", | |
"scope": "ruby" | |
}, | |
"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" | |
], | |
"description": "RSpec not validate presence (multi-line)", | |
"scope": "ruby" | |
}, | |
"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" | |
], | |
"description": "RSpec not validate presence (no comment)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected to validate uniqueness of - 1 line": { | |
"prefix": "itvu", | |
"body": "it { is_expected.to validate_uniqueness_of $1 }$2", | |
"description": "RSpec validate uniqueness (one-line)", | |
"scope": "ruby" | |
}, | |
"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" | |
], | |
"description": "RSpec validate uniqueness (multi-line)", | |
"scope": "ruby" | |
}, | |
"Rspec it is expected to validate uniqueness of - no comment": { | |
"prefix": "itvun", | |
"body": [ | |
"it do", | |
" is_expected.to validate_uniqueness_of $1", | |
"end$2" | |
], | |
"description": "RSpec validate uniqueness (no comment)", | |
"scope": "ruby" | |
}, | |
"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", | |
"description": "RSpec validate inclusion (one-line)", | |
"scope": "ruby" | |
}, | |
"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" | |
], | |
"description": "RSpec validate inclusion (multi-line)", | |
"scope": "ruby" | |
}, | |
"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" | |
], | |
"description": "RSpec validate inclusion (no comment)", | |
"scope": "ruby" | |
}, | |
"Rspec its(:attr) is expected to eq": { | |
"prefix": "itsieq", | |
"body": "its(:$1) { is_expected.to eq $2 }$3", | |
"description": "RSpec its with is_expected.to eq", | |
"scope": "ruby" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment