diff --git a/lib/prawn/view.rb b/lib/prawn/view.rb index dbee949e0..c51436bb8 100644 --- a/lib/prawn/view.rb +++ b/lib/prawn/view.rb @@ -69,10 +69,10 @@ def document # Delegates all unhandled calls to object returned by +document+ method. # (which is an instance of Prawn::Document by default) - def method_missing(method_name, *arguments, &block) + def method_missing(method_name, *args, **kwargs, &block) return super unless document.respond_to?(method_name) - document.public_send(method_name, *arguments, &block) + document.public_send(method_name, *args, **kwargs, &block) end def respond_to_missing?(method_name, _include_all = false) diff --git a/spec/prawn/view_spec.rb b/spec/prawn/view_spec.rb index 237822a0f..3cf937b48 100644 --- a/spec/prawn/view_spec.rb +++ b/spec/prawn/view_spec.rb @@ -12,12 +12,12 @@ it 'delegates unhandled methods to object returned by document method' do doc = instance_double('Document') allow(view_object).to receive(:document).and_return(doc) - allow(doc).to receive(:some_delegated_method) + block = proc {} - view_object.some_delegated_method + view_object.some_delegated_method('positional', keyword: 'argument', &block) - expect(doc).to have_received(:some_delegated_method) + expect(doc).to have_received(:some_delegated_method).with('positional', keyword: 'argument', &block) end it 'allows a block-like DSL via the update method' do