Skip to content

Instantly share code, notes, and snippets.

@elissonmichael
Forked from yuanyan/atom-ruby-snippets.cson
Created November 22, 2018 16:39

Revisions

  1. @yuanyan yuanyan created this gist Mar 4, 2014.
    115 changes: 115 additions & 0 deletions atom-ruby-snippets.cson
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,115 @@
    '.source.ruby':
    '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 $1.new($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'
    'controller_name':
    'prefix': 'conn'
    'body': 'controller_name :${1:controller}'
    'and_raise':
    '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})'
    'and_throw':
    'prefix': 'ant'
    'body': 'and_throw(${1:sym})'
    'and_yield':
    'prefix': 'any'
    'body': 'and_yield(${1:values})'
    'any_number_of_times':
    'prefix': 'annot'
    'body': 'any_number_of_times'
    'at_least':
    'prefix': 'atl'
    'body': 'at_least(${1:n}).times'
    'at_most':
    'prefix': 'atm'
    'body': 'at_most(${1:n}).times'
    'change':
    'prefix': 'ch'
    'body': 'change { $1 }'
    'configure':
    'prefix': 'cnf'
    'body': 'RSpec.configure do |config|\n config.$0\nend'
    'context':
    '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'
    'exactly':
    'prefix': 'ex'
    'body': 'exactly(${1:n}).times'
    'expect':
    'prefix': 'exp'
    'body': 'expect(${1:target}).to'
    'expect with block':
    'prefix': 'expb'
    'body': 'expect { ${1:target} }.to'
    'feature':
    '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}'
    'let':
    'prefix': 'let'
    'body': 'let(:${1:instance}) { $0 }'
    'mock':
    'prefix': 'moc'
    'body': '${1:var} = mock("${2:mock_name}"${3:, :null_object => true})\n$0'
    'mock_model':
    'prefix': 'mm'
    'body': 'mock_model(${1:model})$0'
    'mock_with':
    'prefix': 'mocw'
    'body': 'RSpec::Runner.configure do |config|\n\tconfig.mock_with :${0:mocha|flexmock|rr}\nend'
    'once':
    'prefix': 'on'
    'body': 'once'
    'before':
    'prefix': 'bef'
    'body': 'before(${1::each}) do\n $0\nend'
    'with args':
    'prefix': 'wia'
    'body': 'with(${1})$2'
    'specify':
    'prefix': 'spec'
    'body': 'specify { ${1:behavior} }'
    'stub':
    'prefix': 'stu'
    'body': '${1:double}.stub(:${2:message})$3'
    'subject':
    'prefix': 'subj'
    'body': 'subject(:${1:instance}) { $0 }'
    'after':
    'prefix': 'aft'
    'body': 'after(${1::each}) do\n $0\nend'
    'twice':
    'prefix': 'tw'
    'body': 'twice'