In my app, I have the following code: File.open "filename", "w" do |file| file.write("text") end I want to test this code via RSpec. What are the best practices for doing this?
2012å¹´04æ19æ¥ æè¿ãæ°äººã®ãã¹ãã³ã¼ããè¦ãæ©ä¼ããããã¦ããããã¹ãã®æ¸ãæ¹ã«ã¤ãã¦èããæ©ä¼ããã£ããã¦ããããã¹ãã¯ãã³ãã¬ã¼ãã¿ãããªãã®ãããã®ã§ãããããæ¼ãããã°ã誰ã§ãç°¡åã«æ¸ããã¨ãã§ããã ããã§ã¯ããã®æ¹æ³ã«ã¤ãã¦ç´¹ä»ãããããµã³ãã«ã¯RSpecã§æ¸ããããã®ä»ã®ã¦ããããã¹ããã¬ã¼ã ã¯ã¼ã¯ã§ããå¿ç¨ãã§ããã¨ãããã ã¯ããã«ããåç´åããã¨ããã¹ã対象ã¯ç¶æ ãæã¡ãå ¥åãä¸ããã¨ä½ããã®åºåãè¡ãªããã®ã§ãããå ¥åãå¤ããã°åºåã¯å¤åããããç¶æ ãå¤åããã¨å ¥åãåãã§ãåºåãå¤ããï¼ãããããªãï¼ã ã¦ããããã¹ãã¯ããã¹ã対象ã®ç¶æ ãæä½ããä¸ããå ¥åã«ãã£ã¦æå³éãã®åºåãå¾ããããã確èªããä½æ¥ã®ãã¨ãããããªã®ã§ãã¦ããããã¹ããæ¸ãã¨ãã«ã¯ããªãã¸ã§ã¯ãã®ç¶æ ãã¨ã«ã¡ã½ããåä½ã§å ¥åã¨åºåã確èªããããã«ããã RSpecã®çä¼¼ã³ã¼ãã§æ¸ãã¨
describe("Jasmine", function() { it("makes testing JavaScript awesome!", function() { expect(yourCode).toBeLotsBetter(); }); }); Documentation User Guide Release Notes API Documentation Contributor Guide Download For pure JavaScript projects: VersionSizeDateSHA1
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}