lundi 29 février 2016

Rails Minitest not executing last assertion

This is my test:

require 'test_helper'

class ProvinceTest < ActiveSupport::TestCase
  def setup
    @country = Country.find_by_iso("AO")
  end

  test "name has to be unique for its country" do
    exception = assert_raises(RecordInvalid) { @country.provinces.create!(name: "Luanda") }
    assert_equal "Has to have unique name for its country", exception.message
  end
end

The problem I'm having is that assert_equal "Has to have unique name for its country", exception.message it's not being executed (I know because I tried to execute a several commands between both assertions and they're not executed. However, whatever I put before the first assertion it will be executed.

What happens and why the test doesn't execute the second assertion?

I followed this question to build the test: Rails ActiveSupport: How to assert that an error is raised?

Aucun commentaire:

Enregistrer un commentaire