简体   繁体   English

为什么我在'rake test'期间看到输出而不是'。' 'F'或'E'(ruby 1.9.2p290,Rails 3.0.9)?

[英]Why am I seeing output during 'rake test' other than '.' 'F' or 'E' (ruby 1.9.2p290, Rails 3.0.9)?

When I used to run 'rake test' I would see either '.' 当我以前运行'rake test'时,我会看到'''。 or 'F' or 'E' for each test. 或每次测试的'F'或'E'。 When all was well, the output was a line of '.' 当一切都很顺利时,输出就是一行'。'

Now, even though all my test are passing, I am seeing program output in the midst of the line of '.' 现在,即使我的所有测试都通过了,我看到程序输出位于'。'行的中间。

I am not sure the best way to post the output, but here is an initial offering: 我不确定发布输出的最佳方式,但这是一个初始产品:

perrys-MacBook-Pro:iway perry_mac$ rake test:functionals --trace
** Invoke test:functionals (first_time)
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment 
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment 
** Execute db:schema:load
** Execute test:prepare
** Execute test:functionals
Loaded suite /Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_test_loader
Started
.........................."Welcome joe : "
."Welcome joe : "
."Welcome joe : "
."Welcome joe : "
.................."Welcome bob : "
...........
Finished in 0.998462 seconds.

58 tests, 81 assertions, 0 failures, 0 errors, 0 skips

Test run options: --seed 15796

The line of code generating the output is: app/views/layouts/application.html.erb 生成输出的代码行是:app / views / layouts / application.html.erb

  <div id="nav">
      <% if current_user %>
            <% str= "Welcome " + current_user.username + " : "%>
            <%= p str %>
      <%= link_to "Edit Profile : ", edit_user_path(current_user.id)%>
      <%= link_to "Logout", :logout%>
      <% else %>
      <%= link_to "Register", new_user_path%> |
      <%= link_to "Login", :login %>
      <% end %>
  </div>

The "Welcome joe : " and "Welcome bob : " msgs are expected program output seen after a user successfully logs in. bob and joe are usernames created in a fixtures file. “Welcome joe:”和“Welcome bob:”msgs是用户成功登录后可以看到的程序输出.bob和joe是在fixture文件中创建的用户名。 I can't figure out why the msgs are now seen during 'rake test' I see the same behavior when --trace is not used as well. 我无法弄清楚为什么现在可以在'rake test'中看到msgs。当我没有使用--trace时,我看到相同的行为。 Please comment on A) why I see some program output and not the rest and B) Why am I seeing any at all? 请评论A)为什么我看到一些节目输出而不是其余节目B)为什么我看到任何节目?

Grep for "puts" or other code that writes to stdout in your app or test code. grep用于“puts”或其他代码,用于在应用程序或测试代码中写入stdout Something is leaking data to stdout. 有些东西正在向stdout泄露数据。

It looks like your view template is sending the content to stdout as well as the view: 看起来您的视图模板正在将内容发送到stdout以及视图:

    <%= p str %>

The p function sends the string to stdout and then returns the string. p函数将字符串发送到stdout,然后返回字符串。 The <%= ERB directive injects the value into the page being rendered, so you were both printing it out to stdout/console and rendering it in the page. <%= ERB指令将值注入正在呈现的页面中,因此您将它打印到stdout / console并在页面中呈现它。 This caused it to appear on the console when you were running tests. 这导致它在运行测试时出现在控制台上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么这个非常基本的单元测试失败了(ruby 1.9.2p290,Rails 3.0.9)? - Why is this very basic unit test failing (ruby 1.9.2p290, Rails 3.0.9)? 工厂女孩的“捆绑安装”期间“无效的gemspec”消息(rails 3.1和ruby 1.9.2p290) - “Invalid gemspec” messages during “bundle install” of factory girl (rails 3.1 and ruby 1.9.2p290) 证书验证失败Heroku Ruby on Rails 3.2.1 Ruby 1.9.2p290 - Certificate verify failed Heroku Ruby on Rails 3.2.1 Ruby 1.9.2p290 Ruby 1.9.2p290 URL正则表达式有时挂起/破坏 - Ruby 1.9.2p290 URL regex sometimes hanging / breaking Nokogiri,Omniauth和1.9.2p290 =&gt;完全失败 - Nokogiri, Omniauth and 1.9.2p290 => total failure Rails 3:Ruby 1.9.2:Rake测试:winshellTEST - Rails 3: Ruby 1.9.2: rake test: winshellTEST Rails 2.3.14站点上的“检测到死锁”错误-乘客3.0.9,Ruby 1.9.2 - “deadlock detected” errors on Rails 2.3.14 site — Passenger 3.0.9, Ruby 1.9.2 将Ruby1.9.2从p180升级到p290后,不会更新libruby动态库路径 - After upgrading Ruby1.9.2 from p180 to p290, libruby dynamic library path isn't updated 使用ruby 1.9.2,rails3.1.0,当我尝试生成脚手架时,为什么会出现错误。 - Using ruby 1.9.2, rails3.1.0, Why am I getting an error when I try to generate a scaffold. 为什么我在开发 Rails 缓存中看到测试环境数据? - Why am I seeing test environment data in my development Rails cache?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM