追è¨2ï¼2015/09/08ï¼ããããããã¨ã«ãæªã ã«ãã®è¨äºãããã¯ãã¼ã¯ãã¦ãã ããæ¹ãããã£ãããã¾ããã2008å¹´ã«æ¸ããè¨äºãªã®ã§ã注æä¸ãããå
容ã¯ã¢ãããã¼ããã¦ãã¾ãããç§èªèº«ã¯ãã§ã«Rubyã使ã£ã¦ãã¾ããã
追è¨ï¼å¤ãæ
å ±ã§ãã®ã§ãè¨äºã®æ¥ä»ã¨ã使ãã®RSpecã®ãã¼ã¸ã§ã³ãè¦æ¯ã¹ã¦ãåèç¨åº¦ã«ã覧ãã ããã大é¨åã¯éç¨ããã¯ãã§ããã
Matcherããã¡ãã¡èª¿ã¹ãã®ãé¢åã«ãªã£ã¦ã公式のリファレンスマニュアルã¯ä¸è¦§æ§ãä½ããããèªåã§ä¸è¦§è¡¨ãä½ã£ãã
RSpecãã®ãã®ã«ã¤ãã¦ã¯ãスはスペックのス 【第 1 回】 RSpec の概要と、RSpec on Rails (モデル編)ãªã©ãã©ããããã®ãã¡RSpec on Railsçãä½ãäºå®ã
åå | not((should_not ã§ä½¿ãããã©ããã¨ããæå³ã)) |
æå³ã»æ©è½ |
---|---|---|
== |
â | ==æ¼ç®åãå©ç¨ãã¦æ¯è¼ãããex.)"foo".should == "foo" ã |
be_true |
â | çå½å¤(ç) |
be_false |
â | çå½å¤(å½ï¼ |
be_nil |
â | nil? ãç |
be_empty |
â | Array#empty? ãç |
be_è¿°èª(*args) |
â | be_emptyã®ä¸è¬å½¢ãè¿°èªã¡ã½ããã®?ãé¤ããé¨åãæå®ãã¦ããããtrue ãè¿ã |
be_an_instance_of(Class) |
â | obj.instance_of?(Class) ãtrue |
be_a_kind_of(Class) |
â | obj.kind_of?(Class) ãtrue |
have_key(key) |
â | obj.has_key?(key) ãtrue |
be_close(E,D) |
â | æ°å¤ãã¼ã¿ããE±D ã®ç¯å²ã«åã¾ã£ã¦ãã |
change(obj,msg,&blk) |
â | Proc ãªãã¸ã§ã¯ããããããã¯ã®å¤ãå¤åããã |
eql(expected) |
â | eql? ã§æ¯è¼ãã¦çãã |
equal(expected) |
â | equal? ã§æ¯è¼ãã¦çãã |
have(n).name |
â | ã³ã¬ã¯ã·ã§ã³ãªãã¸ã§ã¯ãããnåã®è¦ç´ ãæã£ã¦ãã(name ã®é¨åã¯ä»»æãitemsã¨ãã«ããã¨ãè±èªã¨ãã¦èªç¶ã£ã½ã)ã |
have_exactly(n).name |
à | have(n) ã¨åã |
have_at_least(n).name |
à | ã³ã¬ã¯ã·ã§ã³ãªãã¸ã§ã¯ãããå°ãªãã¨ãnåã®è¦ç´ ãæã£ã¦ãã |
have_at_most(n).name |
à | ã³ã¬ã¯ã·ã§ã³ãªãã¸ã§ã¯ãããå¤ãã¦ãnåã¾ã§ã®è¦ç´ ãæã£ã¦ãã |
include(expected) |
â | ã³ã¬ã¯ã·ã§ã³ãªãã¸ã§ã¯ãããexpected ãè¦ç´ ã¨ãã¦æã£ã¦ãã |
match(regexp) |
â | æ£è¦è¡¨ç¾regexp ã«ããããã |
raise_error() |
â | Proc ãªãã¸ã§ã¯ããä¾å¤ãçºçãã |
raise_error(error) |
â | Proc ãªãã¸ã§ã¯ããä¾å¤error ãçºçãã |
raise_error(error,msg) |
â | Proc ãªãã¸ã§ã¯ããä¾å¤error ããæååmsg ã§çºçãã |
raise_error(error,regexp) |
â | Proc ãªãã¸ã§ã¯ããä¾å¤error ããregexp ã«ãããããæååã§çºçãã |
respond_to(*args) |
â | ãªãã¸ã§ã¯ãããæå®ãããã¡ã½ãããå ¨ã¦æ㤠|
satisfy {ï½eï½ ...} |
â | ãªãã¸ã§ã¯ããããããã¯ãçã«ããï¼ãããã¯ã®å¼æ°ã¨ãã¦ãªãã¸ã§ã¯ãèªèº«ã渡ãããï¼ |
thorw_symbol(sym=nil) |
â | sym ãthrow ããã |