-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Adding tests for Phlex::HtmlRenderable
- Loading branch information
1 parent
a5174dc
commit 5d6b6dd
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
describe Phlex::HTML do | ||
extend ViewHelper | ||
|
||
with "text" do | ||
html_renderable_view do | ||
def template | ||
plain "Hi" | ||
end | ||
end | ||
|
||
it "produces the correct output" do | ||
expect(output).to be == "Hi" | ||
end | ||
end | ||
|
||
with "int as text" do | ||
view do | ||
def template | ||
plain 1 | ||
end | ||
end | ||
|
||
it "produces the correct output" do | ||
expect(output).to be == "1" | ||
end | ||
end | ||
|
||
with "float as text" do | ||
view do | ||
def template | ||
plain 2.0 | ||
end | ||
end | ||
|
||
it "produces the correct output" do | ||
expect(output).to be == "2.0" | ||
end | ||
end | ||
|
||
with "an object that has no special format_object handling" do | ||
view do | ||
def template | ||
plain Object.new | ||
end | ||
end | ||
|
||
it "raises an ArgumentError" do | ||
expect { output }.to raise_exception(ArgumentError) | ||
end | ||
end | ||
end |