1. rails generate controller Users new
this line of code will generate a users controller and a new action,
also a spec test file of
users_controller_spec.rb
and also a route
get "users/new"
2. next, we will start another loop of test-driven development:
first, we add another test into users_controller_spec.rb
it "should have the right title" do get 'new' response.should have_selector('title', :content=>"Sign up") end
note, we need add "render_views", to make sure the test will render views to test.
if not, the pass won't pass, even if we added the title.
note, we used have_selector again.
3. ok, cool, we got a failing test, next, let's make it pass.
a. define a instance var into new method.
@title = "Sign up"
ok, done!
4. we already got a route:
get "users/new"
but we don't want to use it, we want to use
"/signup"
so let's define another route:
match "/signup" => "users#new"
But, wait, before we add this line of code to route, let's write failing test first:
since we are going the test route of "/signup", which doesn't belong to any controller.
so this test need to go to integration test.
it "should have a sign up page at '/signup'" do get "/signup" response.should have_selector "title", :content => "Sign up" end
ok, this test will fail, then we can add that route to make it pass!!!
5. remember? that route will also create a helper:
signup_path
we can use this path in views, instead of hardcode paths.
发表评论
-
12.3.3 scaling issue of the status feed
2011-10-30 17:54 834the problem of the implementati ... -
12.3 the status feed
2011-10-30 15:34 8711. we need to get all the micro ... -
12.2 a working follow button with Ajax
2011-10-29 18:10 9231. in the last chapter, in the ... -
12.2 a web interface for following and followers.
2011-10-28 22:14 8931.before we do the UI, we need ... -
12. following user, 12.1 relationship model
2011-10-18 14:29 7631. we need to use a relationshi ... -
11.3 manipulating microposts.
2011-10-17 15:31 9131. since all micropost actions ... -
11.2 show microposts.
2011-10-17 12:01 7141. add test to test the new use ... -
11.1 user micropost -- a micropost model.
2011-10-17 10:43 11181. we will first generate a mic ... -
10.4 destroying users.
2011-10-16 15:47 759in this chapter, we will add de ... -
10.3 showing users list
2011-10-15 20:41 787in this chapter, we will do use ... -
10.2 protect pages.
2011-10-15 15:11 678again, we will start from TD ... -
10.1 updating users.
2011-10-14 18:30 7231. git checkout -b updating-use ... -
9.4 sign out
2011-10-13 15:21 748whew!!!, last chapter is a long ... -
9.3 sign in success.
2011-10-12 15:39 7631. we will first finish the cre ... -
9.1 about flash.now[:error] vs flash[:error]
2011-10-12 15:37 742There’s a subtle difference ... -
9.2 sign in failure
2011-10-12 12:19 672start from TDD!!! 1. requir ... -
9.1 sessions
2011-10-12 10:00 656a session is a semi-permanent c ... -
what test framework should you use?
2011-10-11 16:56 0for integration test, i have no ... -
what test framework should you use?
2011-10-11 16:56 0<p>for integration test, ... -
8.4 rspec integration tests
2011-10-11 16:53 737in integration test, you can te ...
相关推荐
国产达梦数据库hibernate方言包
libreoffice-help-el-5.3.6.1-24.el7.x86_64.rpm
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
libreoffice-help-lv-5.3.6.1-24.el7.x86_64.rpm
Code Visual To Flowchart,简称CvF,是一款专门用于自动生成流程图的软件,其最新版本为v5.3.1030。这款工具旨在通过将代码转换为可视化流程图,简化代码理解和调试的过程,提高开发效率。 CvF的核心功能在于它的...
SKYUC_3.2.2_Free_For_PHP5.3.tar.bz2
TamoSoft.CommView.for.WiFi.v5.3.516.Cracked-SSG
openssh5.3版本的rpm包
**苹果的iTunes历史版本:12.6.5.3** iTunes是苹果公司推出的一款数字媒体播放应用程序,它不仅用于管理个人的音乐库,还支持与Apple的iPod、iPhone和iPad设备同步和交互。这个特定的历史版本——12.6.5.3,是在...
达梦数据DmDialect-for-hibernate所有jar包,DmDialect-for-hibernate2.0、DmDialect-for-hibernate2.1、DmDialect-for-hibernate3.0、DmDialect-for-hibernate3.1、DmDialect-for-hibernate3.6、DmDialect-for-...
《WinISO V5.3.0.125绿色版》是一款强大的光盘映像文件处理工具,专为用户提供了方便、高效的光盘映像文件管理和编辑功能。该版本为绿色版,意味着它无需安装,下载解压后即可直接运行,节省了用户的系统资源和时间...
离线安装包,亲测可用
在5.3.2.2-5.el5.i386这个特定版本中,"el5"代表它兼容Red Hat Enterprise Linux 5,而“i386”表明这是为32位Intel架构设计的。这使得该版本可以在32位的Linux系统上有效运行,进行网络监控任务。 net-snmp的主要...
net-snmp-5.3.2.2-9.el5.i386.rpm
一款用于制作3d网页的软件 Cult3D_IE_5.3.0.228.exe 得天独厚的简单 易用 深得广大网站制作者的厚爱
比较老的版本思科模拟器Cisco Packet Tracer是一个功能强大的网络仿真程序,允许学生实验与网络行为。思科模拟器Cisco Packet Tracer软件功能很强大,有很多特色的功能,能够有效的帮助到学习CCNA课程的网络初学者。
DevExpress ExpressQuantumGrid Suite v5.3 是一款专为Delphi和BCB(Borland C++ Builder)开发者设计的强大网格控件集。这个版本针对这两个流行的开发环境提供了全面的功能,帮助开发者创建具有高度交互性和数据...
标题“libdb-5.3.zip”提示我们这是一个与Berkeley DB(通常简称为BDB)相关的库文件,版本为5.3。Berkeley DB是一款轻量级、高性能的键值存储系统,常用于在Linux和其他类UNIX系统中管理数据库。在描述中提到的...
openssh5.3.tar
标题中的"rtl8188FU_linux_v5.3.0.1_28034.20180525.tar.gz"是一个针对Linux操作系统的无线网卡驱动程序,具体是RTL8188FU型号。该驱动源代码的版本号为5.3.0.1,日期为2018年5月25日。这个压缩包以".tar.gz"格式...