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
0
votes
2 answers

Can "assert" produce output for assertions that _pass_?

assert(false, "statement is true") produces output (to stdout, by default) containing the descriptive message "statement is true". What if I want the output to also contain the descriptive message for assertions that pass, i.e. if I instead have…
gcbenison
  • 11,723
  • 4
  • 44
  • 82
0
votes
1 answer

Having problems writing tests for models with *_to_many relationships

I have these models: Sequel::Model.plugin(:schema) DB = ENV['RUBY_ENV'].eql?('test') ? Sequel.sqlite('test.db') : Sequel.sqlite('database.db') DB.loggers << Logger.new($stdout) unless DB.table_exists?(:channel) DB.create_table :channel do …
skatkov
  • 133
  • 2
  • 10
0
votes
1 answer

Warning regarding minitest/unit when used with ActiveSupport-4.1.1.gem? How to resolve this?

I've searched google and github about the following warning (see more detail below) that I am receiving when I run my tests on my gem, which, all pass: Warning: you should require 'minitest/autorun' instead. Warning: or add 'gem "minitest"' before…
gangelo
  • 3,034
  • 4
  • 29
  • 43
0
votes
1 answer

How to test routes that don't include controller?

I'm using minitest in Rails to do testing, but I'm running into a problem that I hope a more seasoned tester can help me out with because I've tried looking everywhere for the answer, but it doesn't seem that anyone has run into this problem or if…
boo-urns
  • 10,136
  • 26
  • 71
  • 107
0
votes
0 answers

MiniTest test contents inside two hashes are equal without considering order

I have this hash: { a: [ { b: 'c' }, { d: 'e' } ], b: [ { f: 'f' }, { g: 'g' } ] } How can I test it that it's contents are equal to another to another hash without considering the order of the keys? For example: { b: [ …
Jumbalaya Wanton
  • 1,601
  • 1
  • 25
  • 47
0
votes
1 answer

rails model unit test trying to hit database throws nil

Any suggestions on how to resolve this test error. The database has records which I try to fetch during test and run the test against. I am using minitest 5.3.3, rails 4.1.1 app and ruby 2.0.0p247 The test output and error thrown: Finished in…
brg
  • 3,915
  • 8
  • 37
  • 66
0
votes
1 answer

rails unit testing model, call to database saying table column is nil when it is not nil

I am using minitest 5.3.3 to test a model in a rails 4.1.1 app using ruby 2.0.0p247. After running the test I get Finished in 0.017875s, 167.8317 runs/s, 55.9439 assertions/s. …
brg
  • 3,915
  • 8
  • 37
  • 66
0
votes
1 answer

Upgrading to Rails 4.1 from 4.0, now all tests are broken

I upgraded my rails version to 4.1.1 from 4.0.4. Whenever I run rake test I get every test having this error: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "roles_users" does not exist LINE 1: DELETE FROM "roles_users" …
0
votes
2 answers

Split tests with Minitest 5 in Rails 4.1

I'm switching one of my projects to rails 4.1, which by default uses minitest version 5. I also use minitest-rails 2.0.1 gem. Before switching to minitest 5, in rails 4.0 when I ran rake test, it used to run model tests first, then controllers,…
CLod
  • 917
  • 2
  • 11
  • 28
0
votes
1 answer

ArgumentError: wrong number of arguments (2 for 1) for 'initialize'?

Fairly new to ruby, playing with Mini Test and log4r, trying to write a wrapper class. Getting the following error: $ ruby logger.rb Run options: --seed 4605 # Running tests: E Finished tests in 0.000000s, Inf tests/s, NaN assertions/s. 1)…
jbobbylopez
  • 257
  • 2
  • 6
  • 15
0
votes
1 answer

refactoring tests that use assert_raises

I have a test block: describe 'without' do describe 'author' do let(:author) {nil} it('fails') {assert_raises(ArgumentError) { excerpt }} end describe 'title' do # same content as above, but testing title end describe…
dax
  • 10,779
  • 8
  • 51
  • 86
0
votes
1 answer

Stuck in controller unit test error

I am getting this error on my controller. The relevant first lines are the following: Started at 2014-04-26 11:29:45 +0200 w/ seed 13696. …
patm
  • 1,420
  • 14
  • 19
0
votes
1 answer

How to run a minitest spec suite from ruby console?

I want to be able to run a spec suite from the console. Something like described here http://interblah.net/how-minitest-works, but with specs. No luck so far. Can someone give me a hint? Thanks.
robertokl
  • 1,869
  • 2
  • 18
  • 28
0
votes
1 answer

error on testing capybara minitest nested resouce

I'm making a simple app for users to make meetings. my seeds.rb file marshall = User.create!(name: 'Marshall', email: 'lanners.marshall@yahoo.com', password: '1234567', password_confirmation: '1234567') test_post1 = marshall.meetings.create!(title:…
user2785628
0
votes
2 answers

Is it possible to add a test that does not get autorunned?

I want to add a test for a one-off task, but once it runs, in the future it should not get run as part of the full suite.
Jason Kenney
  • 101
  • 1
  • 4