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

Ruby on Rails: MiniTest for email validation

This is an absolute beginners question, it's probably pretty obvious but I couldn't find the answer yet. I'm trying to validate an email address in Ruby on Rails using minitest. test "should have format of email address" do user =…
loxosceles
  • 347
  • 5
  • 21
0
votes
1 answer

Test Unit Capybara not able to get query last inserted record

I am using test unit with fixtures using the standard rails testing framework. I am running some tests using capybara and I am unable to find the last inserted record when I run my model find after the insert. I open up my database editor and I see…
Jacob Waller
  • 4,119
  • 3
  • 26
  • 32
0
votes
2 answers

Agile Web Development with Rails 4: MiniTest error for Update action in line_items_controller_test.rb

I'm a beginner working my way through Agile Web Development with Rails 4 where we (readers) build a shopping-cart style demo app. So, far the main REST resources are 1) products, 2) carts and 3) line items. This is my second demo/sample app on my…
Ben
  • 197
  • 3
  • 11
0
votes
0 answers

Rerun a specific test once on failure

I have a flapping test in my test suite - it fails once out of every hundred runs or so. However, this is kind of expected behavior as it's a test for a algorithm that runs a lot of things and returns a result - every once in while a result just…
dax
  • 10,779
  • 8
  • 51
  • 86
0
votes
1 answer

Minitest - NoMethodError: undefined method `get'

I was stuck with error when i run very simple test with minitest-rails gem. I have rails 4.1.5 and minitest 5.4.0 rake test:controllers 1) Error: DashboardController::index action#test_0001_anonymous: NoMethodError: undefined method get' for…
rootatdarkstar
  • 1,486
  • 2
  • 15
  • 26
0
votes
0 answers

minitest mode in emacs running from home directory instead of project directory

When I try and run a test by pressing C-c ,s the test is not being run from the project directory but from my home directory, e.g. bundle exec ruby -Ilib\:test\:spec /Users/paulcowan/projects/crm/test/integration/contacts/import_contact_test.rb…
dagda1
  • 26,856
  • 59
  • 237
  • 450
0
votes
1 answer

How do you load Rails test environment with test db?

I want to load the test environment for Rails to run my minitest tests. I require config/environment.rb after setting RAILS_ENV to 'test'. It seems that this is not the correct way to do it because the test database doesn't seem to be created. I…
user2536065
0
votes
1 answer

MiniTest falis with jruby rake test task

I have a project with self written gems in jruby (using rvm to switch between jrubies). With jruby-1.7.0 I could do my tests with Test::Unit::TestCase. Now I have switched to MiniTest in jruby-1.7.13. But I cannot run my tests any more with 'rake…
0
votes
2 answers

calling single tests works but not running all tests in MiniTest

I switched from Test Unit to MiniTest in jruby-1.7.13. I also use mocha/integration. My problem is that running 'rake test' brings up Mocha::ExpectationError: unexpected invocation: MyClass.new. With MyClass.new beeing a class defined in the lib…
0
votes
1 answer

rails minitest bdd how to specify which test superclass to use

Using a Grape API and add the tests in the Rakefile. Its a Rack application mounted on the main rails app. namespace :test do Rake::TestTask.new(:api) do |t| t.pattern = 'test/api/**/*_test.rb' end end Rake::Task[:test].enhance […
AJcodez
  • 31,780
  • 20
  • 84
  • 118
0
votes
0 answers

emacs minitest mode not running in the emacs terminal but fine in the normal terminal

I am trying to be able to use mini-test mode to enable me to activate and run my tests directly from emacs. The relevant ruby part of my ~/.emacs, looks like this: (add-hook 'ruby-mode-hook 'robe-mode) (add-to-list 'auto-mode-alist …
dagda1
  • 26,856
  • 59
  • 237
  • 450
0
votes
1 answer

Problems running Test::Unit with Guard on Rails 4.1.1 and Ruby 2.1.2

I'm upgrading an app from Rails 3.2 using Ruby 2.0 to Rails 4.1 using Ruby 2.1. Running our Test::Unit tests with rake test works perfectly fine, but running the tests with guard is a failure. 15:30:14 - INFO - Guard::Test 2.0.5 is running, with…
naikipl
  • 471
  • 3
  • 5
0
votes
3 answers

Writing test for controller method

I have a protected method in controller and need to write the test case for it. The method is def source @source.present? ? @source.class : Association.reflect_on_association(source.to_sym).klass end where @source will be an object and source…
vikram
  • 423
  • 4
  • 19
0
votes
1 answer

assert_select expectation contradicting itself (ruby)

This is the code in my test: assert_select "a[href=?]", "/path/with?params", { :count => 1, :text => "" } And this is the failure message I get: Expected exactly 1 element matching "a[href='/path/with?params']", found 0.. Expected: 0 Actual: 1 Any…
sebkkom
  • 1,426
  • 17
  • 31
0
votes
2 answers

cucumber + capybara = has_content? returns true everytime

i'm using following: minitest 5.3.5 cucumber 1.3.15 capybara 2.3.0 capybara_minitest_spec 1.0.2 rails 4.1.1 cucumber-rails 1.4.1 and my cucumber/capybara code Then(/^I should see "(.*?)"$/) do |string| page.has_content?(string) end with any…
Alexey Poimtsev
  • 2,845
  • 3
  • 35
  • 63