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
9
votes
1 answer

Minitest - test controller concerns

I try to test my controller concerns using minitest-rails and combining this techniques: http://ridingtheclutch.com/post/55701769414/testing-controller-concerns-in-rails. Anonymous controller in Minitest w/ Rails And i get "no route matches…
rootatdarkstar
  • 1,486
  • 2
  • 15
  • 26
9
votes
1 answer

minitest - pass any argument to expect

I have the following code that I am using to mock a call to a class method: def test_calls_update_profile_job_for_a_lead input = ContactInput.new valid_attributes mock = MiniTest::Mock.new use_case = CreateContact.new user, input, mock …
dagda1
  • 26,856
  • 59
  • 237
  • 450
9
votes
2 answers

Rails: Could not find minitest-4.7.5 in any of the sources

Here is a trouble: on my remote server command gem list shows: some gems minitest (4.7.5) .... bundle show minitest command shows: /var/lib/gems/1.9.1/gems/minitest-4.7.5 bundle show rails shows the same directory bundle -v - 1.6.2 (the latest…
Artem Z.
  • 1,243
  • 2
  • 14
  • 36
9
votes
4 answers

How to make Ruby test factories with random unique data, in Factory Girl or Minifacture?

I am testing a typical Rails model with a typical factory: # My model uses a 3-letter uppercase airport code, # such as "ATL" for Atlanta, "BOS" for Boston, etc. class Airport < ActiveRecord::Base validates :code, uniqueness: true Factory.define…
joelparkerhenderson
  • 34,808
  • 19
  • 98
  • 119
9
votes
3 answers

MiniTest - ReRun only failed tests

Is it possible to let minitest run only the failed tests via rake task? Couldnt find anything in internet about this... With rspec or cucumber it worked.. Is there any possibility here?
BvuRVKyUVlViVIc7
  • 11,641
  • 9
  • 59
  • 111
9
votes
5 answers

How do i get RSpec's shared examples like behavior in Ruby Test::Unit?

Is there a plugin/extension similar to shared_examples in RSpec for Test::Unit tests?
Sathish
  • 20,660
  • 24
  • 63
  • 71
9
votes
2 answers

How to run a full MiniTest suite without Rake?

Looked at this question already, and that more or less mirrors how I currently run my whole suite. Additionally, I've setup the following rake task: Rake::TestTask.new do |t| t.name = "spec:models" t.libs << "test" t.pattern =…
neezer
  • 19,720
  • 33
  • 121
  • 220
8
votes
4 answers

How do you perform javascript tests with Minitest, Capybara, Selenium?

There are a lot of examples on how to perform javascript tests with Capybara/Selenium/Rspec in which you can write a test like so: it "does something", :js => true do ... end However with minitest you can't pass a second parameter to instruct…
chris
  • 4,332
  • 5
  • 41
  • 61
8
votes
1 answer

Rails Minitest crashing when tests fail

Minitest crashes every time a test fails when I run rails test (Rails 5 and Ruby 2.4.2). For example, I forced a simple test to fail by switching the assert to assert_not: Failure: TransactionTest#test_transaction_should_be_valid…
Isaac
  • 2,246
  • 5
  • 21
  • 34
8
votes
3 answers

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

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…
user464839
  • 81
  • 3
8
votes
1 answer

Can't use guard-minitest in Rails

I start using MiniTest in my Rails project. When I run spring rake test, the test works fine. But I can't run the test by guard-minitest. bundle exec guard 05:03:24 - INFO - Guard::Minitest 2.4.6 is running, with Minitest::Unit 5.9.0! 05:03:24 -…
ironsand
  • 14,329
  • 17
  • 83
  • 176
8
votes
2 answers

How can I mock with a block in minitest?

Hopefully a simple question for MiniTest folks.. I have a section of code which I'll condense into an example here: class Foo def initialize(name) @sqs = Aws::SQS::Client.new @id = @sqs.create_queue( queue_name: name…
egeland
  • 1,244
  • 1
  • 12
  • 19
8
votes
5 answers

Capture Ruby Logger output for testing

I have a ruby class like this: require 'logger' class T def do_something log = Logger.new(STDERR) log.info("Here is an info message") end end And a test script line this: #!/usr/bin/env ruby gem "minitest" require…
Leonard
  • 13,269
  • 9
  • 45
  • 72
8
votes
3 answers

Rails 4 + Devise: How to write a test for Devise Reset Password without RSpec?

For reasons outside of my control, I can't use RSpec for testing in my current project. I'm trying to test Devise Reset Password, and I can't seem to come up with something that works. Here's what I have so far: require 'test_helper' class…
justindao
  • 2,273
  • 4
  • 18
  • 34
8
votes
1 answer

How to generate HTML reports from minitest specs

Is there a reporter for minitest to generate HTML from minitest spec-runs? Or do I miss a built-in feature or flag? Rspec has formatters to generate HTML documentation, but I cannot find this for minitest. In the end, I am looking to generate API…
berkes
  • 26,996
  • 27
  • 115
  • 206