<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 5.6 練習 電子書中有練習的答案,如果想閱讀參考答案,請[購買電子書](http://railstutorial-china.org/#purchase)。 避免練習和正文沖突的方法參見[3.6 節](chapter3.html#mostly-static-pages-exercises)中的說明。 1. 按照 [5.2.2 節](#syntactically-awesome-stylesheets)的建議,自己動手把底部的樣式由[代碼清單 5.13](#listing-footer-css) 中的 CSS 改寫成[代碼清單 5.15](#listing-refactored-scss) 中的 SCSS。 2. 在[代碼清單 5.25](#listing-layout-links-test) 所示的集成測試中添加一些代碼,使用 `get` 方法訪問“注冊”頁面,確認這個頁面有正確的標題。 3. 像[代碼清單 5.36](#listing-test-helper-application-helper) 那樣在測試輔助文件中引入應用的輔助方法后,能在測試中使用 `full_title` 輔助方法。然后可以使用[代碼清單 5.37](#listing-layout-links-test-signup-full-title-helper) 中的測試檢查頁面的標題(在前一個練習的基礎上編寫)。不過這么做有個缺點,如果標題的公共部分有錯別字(例如“Ruby on Rails Tutoial”),測試組件不能發現。所以要為 `full_title` 輔助方法編寫一個測試:新建一個測試,專門用來測試應用的輔助方法,然后把[代碼清單 5.38](#listing-full-title-helper-tests) 中的 `FILL_IN` 改成具體的代碼。([代碼清單 5.38](#listing-full-title-helper-tests) 使用 `assert_equal` 方法通過 `==` 操作符檢查兩個值是否相等。) ##### 代碼清單 5.36:在測試中引入應用的輔助方法 test/test_helper.rb ``` ENV['RAILS_ENV'] ||= 'test' . . . class ActiveSupport::TestCase fixtures :all include ApplicationHelper . . . end ``` ##### 代碼清單 5.37:在測試中使用 `full_title` 輔助方法 GREEN test/integration/site_layout_test.rb ``` require 'test_helper' class SiteLayoutTest < ActionDispatch::IntegrationTest test "layout links" do get root_path assert_template 'static_pages/home' assert_select "a[href=?]", root_path, count: 2 assert_select "a[href=?]", help_path assert_select "a[href=?]", about_path assert_select "a[href=?]", contact_path get signup_path assert_select "title", full_title("Sign up") end end ``` ##### 代碼清單 5.38:測試 `full_title` 輔助方法 test/helpers/application_helper_test.rb ``` require 'test_helper' class ApplicationHelperTest < ActionView::TestCase test "full title helper" do assert_equal full_title, FILL_IN assert_equal full_title("Help"), FILL_IN end end ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看