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

Allow environment variables to configure options #73

Merged
merged 5 commits into from Apr 23, 2015
Merged

Conversation

@hofan41
Copy link
Contributor

hofan41 commented Apr 14, 2015

Closes #72

Changed from using Joi.assert() to Joi.validate(), use Joi.validate()'s
transformed result object for settings instead of using the input
parameter which may not be type safe.
@hofan41 hofan41 changed the title Issue #72 Allow environment variables to configure options Allow environment variables to configure options Apr 14, 2015
@geek geek added the feature label Apr 20, 2015
@geek geek self-assigned this Apr 20, 2015
@geek

This comment has been minimized.

Copy link
Member

geek commented Apr 20, 2015

This looks good. Please add a couple of tests for making the environment variable be passed in. Also, can you add details to the documentation on using environment variables with bell?

Support for configuration via environment variables.
@hofan41

This comment has been minimized.

Copy link
Contributor Author

hofan41 commented Apr 22, 2015

Hi geek,
I am at an impasse.

How would you recommend I approach the tests? I can either copy an existing test that tests functionality that relies on a boolean input option, or I can mock/spy within the scheme function and confirm that the cookie settings are correctly interpreted.

There are pros and cons to both: copying an existing test is easy, but not easy to scale and becomes a maintenance problem. mock/spy is not readily available because the server object passed to the scheme function is not the same server object that is supplied by the test (hapi uses a server._clone).

Confirms that settings are correctly interpreted when they are strings.
@hofan41

This comment has been minimized.

Copy link
Contributor Author

hofan41 commented Apr 22, 2015

Committed the mock/spy test. I ended up spying the resultant OAuth.v1 call instead of server.state. I hope this is acceptable.

@geek geek added this to the 2.4.0 milestone Apr 22, 2015
@@ -6,7 +6,8 @@ var Hapi = require('hapi');
var Hoek = require('hoek');
var Lab = require('lab');
var Mock = require('./mock');

var Sinon = require('sinon');

This comment has been minimized.

Copy link
@geek

geek Apr 22, 2015

Member

Please move this above the Mock require

@@ -23,6 +24,48 @@ var expect = Code.expect;

describe('Bell', function () {

it('supports string representations of boolean and number strategy options', function(done) {

This comment has been minimized.

Copy link
@geek

geek Apr 22, 2015

Member

function (done) {

}
});

expect( spy.calledOnce ).to.be.true();

This comment has been minimized.

Copy link
@geek

geek Apr 22, 2015

Member

expect(spy.calledOnce).to.be.true();

no need for extra spaces in ()

@geek

This comment has been minimized.

Copy link
Member

geek commented Apr 22, 2015

Looks good, just a few minor style items

geek added a commit that referenced this pull request Apr 23, 2015
Allow environment variables to configure options
@geek geek merged commit c6c023f into hapijs:master Apr 23, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.