minitest

How do I scale the stack when debugging with byebug?

微笑、不失礼 提交于 2019-12-06 04:16:23
I'm currently getting an error that looks like this: NoMethodError: undefined method `debug' for nil:NilClass /mnt/hgfs/Dropbox/Company/Project/lib/project/misc.rb:23:in `debug' /mnt/hgfs/Dropbox/Company/Project/lib/project/validation/google_geocoding_validation_engine.rb:49:in `block in compare_addresses' /mnt/hgfs/Dropbox/Company/Project/lib/project/validation/google_geocoding_validation_engine.rb:43:in `each' /mnt/hgfs/Dropbox/Company/Project/lib/project/validation/google_geocoding_validation_engine.rb:43:in `compare_addresses' /mnt/hgfs/Dropbox/Company/Project/lib/project/validation/google

Error “cannot load such file — 2.0/Console_ext” running unit tests in RubyMine

匆匆过客 提交于 2019-12-06 01:48:58
I'm trying to get started running unit tests for a sample ruby on rails application however RubyMine is printing out the following error whenever I try and run unit tests I've also gotten the same error when running bundle install since I added gem "win32console", '1.3.0' to my Gemfile. Here is the error in text form Exception message: cannot load such file -- 2.0/Console_ext ["D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/win32console-1.3.0-x86-mingw32/lib/Win32/Console.rb:12:in `require'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/win32console-1.3.0-x86-mingw32/lib/Win32

How can I generate a report that shows me my slowest running tests in Rails 3.2, Ruby 1.9?

我怕爱的太早我们不能终老 提交于 2019-12-05 16:09:34
I know that RSpec has the --profile option, but I'm only using MiniTest/shoulda for my current project. You can use minitest-reporters for this purpose. This gem provide multiple reporters to see output of your tests. Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new Spec reporter shows the time which each test take to run. It shows the time on console, not as a report. You can just use: rake TESTOPTS="-v" right out of the box. eg: rake TESTOPTS="-v" test:controllers I have tested this with Ruby 1.9.3 on Rails 3.2. 来源: https://stackoverflow.com/questions/23620763/how-can-i

What does this MiniTest::Unit::TestCase warning mean?

耗尽温柔 提交于 2019-12-05 15:43:09
问题 My tests were running without problems, when suddenly the following warning appeared: MiniTest::Unit::TestCase is now Minitest::Test This was reported in the following libs: ruby-1.9.3-p392/lib/ruby/1.9.1/test/unit/testcase.rb:8:in `<module:Unit>' gems/activesupport-3.2.12/lib/active_support/test_case.rb:12:in `<module:ActiveSupport>' gems/activesupport-3.2.12/lib/active_support/descendants_tracker.rb:34:in `inherited' I have no idea what prompted these warnings to appear. Does anybody know

Rails and MiniTest: add additional folder

て烟熏妆下的殇ゞ 提交于 2019-12-05 15:04:44
问题 I use Ruby 2 and Rails 4. I have a folder test/lib , where a few tests are located. But running rake test does not use them. Only the other tests (models, controllers, ...) are running. Where do I have to add the lib folder? I already tried MiniTest::Rails::Testing.default_tasks << 'lib' , but I get NameError Exception: uninitialized constant MiniTest::Rails . I did not add the minitest gem to my Gemfile, because Ruby 2 uses it by default. 回答1: To use MiniTest::Rails::Testing.default_tasks <<

Testing controllers with Minitest

[亡魂溺海] 提交于 2019-12-05 00:26:44
I'm trying to find examples of testing controllers with Minitest, but I've only found a couple and the just verify what template is rendered and that 'success' is returned. That doesn't seem very helpful to me. Is Minitest used to test controllers? The Railscast ( http://railscasts.com/episodes/327-minitest-with-rails ) and a couple other posts I've found seem to do model tests with Minitest and integration tests with Capybara. What about controller tests? Can they be tested with Minitest? If so, are there any real-world examples that actually test the actions? It seems very odd that I can't

Test helper method with Minitest

梦想的初衷 提交于 2019-12-04 21:28:14
问题 I would like to test a helper method using Minitest (minitest-rails) - but the helper method depends on current_user, a Devise helper method available to controllers and view. app/helpers/application_helper.rb def user_is_admin? # want to test current_user && current_user.admin? end test/helpers/application_helper_test.rb require 'test_helper' class ApplicationHelperTest < ActionView::TestCase test 'user is admin method' do assert user_is_admin? # but current_user is undefined end end Note

Has anyone used Minitest::Spec withing a Rails functional test?

三世轮回 提交于 2019-12-04 20:13:54
问题 The spec library in Minitest is great. I've been able to use it within Rails unit tests no problem. However, Rails functional test inherit from ActionController::TestCase which provides instance variables like @controller in it's setup. Has anyone been using the Minitest::Spec lib for their Rails functional tests? If not, I'm considering creating a small library to do just that. I'm not too keen on rspec, and shoulda is starting to shift it's focus to rspec. It would be nice to have something

Include module in all MiniTest tests like in RSpec

久未见 提交于 2019-12-04 19:47:26
问题 In RSpec I could create helper modules in /spec/support/... module MyHelpers def help1 puts "hi" end end and include it in every spec like this: RSpec.configure do |config| config.include(MyHelpers) end and use it in my tests like this: describe User do it "does something" do help1 end end How can I include a module into all MiniTest tests without repeating myself in every test? 回答1: minitest does not provide a way to include or extend a module into every test class in the same way RSpec does

Testing User Model (Devise Authentication) with MiniTest

此生再无相见时 提交于 2019-12-04 17:02:23
I'm trying to test user model, for which I've devise authentication. The problem I'm facing is, 1. Having 'password'/'password_confirmation' fields in fixtures is giving me invalid column 'password'/'password_confirmation' error. If I remove these columns from fixture and add in user_test.rb require 'test_helper' class UserTest < ActiveSupport::TestCase def setup @user = User.new(name: "example user", email: "example@example.com", password: "Test123", work_number: '1234567890', cell_number: '1234567890') end test "should be valid" do assert @user.valid? end test "name should be present" do