Questions tagged [minitest]

a testing framework that comes in the standard library of Ruby 1.9.

Minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking. When making assertions in Cucumber step definitions, there are a few different libraries you could choose. MiniTest is one of the candidates.

MiniTest’s assertions are built into Ruby, which makes them a handy tool to reach for. They use a style of assertion that you’ll be familiar with if you’re used to making assertions in any xUnit testing framework.


Resources

1539 questions
10
votes
5 answers

minitest_plugin.rb:9 getting wrong number of arguments

~/Sites/sample_app$ rails test Running via Spring preloader in process 24338 Run options: --seed 58780 Running: .. Finished in 0.292172s, 6.8453 runs/s, 6.8453…
Josh HUmphrey
  • 273
  • 2
  • 10
10
votes
2 answers

rails/minitest don't load fixtures for select tests

My tests are written using fixtures and I am slowly refactoring them to use factories instead. Once I've refactored a test class to not use fixtures I want to not load fixtures for that class. Is there a way to do this? Or am I stuck with either…
stoebelj
  • 1,536
  • 2
  • 14
  • 31
10
votes
2 answers

How to sign_in for Devise to Test Controller with Minitest

I'm newbie to Rails Testing. After following some tutorial online, I could able to setup and run testing for Model. But when trying to test for Controller, Testing was failed as it is redirected to login page. I've tried every instruction I can…
Metal
  • 435
  • 3
  • 13
10
votes
1 answer

Ruby minitest assert_output syntax

I am new to minitest and still new to ruby and really tired of trying to google this question without result. I would be really grateful for help: What is the exact syntax of assert_output in ruby minitest? All I find on github or elsewhere seems to…
enahel
  • 355
  • 3
  • 15
10
votes
2 answers

How to test a second redirect in Rails' controller test

I am using Wicked which redirects to a self-defined link after finishing the wizard. This happens with a second redirect. So, a PUT update triggers a 302 to /orders/1/finish_wicked, which then redirects to /orders/1. This works as expected, but is…
berkes
  • 26,996
  • 27
  • 115
  • 206
10
votes
3 answers

Include module in all MiniTest tests like in RSpec

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…
BvuRVKyUVlViVIc7
  • 11,641
  • 9
  • 59
  • 111
10
votes
2 answers

Is it still possible to use test-unit in rails 4?

After upgrading from Rails 3.2 to Rails 4, my app works, but my tests, written with test-unit, are a disaster. Minitest is rumored to be "compatible" with test-unit. However, if I attempt to use the (now bundled) Minitest, there are a raft of…
David W
  • 324
  • 1
  • 13
9
votes
3 answers

minitest - mock - expect keyword arguments

When I want to verify that mock is send expected arguments, I can do @mock.expect(:fnc, nil, ["a, "b"]) however, if class I want to mock looks like this class Foo def fnc a:, b: end end how can I mock it and verify values passed as a:, b:?
graywolf
  • 7,092
  • 7
  • 53
  • 77
9
votes
1 answer

What is the difference between MiniTest's assert_in_delta and assert_in_epsilon methods?

Here is documentation for assert_in_delta: assert_in_delta(exp, act, delta = 0.001, msg = nil) public For comparing Floats. Fails unless exp and act are within delta of each other. assert_in_delta Math::PI, (22.0 / 7.0), 0.01 And here is the…
Tom Lord
  • 27,404
  • 4
  • 50
  • 77
9
votes
4 answers

How can I make this Time assertion match perfectly with either Time, Date, or DateTime

I have an assertion in a test that looks like this: assert_equals object.sent_at, Time.now When I run this test, I keep getting an error that looks like this --- expected +++ actual @@ -1 +1 @@ -Fri, 04 Mar 2016 18:57:47 UTC +00:00 +Fri, 04 Mar…
Dan Rubio
  • 4,709
  • 10
  • 49
  • 106
9
votes
1 answer

Why do i need to use minitest/autorun?

Why do i require minitest/autorun instead of test/unit for generating unit test require 'test/unit' class Brokened def uh_oh "I needs fixing" end end class BrokenedTest < Minitest::Test def test_uh_of actual = Brokened.new …
Rajnish
  • 419
  • 6
  • 21
9
votes
2 answers

How do you write a setup method that is executed just once for a test file?

I would like to have a method that runs once per file rather than once per test. I've seen some references to a "before" method, but doesnt appear to work with MiniTest. Ideally, something like this: class MyTest < ActiveSupport::TestCase before…
Tom Rossi
  • 11,604
  • 5
  • 65
  • 96
9
votes
2 answers

What is the use of assert_predicate in MiniTest?

I have a problem understanding the usefulness of assert_predicate in MiniTest. How is it different from assert_equal? When would one want to use this assertion? I have came across it many times but did not really get its exact meaning.
delpha
  • 931
  • 1
  • 8
  • 23
9
votes
1 answer

How to uninstall minitest from Rails

I'm using Ruby 2.2.0p0, and Rails 4.2.0. The Rails application is currently defaulting to using minitest, even though there's no testing gems mentioned in the Gemfile. For example, I have rake test in my rake tasks, and a test folder. I can see how…
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
9
votes
0 answers

How can I setup Minitest fixtures to test Apartment using postgres schemas

I am building a multi tenant app in Rails using the Apartment Gem and Postgresql 9.4.1. I use Minitest and dont' know RSpec. How can I setup Minitest fixtures to put some fixtures/data in the public schema and some other data in a specific…
Adam21e
  • 791
  • 5
  • 13