Last active
December 28, 2015 14:49
-
-
Save jonahoffline/7517035 to your computer and use it in GitHub Desktop.
Added the done() callback to make the spec asynchronous.
(from Jeff Dickley's "Trust, Tools, and Tripping Over Shoelaces While Dancing" blog post - http://archlever.blogspot.com/2013/11/trust-tools-and-tripping-over-shoelaces.html)
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
#= require 'gateway' | |
describe 'Gateway class', -> | |
beforeEach (done) -> | |
@subject = new window.meldd.Gateway() | |
@name = 'foo' | |
@value = $('body') | |
done() | |
# other specs elided... | |
describe 'has a "useGroup" method that', -> | |
it 'takes one parameter', (done) -> | |
expect(@subject.useGroup).to.have.length 1 | |
done() | |
describe 'when called using', -> | |
it 'a nonexistent group name, returns an empty object hash', (done) -> | |
group = @subject.useGroup 'not found' | |
expect(group).to.be.an 'object' | |
expect(group).to.be.empty() | |
done() | |
describe 'a group with one key, returns an object', -> | |
beforeEach (done) -> | |
@subject.register 'foo', 'bar', 'group1' | |
@group = @subject.useGroup 'group1' | |
done() | |
it 'hash', (done) -> | |
expect(@group).to.be.an 'object' | |
done() | |
it 'with the correct single item name as the only key', (done) -> | |
expect(@subject.groups['group1'][0]).to == 'bar' | |
expect(Object.keys(@group)).to == ['foo'] | |
done() | |
it 'with the correct item value as the only value', (done) -> | |
expect(@group['foo']).to == 'bar' | |
done() | |
describe 'two groups with one identical key, returns', -> | |
beforeEach (done) -> | |
@subject.register 'this', @, 'group1', 'group2' | |
@group1 = @subject.useGroup 'group1' | |
@group2 = @subject.useGroup 'group2' | |
done() | |
it 'the identical object in both groups', (done) -> | |
# equality to avoid "Converting circular structure to JSON" error | |
expect(@group1['this']).to == @ | |
expect(@group2['this']).to == @ | |
# identity; they're the exact same object instance | |
expect(@group1['this']).to.be @group2['this'] | |
done() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment