我有明确的申请。我设置了rspec和capybara。我写了简单的测试。
require 'rails_helper'
RSpec.feature "Log in", type: :feature do
scenario 'as user' do
User.create!(email: 'user@eample.com', password: 'password')
visit '/users/sign_in'
fill_in 'Email', with: 'user@example.com'
fill_in 'Password', with: 'password'
click_on 'Log in'
expect(page).to have_content 'Signed in successfully.'
end
end
此测试推送服务器记录到stdout(或stderr)。所以测试输入看起来像这样
> rspec
ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
(0.2ms) BEGIN
(0.2ms) SAVEPOINT active_record_1
User Exists (1.7ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'user@example.com' LIMIT 1
SQL (0.4ms) INSERT INTO "users" ("email", "encrypted_password", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["email", "user@example.com"], ["encrypted_password", "$2a$04$6iqFDQXgBy/bC/1lYdzLV...1Da18lRiTyDaMJpWdi7EiK68Dcm6."], ["created_at", "2015-12-01 17:09:33.264145"], ["updated_at", "2015-12-01 17:09:33.264145"]]
...
Completed 200 OK in 19ms (Views: 18.1ms | ActiveRecord: 0.0ms)
(0.4ms) ROLLBACK
.
Finished in 0.49195 seconds (files took 0.45766 seconds to load)
1 example, 0 failures
的Gemfile:
group :development, :test do
gem 'rspec-rails', '~> 3.0'
gem 'capybara'
end
Gemfile.lock的:
...
rspec (3.4.0)
...
capybara (2.5.0)
...
spec_helper.rb
和rails-helper.rb
是默认值。
我尝试添加不使用capybara的示例:
require 'rails_helper'
describe Array do
it { should respond_to :count }
end
但它返回类似的输出
> rspec spec/models/fake_test_spec.rb
ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
(0.1ms) BEGIN
(0.1ms) ROLLBACK
.
Finished in 0.00257 seconds (files took 0.36298 seconds to load)
1 example, 0 failures
有什么问题?我从未见过同样的行为。它只是开箱即用。我不会更改stderr
或stdout
变量...
答案 0 :(得分:1)
哦不......我让读者感到困惑......我设置了我的应用程序以部署到heroku并使用gem 'rails_12factor'
。它改变了记录器的行为。所以我把这个宝石移到production
组,一切正常。