Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Contributing

## New Features

To develop new features execute the following steps:

1. `git clone` the repository
2. Run `npm install`
3. Open VSCode
4. Go to the `Debug` side menu
5. Select the `Launch Tests` options and press play
6. Once the tests pass, you're ready to go!
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"title": "Run Last Spec"
}
],
"keybindings":[
"keybindings": [
{
"command": "extension.runFileSpecs",
"key": "cmd+shift+t"
Expand Down Expand Up @@ -101,7 +101,7 @@
"default": 2000
},
"ruby.specSaveFile": {
"type":"boolean",
"type": "boolean",
"description": "Auto Save file before running spec test",
"default": false
}
Expand Down
7 changes: 5 additions & 2 deletions src/utils/toSpecPath.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
export default function toSpecPath(filePath: string) {
let [first, ...rest] = filePath.split('/');
let middle = rest.slice(0, rest.length - 1);
let filename = rest[rest.length - 1];

if (filePath.match(/_spec\.rb/) || first === 'spec') {
return filePath
} else if (first !== 'app') {
return ['spec', first, ...middle, filename.replace('.rb', '_spec.rb')].join('/');
} else {
let middle = rest.slice(0, rest.length - 1);
let filename = rest[rest.length - 1];
return ['spec', ...middle, filename.replace('.rb', '_spec.rb')].join('/');
}
}
8 changes: 8 additions & 0 deletions test/utils/toSpecPath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ suite("toSpecPath", () => {
toSpecPath('spec/controllers/namespaces/admin/test_controller_spec.rb')
);
})
suite("when current file is not inside 'app' folder", () => {
test("it should preserve the whole path", () => {
assert.equal(
'spec/lib/utils/custom_calculator_spec.rb',
toSpecPath('lib/utils/custom_calculator.rb')
);
})
});
});