README.md in rspec-subject-extensions-0.2.3 vs README.md in rspec-subject-extensions-0.3.0
- old
+ new
@@ -1,16 +1,17 @@
# RSpec Subject Extensions [](http://travis-ci.org/ZenCocoon/rspec-subject-extensions)
rspec-subject-extensions adds `each` short-hand to generate a nested example group with
a single example that specifies the expected value of each attribute of the subject.
+If no attribute is given, each element of the subject will be used.
## Documentation
The [Cucumber features](http://relishapp.com/ZenCocoon/rspec-subject-extensions)
are the most comprehensive and up-to-date docs for end-users.
-The [RDoc](http://rubydoc.info/gems/rspec-subject-extensions/0.2.3/frames) provides
+The [RDoc](http://rubydoc.info/gems/rspec-subject-extensions/0.3.0/frames) provides
additional information for contributors and/or extenders.
All of the documentation is open source and a work in progress. If you find it
lacking or confusing, you can help improve it by submitting requests and
patches to the [rspec-subject-extensions issue
@@ -28,10 +29,12 @@
## Usage
### Each
+#### Using the singular name of the attributes
+
Creates a nested example group named by `each` and the submitted `attribute`,
and then generates an example for each attribute using the submitted block.
# This ...
describe Object do
@@ -48,9 +51,31 @@
end
end
end
The `attribute` can be a `Symbol` or a `String`.
+
+#### Using no attribute. Ideal to test scopes
+
+Creates a nested example group and then generates an example
+for each instance using the submitted block.
+
+ # This ...
+ describe Object do
+ subject { Object.visible }
+ each { should be_visible }
+ end
+
+ # ... generates the same runtime structure as this:
+ describe Object do
+ describe "each instance" do
+ it "should be visible" do
+ subject.each do |element|
+ element.should be_visible
+ end
+ end
+ end
+ end
## Also see
* [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
* [http://github.com/rspec/rspec-core](http://github.com/rspec/rspec-core)