Sha256: bfed1d9d746647e6e9eadeac3b9c61a20658d6282b09a5c2744c47019ab73a27
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
# frozen_string_literal: true require "assert" require "much-rails/destroy_action" module MuchRails::DestroyAction class UnitTests < Assert::Context desc "MuchRails::DestroyAction" subject{ unit_class } let(:unit_class){ MuchRails::DestroyAction } should "include MuchRails::Mixin" do assert_that(subject).includes(MuchRails::Mixin) end end class ReceiverTests < UnitTests desc "receiver" subject{ receiver_class } setup do Assert.stub_on_call(receiver_class, :change_result) do |call| @change_action_class_change_result_call = call end end let(:receiver_class) do Class.new do include MuchRails::DestroyAction destroy_result{ MuchRails::Result.success } on_call{} end end should have_imeths :destroy_result should "be configured as expected" do assert_that(subject).includes(MuchRails::ChangeAction) end should "call .change_result for its .destroy_result method" do subject.destroy_result assert_that(@change_action_class_change_result_call).is_not_nil end end class InitTests < ReceiverTests desc "when init" subject do receiver_class.new( params: {}, current_session: nil, request: nil, ) end should have_imeths :destroy_result should "call #change_result for its #destroy_result method" do Assert.stub_on_call(subject, :change_result) do |call| @change_action_instance_change_result_call = call end subject.destroy_result assert_that(@change_action_instance_change_result_call).is_not_nil end should "raise a custom error message if no destroy result block defined" do Assert.stub( receiver_class.much_rails_change_action_config, :change_result_block, ){ nil } exception = assert_that{ subject.destroy_result }.raises assert_that(exception.message) .equals("A `destroy_result` block must be defined.") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
much-rails-0.2.8 | test/unit/destroy_action_tests.rb |
much-rails-0.2.7 | test/unit/destroy_action_tests.rb |