-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
SGML#each
to support the Rack interface
- Loading branch information
1 parent
9e5820d
commit 5a0bca2
Showing
2 changed files
with
33 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,26 @@ | ||
# frozen_string_literal: true | ||
|
||
class Example < Phlex::HTML | ||
def template | ||
h1 { "Hello, world!" } | ||
end | ||
end | ||
|
||
describe "#each" do | ||
it "returns an enumerator" do | ||
expect(Example.new.each).to be_a Enumerator | ||
expect(Example.new.each.to_a).to be == ([%(<h1>Hello, world!</h1>)]) | ||
end | ||
|
||
with "block" do | ||
it "yields each fragment to the block" do | ||
fragments = [] | ||
|
||
Example.new.each do |fragment| | ||
fragments << fragment | ||
end | ||
|
||
expect(fragments).to be == ([%(<h1>Hello, world!</h1>)]) | ||
end | ||
end | ||
end |