Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ruby Snippets for Atom
'describe (String)':
'prefix': 'des'
'body': 'describe "${1:subject}" do\n $0\nend'
'describe (type)':
'prefix': 'dest'
'body': 'describe ${1:Type} do\n $0\nend'
'describe (type, string)':
'prefix': 'dests'
'body': 'describe ${1:Type}, "${2:description}" do\n $0\nend'
'it (does something)':
'prefix': 'it'
'body': 'it "${1:does something}"${2: do\n $0\nend}'
'Matcher (Custom)':
'prefix': 'matc'
'body': 'class ${1:ReverseTo}\n def initialize($3)\n @$3 = $3\n end\n\n def matches?(actual)\n @actual = actual\n # Satisfy expectation here. Return false or raise an error if it\'s not met.\n ${0:@actual.reverse.should == @$3}\n true\n end\n\n def failure_message_for_should\n "expected #{@actual.inspect} to $2 #{@$3.inspect}, but it didn\'t"\n end\n\n def failure_message_for_should_not\n "expected #{@actual.inspect} not to $2 #{@$3.inspect}, but it did"\n end\nend\n\ndef ${2:reverse_to}(${3:expected})\n $$3)\nend'
'Matcher (DSL)':
'prefix': 'mat'
'body': 'RSpec::Matchers.define :${1:name} do |${2:expected}|\n match do |${3:actual}|\n $3.$1?($2)\n end\nend\n'
'Require spec_helper':
'prefix': 'reqs'
'body': 'require \'spec_helper\'\n\n'
'prefix': 'conn'
'body': 'controller_name :${1:controller}'
'prefix': 'anr'
'body': 'and_raise(${1:exception})'
'and_return with block':
'prefix': 'anrb'
'body': 'and_return { $1 }'
'and_return with args':
'prefix': 'andra'
'body': 'and_return(${1:value})'
'prefix': 'ant'
'body': 'and_throw(${1:sym})'
'prefix': 'any'
'body': 'and_yield(${1:values})'
'prefix': 'annot'
'body': 'any_number_of_times'
'prefix': 'atl'
'body': 'at_least(${1:n}).times'
'prefix': 'atm'
'body': 'at_most(${1:n}).times'
'prefix': 'ch'
'body': 'change { $1 }'
'prefix': 'cnf'
'body': 'RSpec.configure do |config|\n config.$0\nend'
'prefix': 'con'
'body': 'context "${1:context}" do\n $0\nend'
'describe (Controller)':
'prefix': 'desc'
'body': 'require File.expand_path(File.dirname(__FILE__) + \'/../spec_helper\')\n\ndescribe ${1:controller} do\n $0\nend'
'describe (RESTful Controller)':
'prefix': 'desrc'
'body': 'describe ${1:controller}, "${2:GET|POST|PUT|DELETE} ${3:/some/path}${4: with some parameters}" do\n $0\nend'
'prefix': 'ex'
'body': 'exactly(${1:n}).times'
'prefix': 'exp'
'body': 'expect(${1:target}).to'
'expect with block':
'prefix': 'expb'
'body': 'expect { ${1:target} }.to'
'prefix': 'sce'
'body': 'scenario "${1:scenario description}" do\n $0\nend'
'it (does something)':
'prefix': 'its'
'body': 'it "does ${1:do something}"${2: do\n $0\nend}'
'prefix': 'let'
'body': 'let(:${1:instance}) { $0 }'
'prefix': 'moc'
'body': '${1:var} = mock("${2:mock_name}"${3:, :null_object => true})\n$0'
'prefix': 'mm'
'body': 'mock_model(${1:model})$0'
'prefix': 'mocw'
'body': 'RSpec::Runner.configure do |config|\n\tconfig.mock_with :${0:mocha|flexmock|rr}\nend'
'prefix': 'on'
'body': 'once'
'prefix': 'bef'
'body': 'before(${1::each}) do\n $0\nend'
'with args':
'prefix': 'wia'
'body': 'with(${1})$2'
'prefix': 'spec'
'body': 'specify { ${1:behavior} }'
'prefix': 'stu'
'body': '${1:double}.stub(:${2:message})$3'
'prefix': 'subj'
'body': 'subject(:${1:instance}) { $0 }'
'prefix': 'aft'
'body': 'after(${1::each}) do\n $0\nend'
'prefix': 'tw'
'body': 'twice'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.