forked from rspec/rspec-core
-
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.
ExampleGroup .its() creates new Example with a subject modifier
- Loading branch information
1 parent
a275d81
commit d4b365e
Showing
6 changed files
with
109 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require File.dirname(__FILE__) + '/spec_helper' | ||
|
||
module SubjectExample | ||
class OneThing | ||
attr_accessor :what_things_do | ||
def initialize | ||
self.what_things_do = "stuff" | ||
end | ||
end | ||
|
||
# implicit subject | ||
describe OneThing do | ||
it "should do what things do" do | ||
subject.what_things_do.should == "stuff" | ||
end | ||
it "should be a OneThing" do | ||
should == subject | ||
end | ||
its(:what_things_do) { should == "stuff" } | ||
end | ||
|
||
# explicit subject | ||
describe SubjectExample::OneThing do | ||
subject { SubjectExample::OneThing.new } | ||
it "should do what things do" do | ||
subject.what_things_do.should == "stuff" | ||
end | ||
it "should be a OneThing" do | ||
should == subject | ||
end | ||
its(:what_things_do) { should == "stuff" } | ||
end | ||
|
||
# modified subject | ||
describe OneThing do | ||
subject { SubjectExample::OneThing.new } | ||
before { subject.what_things_do = "more stuff" } | ||
it "should do what things do" do | ||
subject.what_things_do.should == "more stuff" | ||
end | ||
its(:what_things_do) { should == "more stuff" } | ||
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
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