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 801the problem of the implementati ... -
12.3 the status feed
2011-10-30 15:34 8491. we need to get all the micro ... -
12.2 a working follow button with Ajax
2011-10-29 18:10 9021. in the last chapter, in the ... -
12.2 a web interface for following and followers.
2011-10-28 22:14 8681.before we do the UI, we need ... -
12. following user, 12.1 relationship model
2011-10-18 14:29 7361. we need to use a relationshi ... -
11.3 manipulating microposts.
2011-10-17 15:31 8861. since all micropost actions ... -
11.2 show microposts.
2011-10-17 12:01 6941. add test to test the new use ... -
11.1 user micropost -- a micropost model.
2011-10-17 10:43 10941. we will first generate a mic ... -
10.4 destroying users.
2011-10-16 15:47 724in this chapter, we will add de ... -
10.3 showing users list
2011-10-15 20:41 762in this chapter, we will do use ... -
10.2 protect pages.
2011-10-15 15:11 645again, we will start from TD ... -
10.1 updating users.
2011-10-14 18:30 6971. git checkout -b updating-use ... -
9.4 sign out
2011-10-13 15:21 724whew!!!, last chapter is a long ... -
9.3 sign in success.
2011-10-12 15:39 7351. we will first finish the cre ... -
9.1 about flash.now[:error] vs flash[:error]
2011-10-12 15:37 714There’s a subtle difference ... -
9.2 sign in failure
2011-10-12 12:19 652start from TDD!!! 1. requir ... -
9.1 sessions
2011-10-12 10:00 640a 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 707in integration test, you can te ...
相关推荐
国产达梦数据库hibernate方言包
libreoffice-help-el-5.3.6.1-24.el7.x86_64.rpm
libreoffice-help-lv-5.3.6.1-24.el7.x86_64.rpm
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
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
Code Visual To Flowchart,简称CvF,是一款专门用于自动生成流程图的软件,其最新版本为v5.3.1030。这款工具旨在通过将代码转换为可视化流程图,简化代码理解和调试的过程,提高开发效率。 CvF的核心功能在于它的...
一款用于制作3d网页的软件 Cult3D_IE_5.3.0.228.exe 得天独厚的简单 易用 深得广大网站制作者的厚爱
DevExpress ExpressQuantumGrid Suite v5.3 是一款专为Delphi和BCB(Borland C++ Builder)开发者设计的强大网格控件集。这个版本针对这两个流行的开发环境提供了全面的功能,帮助开发者创建具有高度交互性和数据...
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
Spring Framework v5.3.32是该框架的一个特定版本,它包含了修复的问题、性能优化以及可能的新功能。 在Spring Framework 5.3.32中,我们可以关注以下几个关键知识点: 1. **模块化设计**:Spring Framework 分为...
《WinISO V5.3.0.125绿色版》是一款强大的光盘映像文件处理工具,专为用户提供了方便、高效的光盘映像文件管理和编辑功能。该版本为绿色版,意味着它无需安装,下载解压后即可直接运行,节省了用户的系统资源和时间...
这款工具最初由HP公司于1985年开发,后来在2005年被谷歌接管并持续进行更新和优化,目前最新的版本为v5.3.0.20221214。 **1. OCR技术简介** OCR技术是一种计算机视觉技术,它能够检测并提取图像中的文字内容,将...