Sha256: 0099a8c2428bc27ccaf8a4f74d446b71eab2ea0db17a8d97b925ce06969b57d4

Contents?: true

Size: 1.34 KB

Versions: 18

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require "assert"
require "much-rails/call_method"

module MuchRails::CallMethodTest
  class UnitTests < Assert::Context
    desc "MuchRails::CallMethod"
    subject{ unit_class }

    let(:unit_class){ MuchRails::CallMethod }

    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_tap(subject, :new) do |new_object|
        @new_class_method_called = true

        Assert.stub(new_object, :on_call) do
          @on_call_instance_method_called = true
        end
      end
    end

    let(:receiver_class) do
      Class.new do
        include MuchRails::CallMethod
      end
    end

    should have_imeths :call

    should "call #new and #call" do
      subject.call

      assert_that(@new_class_method_called).is_true
      assert_that(@on_call_instance_method_called).is_true
    end
  end

  class ReceiverWithOnCallNotImplemented < UnitTests
    desc "with the #on_call method not implemented"
    subject{ receiver_class }

    let(:receiver_class) do
      Class.new do
        include MuchRails::CallMethod
      end
    end

    should "not implement its #call method" do
      assert_that(->{ subject.call }).raises(NotImplementedError)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
much-rails-0.4.3 test/unit/call_method_tests.rb
much-rails-0.4.2 test/unit/call_method_tests.rb
much-rails-0.4.1 test/unit/call_method_tests.rb
much-rails-0.4.0 test/unit/call_method_tests.rb
much-rails-0.3.0 test/unit/call_method_tests.rb
much-rails-0.2.8 test/unit/call_method_tests.rb
much-rails-0.2.7 test/unit/call_method_tests.rb
much-rails-0.2.6 test/unit/call_method_tests.rb
much-rails-0.2.5 test/unit/call_method_tests.rb
much-rails-0.2.4 test/unit/call_method_tests.rb
much-rails-0.2.3 test/unit/call_method_tests.rb
much-rails-0.2.2 test/unit/call_method_tests.rb
much-rails-0.2.1 test/unit/call_method_tests.rb
much-rails-0.2.0 test/unit/call_method_tests.rb
much-rails-0.1.3 test/unit/call_method_tests.rb
much-rails-0.1.2 test/unit/call_method_tests.rb
much-rails-0.1.1 test/unit/call_method_tests.rb
much-rails-0.1.0 test/unit/call_method_tests.rb