Skip to content

Commit

Permalink
feat(ruby-version): used rbenv to install the defined ruby version
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed Aug 19, 2019
1 parent 77bcc7e commit 0d29fbc
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 42 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ opinionated scaffolder for Ruby projects
$ npm install @form8ion/ruby-scaffolder --save
```

### Dependencies

It is expected that [rbenv](https://github.com/rbenv/rbenv) is available for
managing [Ruby](https://www.ruby-lang.org/en/) versions. This scaffolder will
leverage [rbenv](https://github.com/rbenv/rbenv) to install the version of
[Ruby](https://www.ruby-lang.org/en/) that is defined in the generated
`.ruby-version` file.

## Contributing

<!-- contribution badges -->
Expand Down
126 changes: 85 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,7 @@
"sinon": "^7.4.1",
"travis-lint": "^1.0.0"
},
"dependencies": {}
"dependencies": {
"execa": "^2.0.4"
}
}
3 changes: 3 additions & 0 deletions src/ruby-version-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {promises as fsPromises} from 'fs';
import {assert} from 'chai';
import sinon from 'sinon';
import any from '@travi/any';
import * as execa from '../thirdparty-wrappers/execa';
import scaffoldRubyVersion from './ruby-version';

suite('ruby-version', () => {
Expand All @@ -11,6 +12,7 @@ suite('ruby-version', () => {
sandbox = sinon.createSandbox();

sandbox.stub(fsPromises, 'writeFile');
sandbox.stub(execa, 'default');
});

teardown(() => sandbox.restore());
Expand All @@ -21,5 +23,6 @@ suite('ruby-version', () => {
await scaffoldRubyVersion(projectRoot);

assert.calledWith(fsPromises.writeFile, `${projectRoot}/.ruby-version`, '2.6.3');
assert.calledWith(execa.default, 'rbenv', ['install']);
});
});
3 changes: 3 additions & 0 deletions src/ruby-version.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {promises} from 'fs';
import execa from '../thirdparty-wrappers/execa';

export default async function (projectRoot) {
await promises.writeFile(`${projectRoot}/.ruby-version`, '2.6.3');

await execa('rbenv', ['install']);
}
5 changes: 5 additions & 0 deletions test/integration/features/step_definitions/common-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import {promisify} from 'util';
import {resolve} from 'path';
import stubbedFs from 'mock-fs';
// import bddStdIn from 'bdd-stdin';
import sinon from 'sinon';
import {assert} from 'chai';
import any from '@travi/any';
import {After, Before, Given, Then, When} from 'cucumber';
import * as execa from '../../../../thirdparty-wrappers/execa';
import {scaffold} from '../../../../src';

let scaffoldResult;
Expand All @@ -23,6 +25,9 @@ Before(async function () {
'Rakefile.rb': await readFile(resolve(__dirname, '../../../../', 'templates/Rakefile.rb'))
}
});

this.sinonSandbox = sinon.createSandbox();
this.sinonSandbox.stub(execa, 'default');
});

After(function () {
Expand Down
3 changes: 3 additions & 0 deletions thirdparty-wrappers/execa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import execa from 'execa';

export default execa;

0 comments on commit 0d29fbc

Please sign in to comment.