`
peryt
  • 浏览: 54359 次
  • 来自: ...
最近访客 更多访客>>
社区版块
存档分类
最新评论
  • waiting: 既然都指定了dataType为'script'那就不必特别在b ...
    jQuery
文章列表
start from TDD!!!   1. require 'spec_helper' describe SessionsController do render_views . . . describe "POST 'create'" do describe "invalid signin" do before(:each) do @attr = { :email => "email@example.com", :password => ...

9.1 sessions

a session is a semi-permanent connection between 2 computers, such as client running browser & server running rails.   there are several model for session behaviors: 1. forget session on browser close 2. use a optional "remember me" checkbox for persistent sessions. 3. remember the ...
for integration test, i have no prefer between the default Test:Unit  and  Rspec.   just stick to one framework inside a project, no need to mix the two in one project.   A second option is Cucumber, which works nicely with RSpec and allows the definition of plain-text stories describing appl ...
in integration test, you can test many controllers at the same time,   test a complete workflow, like login to the home page, open signup page, fill in contents, and submit......   maybe you have made sure these functions worked fine through manual test, but the integration test is to make sure i ...
Chapter 8.3 this part, we will deal with the case that sign up success.   1. start from TDD!!!!     describe "success" do before(:each) do @attr = { :name => "New User", :email => "user@example.com", :password => " ...
chapter 8.2   for this section, we will do this:   if a signup form has invalid submission, the app will re-render the signup page, show the error details.   1. we will do TDD again!!!   resources :users   this line in routes.rb prepare many REST urls for us.   for example, a POST request ...
What happens: When the user views a form to create, update, or destroy a resource, the rails app would create a random authenticity_token, store this token in the session, and place it in a hidden field in the form. When the user submits the form, rails would look for the authenticity_token, compar ...
chapter 8.1   1. let's first make a branch for the sign up chapter: git checkout -b signing-up   2. also reset the database: rake db:reset   3. we already got two basic test for new action in users_controller_spec.rb test   describe "GET 'new'" do it "should be success ...
Chapter 7.3   now, we have a good user model, we can try to make a show page to show the user info.   we already have some test for the new action in the users controller.   now we will add some test for the show action in this controller.   But at once, we facing a challenge, the test of sho ...
chapter 7.2.4   1. we need to create a user, save it to database 2. we need to get the user object by email 3. we need to verify that it has a given password   not surprising, we will start from test again, right, TDD!!!!!   we expect we will have a class method:     User.authenticate(emai ...
chapter 7.2   again, let's start from TDD again!!!!!!!!!!!!!!   1. since we define the encrypt_password into private area, how do we test it????????   ok, we need some public interface to use it. (TDD by acting as a client, the test motivate us to design a useful interface right from the start) ...
chapter 7.1.3   now that our user model has an attr for storing password, we need to arrange to generate and save an encrypted password when save user to the database.   the technique of doing this is callback.   we will use before_save callback to create the encrypted_password.   1. start fr ...
1. rake db:reset   this command is very useful, it will clear the old sample data from database, so we again have a clean database   2. here, we will just use plain password, with bad secure, we will talk about password security later.   3. again, we will start from test!!!!   now in the samp ...
1. let's start to console without --sandbox param to create some record into our database:     rails console User.create!(:name => "china zhang", :email => "china@china.com")  to see if this work, let's use SQLite database browser to see.   2. let's create a view na ...
  <html> <body> <div class="container"> <%= render 'layouts/footer'%> <%= debug(params) if Rails.env.development? %> </div> </body> </html>   since we don't want to display the debug info to a deployed applica ...
Global site tag (gtag.js) - Google Analytics