nviennot / rspec-console

Run RSpec tests in your rails console
101 stars 20 forks source link

Silence logger option #18

Closed mooreniemi closed 9 years ago

mooreniemi commented 9 years ago

While using rspec-console in Rails, the ActiveRecord logging to console output can obscure the test output. (If you have a noisy database.) My code changes allow a user to set an environment variable to silence the log while running tests in rails c test. I'd like to put more tests around the Pry command itself, but I can confirm this command works in my apps (mix of jruby, Ruby 2, Rails 3 and 4).

All other changes are "boyscout rule" changes in response to deprecation warnings.

nviennot commented 9 years ago

Are you using rspec-console with irb-config?

mooreniemi commented 9 years ago

No, irb-config caused issues for me, so I removed it. I also can't guarantee it will be used by the rest of my department, whereas rspec-console's use is widespread. Would irb-config have fixed this somehow?

nviennot commented 9 years ago

No I though AR's logger was always going in log/test.log, except with irb-config which plugs STDERR to the logger: https://github.com/nviennot/irb-config/blob/master/irb/rails_colors.rb#L6

nviennot commented 9 years ago

I changed your code to use some more idiomatic ruby: https://github.com/nviennot/rspec-console/blob/silence_ar/lib/rspec-console/pry.rb

Can you try the silence_ar branch and see if it works for you?

mooreniemi commented 9 years ago

Confirmed to work for me.

nviennot commented 9 years ago

pushed to master :)

mooreniemi commented 9 years ago

Thanks! :+1:

nviennot commented 9 years ago

btw I forced push on master to fix the test you wrote :)