Created
November 16, 2011 04:20
-
-
Save searls/1369224 to your computer and use it in GitHub Desktop.
jasmine-given example
This file contains hidden or 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
class MakesSandwiches | |
make: -> cheese: "swiss", bread: "sourdough" |
This file contains hidden or 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
#jasmine-given | |
describe "MakesSandwiches", -> | |
Given -> @subject = new MakesSandwiches | |
describe "#make", -> | |
When -> @sandwich = @subject.make() | |
Then -> expect(@sandwich).toHave("bread") | |
Then -> expect(@sandwich).toHave("cheese") | |
#vanilla jasmine | |
describe "MakesSandwiches", -> | |
beforeEach -> | |
@subject = new MakesSandwiches | |
describe "#make", -> | |
beforeEach -> | |
@sandwich = @subject.make() | |
it "has bread", -> | |
expect(@sandwich).toHave("bread") | |
it "has cheese", -> | |
expect(@sandwich).toHave("cheese") | |
#a custom matcher for toHave()'ing properties. | |
beforeEach -> | |
@addMatchers | |
toHave: (property) -> | |
@actual.hasOwnProperty(property) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment