Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3642020
commit 32e3f9f
Showing
1 changed file
with
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Feature: exist matcher | ||
|
||
The exist matcher is used to specify that something exists | ||
(as indicated by #exist?): | ||
|
||
obj.should exist # passes if obj.exist? | ||
|
||
Scenario: basic usage | ||
Given a file named "exist_matcher_spec.rb" with: | ||
""" | ||
class Planet | ||
attr_reader :name | ||
def initialize(name) | ||
@name = name | ||
end | ||
def inspect | ||
"<Planet: #{name}>" | ||
end | ||
def exist? | ||
%w[Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune].include?(name) | ||
end | ||
end | ||
describe "Earth" do | ||
subject { Planet.new("Earth") } | ||
it { should exist } | ||
it { should_not exist } # deliberate failure | ||
end | ||
describe "Tatooine" do | ||
subject { Planet.new("Tatooine") } | ||
it { should_not exist } | ||
it { should exist } # deliberate failure | ||
end | ||
""" | ||
When I run "rspec exist_matcher_spec.rb" | ||
Then the output should contain all of these: | ||
| 4 examples, 2 failures | | ||
| expected <Planet: Earth> not to exist | | ||
| expected <Planet: Tatooine> to exist | | ||
|