-
Notifications
You must be signed in to change notification settings - Fork 15
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
Showing
3 changed files
with
156 additions
and
1 deletion.
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
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,81 @@ | ||
describe 'Capybara specs', -> | ||
|
||
specs = null | ||
ACTION_DATA_MOCK = | ||
type : 'action', | ||
name : 'clickLink', | ||
locator: 'foobar', | ||
scope : null | ||
options: {} | ||
MATCHER_DATA_MOCK = | ||
type : 'matcher', | ||
name : 'shouldHaveSelector', | ||
selector: '#foo', | ||
scope : null | ||
options : {} | ||
SCOPED_ACTION_DATA_MOCK = | ||
_.extend {}, ACTION_DATA_MOCK, scope: 'form-scope' | ||
|
||
beforeEach -> | ||
specs = new Capybara.Specs tabURL: '/foo' | ||
|
||
describe '#add', -> | ||
|
||
it 'should store the added generators', -> | ||
before = specs.generators.length | ||
specs.add { type: 'action' } | ||
expect(specs.generators.length).toBeGreaterThan(before) | ||
|
||
describe '#setName', -> | ||
|
||
it 'should change the specs name', -> | ||
specs.setName 'foo' | ||
expect(specs.name).toBe('foo') | ||
|
||
describe '#generate', -> | ||
|
||
it 'should generate basic structure', -> | ||
expectedOutput = """ | ||
it 'SHOULDDOSOMETHING' do | ||
visit('/foo') | ||
end | ||
""" | ||
expect(specs.generate()).toEqual(expectedOutput) | ||
|
||
describe 'actions', -> | ||
|
||
it 'should wrap action generator output', -> | ||
specs.add(ACTION_DATA_MOCK) | ||
expectedOutput = """ | ||
it 'SHOULDDOSOMETHING' do | ||
visit('/foo') | ||
click_link('foobar') | ||
end | ||
""" | ||
expect(specs.generate()).toEqual(expectedOutput) | ||
|
||
describe 'with scope', -> | ||
|
||
it 'should wrap the generator output', -> | ||
specs.add(SCOPED_ACTION_DATA_MOCK) | ||
expectedOutput = """ | ||
it 'SHOULDDOSOMETHING' do | ||
visit('/foo') | ||
within('form-scope') do | ||
click_link('foobar') | ||
end | ||
end | ||
""" | ||
expect(specs.generate()).toEqual(expectedOutput) | ||
|
||
describe 'matchers', -> | ||
|
||
it 'should wrap matcher generator output', -> | ||
specs.add(MATCHER_DATA_MOCK) | ||
expectedOutput = """ | ||
it 'SHOULDDOSOMETHING' do | ||
visit('/foo') | ||
page.should have_selector('#foo') | ||
end | ||
""" | ||
expect(specs.generate()).toEqual(expectedOutput) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.