-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Symbols to be used as selectors
This commit allows using a Symbol as a selector. The symbol is converted to a String using `to_s`. ```ruby class TodoIndex < PageEz::Page has_one :heading, :h1 end ``` ```ruby todo_index = TodoIndex.new expect(todo_index).to have_heading(text: "Hello") ```
- Loading branch information
1 parent
36abf53
commit 6810607
Showing
2 changed files
with
39 additions
and
1 deletion.
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,38 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe "Selectors" do | ||
it "allows string selectors" do | ||
page = build_page(<<-HTML) | ||
<h1>Hello</h1> | ||
HTML | ||
|
||
test_page = Class.new(PageEz::Page) do | ||
has_one :heading, "h1" | ||
end.new(page) | ||
|
||
page.visit "/" | ||
|
||
expect(test_page).to have_heading | ||
end | ||
|
||
it "allows symbol selectors" do | ||
page = build_page(<<-HTML) | ||
<h1>Hello</h1> | ||
HTML | ||
|
||
test_page = Class.new(PageEz::Page) do | ||
has_one :heading, :h1 | ||
end.new(page) | ||
|
||
page.visit "/" | ||
|
||
expect(test_page).to have_heading | ||
end | ||
|
||
def build_page(markup) | ||
AppGenerator | ||
.new | ||
.route("/", markup) | ||
.run | ||
end | ||
end |