-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add syntatic sugar to have_selector and have_text matchers
- Loading branch information
Showing
6 changed files
with
57 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,36 @@ | ||
# frozen_string_literal: true | ||
|
||
module Capybara | ||
module RSpecMatchers | ||
module CountSugar | ||
def once; exactly(1); end | ||
def twice; exactly(2); end | ||
def thrice; exactly(3); end | ||
|
||
def exactly(number) | ||
options[:count] = number | ||
self | ||
end | ||
|
||
def at_most(number) | ||
options[:maximum] = number | ||
self | ||
end | ||
|
||
def at_least(number) | ||
options[:minimum] = number | ||
self | ||
end | ||
|
||
def times | ||
self | ||
end | ||
|
||
private | ||
|
||
def options | ||
(@args.last.is_a?(Hash) ? @args : @args.push({})).last | ||
end | ||
end | ||
end | ||
end |
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
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