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 824the problem of the implementati ... -
12.3 the status feed
2011-10-30 15:34 8581. we need to get all the micro ... -
12.2 a working follow button with Ajax
2011-10-29 18:10 9131. in the last chapter, in the ... -
12.2 a web interface for following and followers.
2011-10-28 22:14 8791.before we do the UI, we need ... -
12. following user, 12.1 relationship model
2011-10-18 14:29 7551. we need to use a relationshi ... -
11.3 manipulating microposts.
2011-10-17 15:31 9001. since all micropost actions ... -
11.2 show microposts.
2011-10-17 12:01 7031. add test to test the new use ... -
11.1 user micropost -- a micropost model.
2011-10-17 10:43 11071. we will first generate a mic ... -
10.4 destroying users.
2011-10-16 15:47 745in this chapter, we will add de ... -
10.3 showing users list
2011-10-15 20:41 774in this chapter, we will do use ... -
10.2 protect pages.
2011-10-15 15:11 665again, we will start from TD ... -
10.1 updating users.
2011-10-14 18:30 7091. git checkout -b updating-use ... -
9.4 sign out
2011-10-13 15:21 737whew!!!, last chapter is a long ... -
9.3 sign in success.
2011-10-12 15:39 7501. we will first finish the cre ... -
9.1 about flash.now[:error] vs flash[:error]
2011-10-12 15:37 727There’s a subtle difference ... -
9.2 sign in failure
2011-10-12 12:19 658start from TDD!!! 1. requir ... -
9.1 sessions
2011-10-12 10:00 645a 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 721in 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,是在...
离线安装包,亲测可用
在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 得天独厚的简单 易用 深得广大网站制作者的厚爱
DevExpress ExpressQuantumGrid Suite v5.3 是一款专为Delphi和BCB(Borland C++ Builder)开发者设计的强大网格控件集。这个版本针对这两个流行的开发环境提供了全面的功能,帮助开发者创建具有高度交互性和数据...
达梦数据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-...
openssh5.3.tar
net-snmp-libs-5.3.2.2-5.el5.i386.rpm
libreoffice-help-dz-5.3.6.1-24.el7.x86_64.rpm
《CAD快速看图5.3.2.38:高效浏览与管理CAD图纸的利器》 在工程设计领域,AutoCAD是一款广泛使用的专业制图软件,但其庞大的体积和复杂的操作使得在日常工作中快速查看和预览CAD图纸成为一个挑战。为了解决这一问题...
Spring Framework v5.3.32是该框架的一个特定版本,它包含了修复的问题、性能优化以及可能的新功能。 在Spring Framework 5.3.32中,我们可以关注以下几个关键知识点: 1. **模块化设计**:Spring Framework 分为...