Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code quality, fix bug, added chained methods, added new BDD methods. #51

Merged
merged 3 commits into from Aug 27, 2020
Merged

Code quality, fix bug, added chained methods, added new BDD methods. #51

merged 3 commits into from Aug 27, 2020

Conversation

ghost
Copy link

@ghost ghost commented Aug 18, 2020

fixes #48 .

Code Quality:

  • Specify public API now lives inside Specify.php, and private properties and methods inside Specify\SpecifyBoostrap.php for clarity and readability.
  • Added validations regarding whether the anonymous function is received as argument, and improved the names of the arguments depending on the called function.

Once and for all:

Good things, even better:

  • Added Fluent Interface support, this allows you to add it's and should's chained to a specify or describe. In this way, this example code:
    $this->describe("user", function() {
        $this->it("should have a name", function() {
            // do some asserts
        });

        $this->it("should not have long name", function() {
            // do more asserts
        });
    });

can now be written like this:

    $this->describe('user')
        ->it('should have a name', function() {
            // do some asserts
        })
        ->shouldNot('have long name', function() {
            // do more asserts
        })
    ;

Specify is smarter:

  • Added alias its for it, and added shouldNot as counterpart of should
  • Added .phpunit.result.cache file to .gitignore

Getting started:

  • As soon as this PR is merged, I will continue to add improvements to the tests and the other files inside the Codeception/Specify folder.
  • Some changes may require additional documentation, so improving the docs is one of the goals in sight in future commits.

@DavertMik , @Naktibalda I'll pay attention to your comments.

@Naktibalda
Copy link
Member

So many changes, I will try to understand what was changed another day.

@ghost
Copy link
Author

ghost commented Aug 20, 2020

they are in fact less than they appear to be.

  • Specify.php now has the public functions: specify, describe, it and should.
  • Whereas Specify/SpecifyBoostrap.php has the rest of the private functions and attributes from original file.
  • The functions specify, describe, it and should now return $this; to allow chained statements, and as I specified,
  • If an it or should only receives text now that test is marked as incomplete.
  • shouldNot and its were added as aliases.

If you need more help reviewing the changes, please let me know, I'll be as explicit as possible.
I know it takes time but I hope the benefits justify the time spent.

Copy link
Member

@DavertMik DavertMik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me, except naming things 😁
If you want to improve specify I would be glad to give all my support with it. As long as tests pass feel free to improve it.

Btw, please join Codeception Slack channel so we could discuss big changes like this upfront. When you are there - text me privately.

return $params['examples'];
}
return [[]];
use SpecifyBoostrap {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bootstrap maybe?

use ReflectionProperty;
use RuntimeException;

trait SpecifyBoostrap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bootstrap?

return $params['examples'];
}
return [[]];
use SpecifyBoostrap {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this naming:

SpecifyHooks

Before and After are hooks, we can name it like this

@DavertMik DavertMik merged commit 9848be0 into Codeception:master Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty specify() and describe() blocks pass tests
3 participants