-
Notifications
You must be signed in to change notification settings - Fork 0
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
Josep M. Bach
committed
Oct 30, 2010
1 parent
2f768f1
commit bbcc3b6
Showing
12 changed files
with
138 additions
and
55 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
stendhal (0.0.1) | ||
stendhal (0.1.0) | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
|
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,56 @@ | ||
Feature: Expectations | ||
|
||
Stendhal comes with some built-in expectations. | ||
|
||
Scenario: equality expectations | ||
Given a directory named "stendhal_project" | ||
When I cd to "stendhal_project" | ||
Given a file named "sample_spec.rb" with: | ||
""" | ||
describe "something" do | ||
it "does something" do | ||
(3 + 4).should == 7 | ||
6.should_not == 7 | ||
end | ||
end | ||
""" | ||
When I run "stendhal sample_spec.rb" | ||
Then the exit status should be 0 | ||
And the output should contain "1 example, 0 failures" | ||
|
||
Scenario: identity expectations | ||
Given a directory named "stendhal_project" | ||
When I cd to "stendhal_project" | ||
Given a file named "sample_spec.rb" with: | ||
""" | ||
describe "something" do | ||
it "does something" do | ||
6.should be_a(Fixnum) | ||
end | ||
end | ||
""" | ||
When I run "stendhal sample_spec.rb" | ||
Then the exit status should be 0 | ||
And the output should contain "1 example, 0 failures" | ||
|
||
Scenario: predicate expectations | ||
Given a directory named "stendhal_project" | ||
When I cd to "stendhal_project" | ||
Given a file named "sample_spec.rb" with: | ||
""" | ||
describe "something" do | ||
it "does something" do | ||
str = "String".freeze | ||
str.should be_frozen | ||
end | ||
end | ||
""" | ||
When I run "stendhal sample_spec.rb" | ||
Then the exit status should be 0 | ||
And the output should contain "1 example, 0 failures" |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module Stendhal | ||
class Example | ||
include Assertions | ||
include Matchers | ||
|
||
@@examples = [] | ||
|
||
|
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,5 @@ | ||
module Stendhal | ||
module Exceptions | ||
class ExpectationNotMet < StandardError; 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Stendhal | ||
module Expectations | ||
class EqualityExpectation; end | ||
class KindExpectation; end | ||
class PredicateExpectation; 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Stendhal | ||
module Matchers | ||
def ==(other) | ||
Stendhal::Expectations::EqualityExpectation.new(other) | ||
end | ||
def eq(other) | ||
Stendhal::Expectations::EqualityExpectation.new(other) | ||
end | ||
def be_a(kind) | ||
Stendhal::Expectations::KindExpectation.new(kind) | ||
end | ||
def method_missing(m,*args) | ||
if m.to_s =~ /be_(\w+)/ | ||
Stendhal::Expectations::PredicateExpectation.new(($1 + '?').to_sym) | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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,34 @@ | ||
require 'spec_helper' | ||
|
||
class MyClass | ||
include Stendhal::Matchers | ||
end | ||
|
||
module Stendhal | ||
describe "a class with included Matchers" do | ||
|
||
let(:object) { MyClass.new } | ||
|
||
describe "#==" do | ||
it 'creates a new equality expectation' do | ||
Expectations::EqualityExpectation.should_receive(:new).with(7) | ||
object == 7 | ||
end | ||
end | ||
|
||
describe "#be_a" do | ||
it 'creates a new kind expectation' do | ||
Expectations::KindExpectation.should_receive(:new).with(Fixnum) | ||
object.be_a(Fixnum) | ||
end | ||
end | ||
|
||
describe "#be_whatever" do | ||
it 'creates a new predicate expectation' do | ||
Expectations::PredicateExpectation.should_receive(:new).with(:frozen?) | ||
object.be_frozen | ||
end | ||
end | ||
|
||
end | ||
end |