ãããããRSpec Mock 2.14ã«Test Spyãããããã§...
RSpec Mock 2.14ã«ã¯expectã£ã½ãè¨è¿°ã追å ããã¾ããããhttp://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# Old foo.should_receive(:bar) foo.should_receive(:bar).with(:buzz) foo.should_receive(:bar).exactly(3).times # New expect(foo).to receive(:bar) expect(foo).to receive(:bar).with(:buzz) expect(foo).to receive(:bar).exactly(3).times
ããã ããã¨æã£ã¦ããããDoubleãã¿ã¼ã³ã®Test Spyãå®è£
ããã¦ãã¾ãã(Test Spyã«ã¤ãã¦ã¯ãæ¥æ¬èªã 㨠http://goyoki.hatenablog.com/entry/20120301/1330608789 ã® Test Spyãåããããããã)å¾
ã£ã¦ã¾ãããï¼ï¼(ããããã¦ãundocumentedã ã£ãã ãã§ãå
ã
å®è£
ããã¦ã¾ããããï¼)
以ä¸ã¯ãhttp://myronmars.to/n/dev-blog/2013/07/rspec-2-14-is-released ã®ãMocks: Spiesãã®ãµã³ãã«ã³ã¼ãã§ãã
# non_spy_spec.rb mailer = double("Mailer") expect(mailer).to receive(:deliver_welcome_email).with(an_instance_of(User)) UserCreationService.new(mailer).create_user(params) # spy_spec.rb mailer = double("Mailer", deliver_welcome_email: nil) UserCreationService.new(mailer).create_user(params) expect(mailer).to have_received(:deliver_welcome_email).with(an_instance_of(User))
ã¨ã£ã¦ãããããï¼
--- åèURL
- RSpec 2.14ã®ãªãªã¼ã¹ãã¼ã(è±èª): http://myronmars.to/n/dev-blog/2013/07/rspec-2-14-is-released
- RSpec Mock 2.14ã§å°å ¥ãããæ°ããè¨æ³ã®ã¤ãã¦(è±èª): http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
--- PRåºå
è¨äºãèªãã§ãã ããããããã¨ããããã¾ãããããããããã°ããã®è¨äºã®èè
ãéçºã»éå¶ãã¦ããç¡æã®ã«ã¯ãã«ã¬ã·ãæä¾ãµã¼ãã¹ãããã£ã¦ãï¼ããã試ããã ããã
- ããã£ã¦ãï¼: http://cocktailq.herokuapp.com/