-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to use each without attribute to test each element of subject.
- Loading branch information
Showing
5 changed files
with
219 additions
and
60 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
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,33 @@ | ||
Feature: each element of subject | ||
|
||
Use the each() method as a short-hand to generate a nested example group with | ||
a single example that specifies the expected value of each element of the | ||
subject. This can be used with an implicit or explicit subject. | ||
|
||
each() requires a block representing the example. | ||
|
||
each { should be_visible } | ||
|
||
Scenario: specify value of each element | ||
Given a file named "example_spec.rb" with: | ||
""" | ||
require 'rspec-subject-extensions' | ||
class Post | ||
def visible? | ||
true | ||
end | ||
end | ||
describe Post do | ||
subject { [Post.new, Post.new] } | ||
each { should be_visible } | ||
end | ||
""" | ||
When I run `rspec example_spec.rb --format documentation` | ||
Then the output should contain: | ||
""" | ||
Post | ||
each instance | ||
should be visible | ||
""" |
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