Skip to content

Commit

Permalink
Adding negative case for initialize check with ancestry
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebergen authored and kernow committed May 14, 2019
1 parent b6a97ef commit c47d22d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/shortcode/presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require "support/presenters/missing_for_presenter"
require "support/presenters/missing_initialize_presenter"
require "support/presenters/child_presenter"
require "support/presenters/child_missing_initialize_presenter"
require "support/presenters/missing_content_presenter"
require "support/presenters/missing_attributes_presenter"

Expand Down Expand Up @@ -109,6 +110,13 @@
end
end

context "when self and ancestory are missing #initialize method" do
it "raises an exception" do
expect { shortcode.register_presenter ChildMissingInitializePresenter }
.to raise_error(ArgumentError, "The presenter must define an initialize method")
end
end

context "when missing #content method" do
it "raises an exception" do
expect { shortcode.register_presenter MissingContentPresenter }
Expand Down
11 changes: 11 additions & 0 deletions spec/support/presenters/child_missing_initialize_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "support/presenters/parent_missing_initialize_presenter"

class ChildMissingInitializePresenter < ParentMissingInitializePresenter

def self.for; end

def content; end

def attributes; end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ParentMissingInitializePresenter
end

0 comments on commit c47d22d

Please sign in to comment.