LoginSignup
0
0

More than 3 years have passed since last update.

Rails Tutorial 第14章 演習14.2.3.2 コメントアウトは2箇所しないとredにならない

Posted at

演習14.2.2.3 strongタグにIDを指定

ネットの他の方はrespons.bodyでassert_matchをしていました。私はstrongタグにIDを指定して、assert_selectを使っています。

test/integration/users_profile_test.rb
  test "Home stat" do
    log_in_as(@user)
    get root_path
    assert_select 'strong#following', @user.following.count.to_s 
    assert_select 'strong#followers', @user.followers.count.to_s
  end
ネットの他の方
    assert_match @user.active_relationships.to_s, response.body
    assert_match @user.passive_relationships.to_s, response.body

演習14.2.3.2 コメントアウトは2箇所しないとredにならない

ネットの他の方はコメントアウトは1箇所でした。私は2箇所しないとredにならずgreenのままでした。

views/users/show_follow.html.erb
           <% @users.each do |user| %>
            <%#= link_to gravatar_for(user, size: 30), user %>
          <% end %>
..
      <ul class="users follow">
        <%#= render @users %>
      </ul>
ネットの他の方
    <% @users.each do |user| %>
        <%= #link_to gravatar_for(user, size:30), user %>
    <% end %>

演習14.2.6.1 ネットの他の人の答えが2種類

>各行を順にコメントアウトしていき、テストが正しくエラーを検知できるか
の意味をどうとるかで、ネットの他の人の答えが2種類ありました。
1.「順に」を1行だけずつ
2.1行の次は2行と2行を追加していく

私は1.を選びましたが、それだと次の設問で答えが得られなかったです。なので2.が正解のようです。
理由は、format.jsの行だけをコメントアウトしても、redにならずgreenのままだからです。

controllers/relationships_controller.rb
      respond_to do |format|
#        format.html { redirect_to @user }
#        format.js
      end
 FAIL["test_should_follow_a_user_with_Ajax", FollowingTest, 0.9658033109999451]
 test_should_follow_a_user_with_Ajax#FollowingTest (0.97s)
        "@user.following.count" didn't change by 1.
        Expected: 3
          Actual: 2
        test/integration/following_test.rb:36:in `block in <class:FollowingTest>'

ERROR["test_should_follow_a_user_the_standard_way", FollowingTest, 0.9935227480000322]
 test_should_follow_a_user_the_standard_way#FollowingTest (0.99s)
ActionController::UnknownFormat:         ActionController::UnknownFormat: ActionController::UnknownFormat
            app/controllers/relationships_controller.rb:7:in `create'
            test/integration/following_test.rb:31:in `block (2 levels) in <class:FollowingTest>'
            test/integration/following_test.rb:30:in `block in <class:FollowingTest>'
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0