Skip to content
Browse files

Update expect() and expect { } snippets

  • Loading branch information...
1 parent 5557dff commit 0dc183f62c43c9f094c7113decfe48d101c3c73d @timstott timstott committed with ashmoran Nov 3, 2013
View
54 README.md
@@ -9,21 +9,69 @@ Clone the repository in your Sublime Text 2 Pacakges directory.
Snippets
========
-
+## Definitons
```Ruby
# desc
describe 'description' do
...
end
-```
-```Ruby
# con
context 'description' do
...
end
+
+# it
+it 'description' do
+ ...
+end
+
+# iti
+it { should ... }
+```
+
+## Fabricators
+```Ruby
+# letf
+let(:fabricator) { Fabricate.build(:fabricator) }
```
+## Expectations
+All `exepect` snippets are prefixed with `exp`
+
+```Ruby
+# expeql
+expect(subject).to eql(value)
+
+# expinclude
+expect(subject).to include(element)
+
+# exphave
+expect(subject).to have(num).items
+
+# expbenil
+expect(subject).to be_nil
+
+# expbeclose
+expect(subject).to be_close(result, tolerance)
+
+# expraise
+expect { action }.to raise_error(Error)
+
+# expmatch
+expect(subject).to match(/regexp/)
+
+# expdo
+expect do
+ action
+end.to matcher
+
+# expexist
+expect(subject).to exist
+```
+
+## Mocking
+
Features
========
* RSpec.sublime-build for executing unit tests for the active module via the S2 *Build* command
View
6 Snippets/expect-one-line.sublime-snippet
@@ -0,0 +1,6 @@
+<snippet>
+ <content><![CDATA[expect(${1:subject}).to ${2:matcher}$0]]></content>
+ <tabTrigger>exp</tabTrigger>
+ <scope>source.ruby.rspec</scope>
+ <description>expect(subject).to something</description>
+</snippet>
View
6 Snippets/expect-to-be-close.sublime-snippet
@@ -0,0 +1,6 @@
+<snippet>
+ <content><![CDATA[expect(${1:subject}).to be_close(${2:result}, ${3:tolerance})$0]]></content>
+ <tabTrigger>expbeclose</tabTrigger>
+ <scope>source.ruby.rspec</scope>
+ <description>expect(obj) be_close</description>
+</snippet>
View
6 Snippets/expect-to-be-nil.sublime-snippet
@@ -0,0 +1,6 @@
+<snippet>
+ <content><![CDATA[expect(${1:subject}).to be_nil$0]]></content>
+ <tabTrigger>expbenil</tabTrigger>
+ <scope>source.ruby.rspec</scope>
+ <description>expect(obj) be_nil</description>
+</snippet>
View
6 Snippets/expect-to-be.sublime-snippet
@@ -0,0 +1,6 @@
+<snippet>
+ <content><![CDATA[expect(${1:subject}).to be$0]]></content>
+ <tabTrigger>expbe</tabTrigger>
+ <scope>source.ruby.rspec</scope>
+ <description>expect(obj) be</description>
+</snippet>
View
9 Snippets/expect-to-block.sublime-snippet
@@ -0,0 +1,9 @@
+<snippet>
+ <content><![CDATA[expect do
+ ${1:action}
+end.to ${2:matcher}$0]]>
+</content>
+ <tabTrigger>expdo</tabTrigger>
+ <scope>source.ruby.rspec</scope>
+ <description>expect do ... end.to something</description>
+</snippet>
View
6 Snippets/expect-to-eql.sublime-snippet
@@ -0,0 +1,6 @@
+<snippet>
+ <content><![CDATA[expect(${1:subject}).to eql(${2:value})$0]]></content>
+ <tabTrigger>expeql</tabTrigger>
+ <scope>source.ruby.rspec</scope>
+ <description>expect(obj) eql(value)</description>
+</snippet>
View
6 Snippets/expect-to-exist.sublime-snippet
@@ -0,0 +1,6 @@
+<snippet>
+ <content><![CDATA[expect(${1:subject}).to exist$0]]></content>
+ <tabTrigger>expexist</tabTrigger>
+ <scope>source.ruby.rspec</scope>
+ <description>expect(obj) exist</description>
+</snippet>
View
6 Snippets/expect-to-have.sublime-snippet
@@ -0,0 +1,6 @@
+<snippet>
+ <content><![CDATA[expect(${1:subject}).to have(${2:num}).${3:items}$0]]></content>
+ <tabTrigger>exphave</tabTrigger>
+ <scope>source.ruby.rspec</scope>
+ <description>expect(obj) have(num)</description>
+</snippet>
View
6 Snippets/expect-to-include.sublime-snippet
@@ -0,0 +1,6 @@
+<snippet>
+ <content><![CDATA[expect(${1:subject}).to include(${2:element})$0]]></content>
+ <tabTrigger>expinclude</tabTrigger>
+ <scope>source.ruby.rspec</scope>
+ <description>expect(obj) include(element)</description>
+</snippet>
View
6 Snippets/expect-to-match.sublime-snippet
@@ -0,0 +1,6 @@
+<snippet>
+ <content><![CDATA[expect(${1:subject}).to match(/${2:regexp}/)$0]]></content>
+ <tabTrigger>expmatch</tabTrigger>
+ <scope>source.ruby.rspec</scope>
+ <description>expect(obj) match</description>
+</snippet>
View
6 Snippets/expect-to-raise.sublime-snippet
@@ -0,0 +1,6 @@
+<snippet>
+ <content><![CDATA[expect { ${1:action} }.to raise_error(${2:Error})$0]]></content>
+ <tabTrigger>expraise</tabTrigger>
+ <scope>source.ruby.rspec</scope>
+ <description>expect { action } raise</description>
+</snippet>
View
16 Snippets/expect_be.tmSnippet
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>content</key>
- <string>expect(${1:subject}).to be$0</string>
- <key>name</key>
- <string>expect(subject) be</string>
- <key>scope</key>
- <string>source.ruby.rspec</string>
- <key>tabTrigger</key>
- <string>be</string>
- <key>uuid</key>
- <string>F401AA03-A119-4965-8677-BDAAE8312F13</string>
-</dict>
-</plist>
View
16 Snippets/expect_be_false.tmSnippet
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>content</key>
- <string>expect(${1:subject}).to be_false$0</string>
- <key>name</key>
- <string>expect(subject) be_false</string>
- <key>scope</key>
- <string>source.ruby.rspec</string>
- <key>tabTrigger</key>
- <string>bf</string>
- <key>uuid</key>
- <string>F401AA03-A119-4965-8677-BDAAE8312F13</string>
-</dict>
-</plist>
View
16 Snippets/expect_be_nil.tmSnippet
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>content</key>
- <string>expect(${1:subject}).to be_nil$0</string>
- <key>name</key>
- <string>expect(subject) be_nil</string>
- <key>scope</key>
- <string>source.ruby.rspec</string>
- <key>tabTrigger</key>
- <string>bn</string>
- <key>uuid</key>
- <string>F401AA03-A119-4965-8677-BDAAE8312F13</string>
-</dict>
-</plist>
View
16 Snippets/expect_be_true.tmSnippet
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>content</key>
- <string>expect(${1:subject}).to be_true$0</string>
- <key>name</key>
- <string>expect(subject) be_true</string>
- <key>scope</key>
- <string>source.ruby.rspec</string>
- <key>tabTrigger</key>
- <string>bt</string>
- <key>uuid</key>
- <string>F401AA03-A119-4965-8677-BDAAE8312F13</string>
-</dict>
-</plist>
View
16 Snippets/expect_eql.tmSnippet
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>content</key>
- <string>expect(${1:subject}).to eql(${2:value})$0</string>
- <key>name</key>
- <string>expect eql</string>
- <key>scope</key>
- <string>source.ruby.rspec</string>
- <key>tabTrigger</key>
- <string>eql</string>
- <key>uuid</key>
- <string>0F03467B-16F7-4764-99C6-B7F123E95E5C</string>
-</dict>
-</plist>
View
16 Snippets/expect_exist.tmSnippet
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>content</key>
- <string>expect(${1:subject}).to exist$0</string>
- <key>name</key>
- <string>expect(subject) exist</string>
- <key>scope</key>
- <string>source.ruby.rspec</string>
- <key>tabTrigger</key>
- <string>exist</string>
- <key>uuid</key>
- <string>F401AA03-A119-4965-8677-BDAAE8312F13</string>
-</dict>
-</plist>
View
16 Snippets/expect_have.tmSnippet
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>content</key>
- <string>expect(${1:subject}).to have(${2:num}).${3:things}$0</string>
- <key>name</key>
- <string>expect(subject) have</string>
- <key>scope</key>
- <string>source.ruby.rspec</string>
- <key>tabTrigger</key>
- <string>have</string>
- <key>uuid</key>
- <string>42B1F497-2BAF-425D-9829-57E35456E7FE</string>
-</dict>
-</plist>
View
16 Snippets/expect_include.tmSnippet
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>content</key>
- <string>expect(${1:subject}).to include(${2})$0</string>
- <key>name</key>
- <string>expect(subject) include(element)</string>
- <key>scope</key>
- <string>source.ruby.rspec</string>
- <key>tabTrigger</key>
- <string>inc</string>
- <key>uuid</key>
- <string>F401AA03-A119-4965-8677-BDAAE8312F13</string>
-</dict>
-</plist>
View
16 Snippets/expect_match.tmSnippet
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>content</key>
- <string>expect(${1:subject}).to match(/${2:regexp}/)$0</string>
- <key>name</key>
- <string>expect(subject) match</string>
- <key>scope</key>
- <string>source.ruby.rspec</string>
- <key>tabTrigger</key>
- <string>match</string>
- <key>uuid</key>
- <string>D6CE8D1B-16EC-4E0E-8089-62F193D3D048</string>
-</dict>
-</plist>
View
16 Snippets/expect_raise.tmSnippet
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>content</key>
- <string>expect { raise ${1:Error} }.to raise_error(${2:Error})$0</string>
- <key>name</key>
- <string>expect raise_error</string>
- <key>scope</key>
- <string>source.ruby.rspec</string>
- <key>tabTrigger</key>
- <string>raise</string>
- <key>uuid</key>
- <string>813263F0-A2C0-465F-A617-69ECBAF8F7DD</string>
-</dict>
-</plist>

0 comments on commit 0dc183f

Please sign in to comment.
Something went wrong with that request. Please try again.