-
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.
Merge pull request #1 from coderfoxbrasil/hjjunior/fix-edge-cases
Adds tests of edge cases
- Loading branch information
Showing
8 changed files
with
133 additions
and
15 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
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
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
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,38 @@ | ||
<?php | ||
|
||
use function Cfx\PSpec\getSubject; | ||
use function Cfx\PSpec\subject; | ||
|
||
subject(fn () => 3); | ||
|
||
it('uses the root subject') | ||
->expect(getSubject(...)) | ||
->toEqual(3); | ||
|
||
describe('subject 1', function () { | ||
subject(fn () => 1); | ||
|
||
it('gets subject 1') | ||
->expect(getSubject(...)) | ||
->toEqual(1); | ||
|
||
describe('nested block', function () { | ||
it('gets subject 1') | ||
->expect(getSubject(...)) | ||
->toEqual(1); | ||
}); | ||
}); | ||
|
||
describe('subject 2', function () { | ||
subject(fn () => 2); | ||
|
||
it('gets subject 2') | ||
->expect(getSubject(...)) | ||
->toEqual(2); | ||
|
||
describe('nested block', function () { | ||
it('gets subject 2') | ||
->expect(getSubject(...)) | ||
->toEqual(2); | ||
}); | ||
}); |
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,48 @@ | ||
<?php | ||
|
||
use function Cfx\PSpec\get; | ||
use function Cfx\PSpec\getSubject; | ||
use function Cfx\PSpec\let; | ||
use function Cfx\PSpec\subject; | ||
|
||
describe('class_name', function () { | ||
subject(fn () => get('variable')); | ||
|
||
let('variable', fn () => 'from root'); | ||
|
||
it('gets the variable from root variable') | ||
->expect(getSubject(...)) | ||
->toEqual('from root'); | ||
|
||
describe('.method_name', function () { | ||
it('gets the variable from root variable') | ||
->expect(getSubject(...)) | ||
->toEqual('from root'); | ||
|
||
describe('can override', function () { | ||
let('variable', fn () => 'overrided'); | ||
|
||
it('gets the variable from local scope') | ||
->expect(getSubject(...)) | ||
->toEqual('overrided'); | ||
|
||
describe('sub nested block', function () { | ||
it('gets variable from parent block') | ||
->expect(getSubject(...)) | ||
->toEqual('overrided'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('no direct tests block', function () { | ||
subject(fn () => get('variable2')); | ||
|
||
let('variable2', fn () => 'from root'); | ||
|
||
describe('nested block', function () { | ||
it('gets the variable from root variable') | ||
->expect(getSubject(...)) | ||
->toEqual('from root'); | ||
}); | ||
}); |
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 @@ | ||
<?php | ||
|
||
use function Cfx\PSpec\get; | ||
use function Cfx\PSpec\getSubject; | ||
use function Cfx\PSpec\let; | ||
use function Cfx\PSpec\subject; | ||
|
||
describe('no direct tests block', function () { | ||
subject(fn () => get('variable2')); | ||
|
||
let('variable2', fn () => 'from root'); | ||
|
||
describe('nested block', function () { | ||
it('gets the variable from root variable') | ||
->expect(getSubject(...)) | ||
->toEqual('from root'); | ||
}); | ||
}); |