Permalink
Browse files

add more snippets and split testunit from ruby.snippets

  • Loading branch information...
1 parent 1ebd6e7 commit b6d531a7e144d0bd210b3185b4f708dffc3601a9 @kaichen committed May 23, 2009
@@ -43,7 +43,7 @@ snippet =jsit
snippet =sslt
<%= stylesheet_link_tag "${1:stylesheet_filename}" %>
-snippet it
+snippet imaget
<%= image_tag "${1:image_path}" %>
snippet lt
<%= link_to '${1:caption}', ${2:path} %>
@@ -33,3 +33,4 @@ snippet Fw
Factory(:${1:factory}, :${2})
snippet Fbw
Factory.build(:${1:factory}, :${2})
+
View
@@ -6,7 +6,8 @@ snippet logd
logger.debug { "${1:message}" }${2}
snippet logw
logger.warn { "${1:message}" }${2}
-snippet logd
+snippet loge
logger.error { "${1:message}" }${2}
snippet logf
logger.fatal { "${1:message}" }${2}
+
@@ -8,3 +8,4 @@ snippet wants
wants.${1:js|json|xml|html}${2}
snippet flash
flash[:${1:notice}] = "${2}"
+
@@ -37,3 +37,4 @@ snippet vlength
validates_length_of :${1:attribute}, ${2}
snippet vnumeric
validates_numericality_of :${1:attribute}
+
View
@@ -1,6 +1,8 @@
# rspec
snippet spechelper
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')${1}
+
+# describe
snippet des
describe ${1:description}" do
${2}
@@ -26,14 +28,18 @@ snippet desd
end
end
-snippet before
+
+# before & after
+snippet before-
before(:${1:each}) do
${2}
end
-snippet after
+snippet after-
after(:${1:each}) do
${2}
end
+
+# it should
snippet it
it "should ${1:description}" do
${2}
@@ -46,25 +52,10 @@ snippet itshbe
it "should ${1:description}" do
${2:model}.should be_${3}
end
-snippet atsh
- it "should ${1:description}" do
- ${2:model}.${3:attr}.should ${4}
- end
-snippet atshbe
- it "should ${1:description}" do
- ${2:model}.${3:attr}.should be_${4}
- end
# matchers
snippet sheq
${1:targe}.should == ${2}
snippet shbe
${1:target}.should be_${2:result}
-# rspec-rails
-snippet itres
- it { response.should be_${1} }
-snippet itrend
- it { response.should render_template(:${1}) }
-snippet itred
- it { response.should redirect_to(${1}) }
@@ -0,0 +1,9 @@
+# Rspec Rails
+
+snippet itres
+ it { response.should be_${1} }
+snippet itrend
+ it { response.should render_template(:${1}) }
+snippet itred
+ it { response.should redirect_to(${1}) }
+
@@ -0,0 +1,58 @@
+# Shoulda macros for Rspec
+
+# association
+snippet itshbt shoulda macros for rspec: should_belong_to
+ it { should_belong_to :${1:association} }
+snippet itshhabtm shoulda macros for rspec: should_have_and_belong_to_many
+ it { should_have_and_belong_to_many :${1:association} }
+snippet itshhm shoulda macros for rspec: should_have_many
+ it { should_have_many :${1:association} }
+snippet itshho shoulda macros for rspec: should_have_one
+ it { should_have_one :${1:association} }
+
+# assign_to
+snippet itshat
+ it { should assign_to(:${1:model}) }
+snippet itshnat
+ it { should_not assign_to(:${1:model}) }
+snippet itshatwk
+ it { should assign_to(:${1:model}).with_kind_of(${2:klass}) }
+snippet itshatw
+ it { should assign_to(:${1:model}).with(@${2}) }
+
+# filter_param
+snippet itshfp
+ it { should filter_param(:${1:field}) }
+
+# layout
+snippet itshrwl
+ it { should render_with_layout }
+snippet itshnrwl
+ it { should_not render_with_layout }
+
+# respond
+snippet itshrepw
+ it { should respond_with(:${1:success|redirect|missing|error}) }
+snippet itshrepwc
+ it { should respond_with_content_type(:${1:xml|csv|atom|yaml|text}) }
+
+# route
+snippet itshroute
+ it { should route(:${1:method}, "/${2:path}").to(:action => :${3:action}) }
+
+# session
+snippet itshsets
+ it { should set_session(:${1:message}) }
+snippet itshsetst
+ it { should set_session(:${1:key}).to(${2:value}) }
+snippet itshnsets
+ it { should_not set_session(:${1:key}) }
+
+# flash
+snippet itshsetfl
+ it { should set_the_flash }
+snippet itshsetflt
+ it { should set_the_flash.to(/${1:message}/i) }
+snippet itshnsetfl
+ it { should_not set_the_flash }
+
@@ -0,0 +1,48 @@
+# Shoulda macros for Rspec
+
+# assign_to
+snippet itshat
+ it { should assign_to(:${1:model}) }
+snippet itshnat
+ it { should_not assign_to(:${1:model}) }
+snippet itshatwk
+ it { should assign_to(:${1:model}).with_kind_of(${2:klass}) }
+snippet itshatw
+ it { should assign_to(:${1:model}).with(@${2}) }
+
+# filter_param
+snippet itshfp
+ it { should filter_param(:${1:field}) }
+
+# layout
+snippet itshrwl
+ it { should render_with_layout }
+snippet itshnrwl
+ it { should_not render_with_layout }
+
+# respond
+snippet itshrepw
+ it { should respond_with(:${1:success|redirect|missing|error}) }
+snippet itshrepwc
+ it { should respond_with_content_type(:${1:xml|csv|atom|yaml|text}) }
+
+# route
+snippet itshroute
+ it { should route(:${1:method}, "/${2:path}").to(:action => :${3:action}) }
+
+# session
+snippet itshsets
+ it { should set_session(:${1:message}) }
+snippet itshsetst
+ it { should set_session(:${1:key}).to(${2:value}) }
+snippet itshnsets
+ it { should_not set_session(:${1:key}) }
+
+# flash
+snippet itshsetfl
+ it { should set_the_flash }
+snippet itshsetflt
+ it { should set_the_flash.to(/${1:message}/i) }
+snippet itshnsetfl
+ it { should_not set_the_flash }
+
@@ -0,0 +1,12 @@
+# Shoulda macros for Rspec
+
+# association
+snippet itshbt shoulda macros for rspec: should_belong_to
+ it { should_belong_to :${1:association} }
+snippet itshhabtm shoulda macros for rspec: should_have_and_belong_to_many
+ it { should_have_and_belong_to_many :${1:association} }
+snippet itshhm shoulda macros for rspec: should_have_many
+ it { should_have_many :${1:association} }
+snippet itshho shoulda macros for rspec: should_have_one
+ it { should_have_one :${1:association} }
+
View
@@ -1,7 +1,7 @@
# Shoulda
# macros
-snippet shc
+snippet shc shoulda macros should_change
should_change "${1:expression}"
snippet shcb
should_change "${1:expression}", :by => ${2:by}
View
@@ -0,0 +1,56 @@
+# TestUnit
+
+snippet tc
+ require \"test/unit\"
+
+ require \"${1:library_file_name}\"
+
+ class Test${2:$1} < Test::Unit::TestCase
+ def test_${3:case_name}
+ ${4}
+ end
+ end
+snippet ts
+ require \"test/unit\"
+
+ require \"tc_${1:test_case_file}\"
+ require \"tc_${2:test_case_file}\"${3}
+snippet as
+ assert(${1:test}, \"${2:Failure message.}\")${3}
+snippet ase
+ assert_equal(${1:expected}, ${2:actual})${3}
+snippet asne
+ assert_not_equal(${1:unexpected}, ${2:actual})${3}
+snippet asid
+ assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4}
+snippet asio
+ assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3}
+snippet asko
+ assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3}
+snippet asn
+ assert_nil(${1:instance})${2}
+snippet asnn
+ assert_not_nil(${1:instance})${2}
+snippet asm
+ assert_match(/${1:expected_pattern}/, ${2:actual_string})${3}
+snippet asnm
+ assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3}
+snippet aso
+ assert_operator(${1:left}, :${2:operator}, ${3:right})${4}
+snippet asr
+ assert_raise(${1:Exception}) { ${2} }
+snippet asnr
+ assert_nothing_raised(${1:Exception}) { ${2} }
+snippet asrt
+ assert_respond_to(${1:object}, :${2:method})${3}
+snippet ass assert_same(..)
+ assert_same(${1:expected}, ${2:actual})${3}
+snippet ass assert_send(..)
+ assert_send([${1:object}, :${2:message}, ${3:args}])${4}
+snippet asns
+ assert_not_same(${1:unexpected}, ${2:actual})${3}
+snippet ast
+ assert_throws(:${1:expected}) { ${2} }
+snippet asnt
+ assert_nothing_thrown { ${1} }
+
Oops, something went wrong.

0 comments on commit b6d531a

Please sign in to comment.