「assertありゃええねん」

前回のdecoratorのテストのassertをminitest-power_assertに変えてみた。
# Gemfile:
group :test do
  gem 'minitest-power_assert'
end

わざと間違えてみる。

# test/decorators/user_decorator_test.rb:
require 'test_helper'

class UserDecoratorTest < ActiveSupport::TestCase
  def setup
    ActiveDecorator::ViewContext.current = controller.view_context
    @user = ActiveDecorator::Decorator.instance.decorate users(:jean)
  end

  test 'full_name' do
    assert { @user.full_name == 'Hugh Jackman' }
  end
end
$ rake test test/decorators/user_decorator_test.rb
Run options: --seed 52969

# Running:

F

Finished in 0.134274s, 7.4475 runs/s, 7.4475 assertions/s.

  1) Failure:
UserDecoratorTest#test_full_name [/Users/komagata/code/active_decorator-test_unit/test/decorators/user_decorator_test.rb:10]:

    assert { @user.full_name == 'Hugh Jackman' }
             |     |         |
             |     |         false
             |     "Jean Valjean"
             #<User id: 758109964, first_name: "Jean", last_name: "Valjean", website: "http://jeanvaljean.com", created_at: "2014-07-01 15:35:12", updated_at: "2014-07-01 15:35:12">

1 runs, 1 assertions, 1 failures, 0 errors, 0 skips

こりゃええ!

Comments


(Option)