-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic tests for RSpec, although they don't work yet.
- Loading branch information
1 parent
94b648a
commit 0551434
Showing
15 changed files
with
394 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rubyTestExplorer": { | ||
"testFramework": "rspec" | ||
} | ||
} |
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,4 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "rspec" | ||
gem "rake" |
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,28 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
diff-lcs (1.4.4) | ||
rake (13.0.3) | ||
rspec (3.10.0) | ||
rspec-core (~> 3.10.0) | ||
rspec-expectations (~> 3.10.0) | ||
rspec-mocks (~> 3.10.0) | ||
rspec-core (3.10.1) | ||
rspec-support (~> 3.10.0) | ||
rspec-expectations (3.10.1) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.10.0) | ||
rspec-mocks (3.10.2) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.10.0) | ||
rspec-support (3.10.2) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
rake | ||
rspec | ||
|
||
BUNDLED WITH | ||
2.2.13 |
Empty file.
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,10 @@ | ||
class Abs | ||
def apply(n) | ||
case | ||
when n > 0 | ||
n | ||
when n == 0 | ||
raise "Abs for zero is not supported" | ||
end | ||
end | ||
end |
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,5 @@ | ||
class Square | ||
def apply(n) | ||
n + n | ||
end | ||
end |
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,17 @@ | ||
require "test_helper" | ||
|
||
describe Abs do | ||
it "finds the absolute value of 1" do | ||
expect(Abs.new.apply(1)).to eq(1) | ||
end | ||
|
||
it "finds the absolute value of 0" do | ||
expect(Abs.new.apply(0)).to eq(0) | ||
end | ||
|
||
it "finds the absolute value of -1" do | ||
skip | ||
expect(Abs.new.apply(-1)).to eq(1) | ||
end | ||
end | ||
|
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,12 @@ | ||
require "test_helper" | ||
|
||
describe Square do | ||
it "finds the square of 2" do | ||
expect(Square.new.apply(2)).to eq(4) | ||
end | ||
|
||
it "finds the square of 3" do | ||
expect(Square.new.apply(3)).to eq(9) | ||
end | ||
end | ||
|
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,5 @@ | ||
$LOAD_PATH << File.join(__dir__, "../lib") | ||
|
||
require "abs" | ||
require "square" | ||
require "rspec" |
File renamed without changes.
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,32 @@ | ||
import * as path from 'path'; | ||
import * as cp from 'child_process'; | ||
|
||
import { runTests, downloadAndUnzipVSCode, resolveCliPathFromVSCodeExecutablePath } from 'vscode-test'; | ||
|
||
async function main() { | ||
try { | ||
const extensionDevelopmentPath = path.resolve(__dirname, '../../'); | ||
|
||
const vscodeExecutablePath = await downloadAndUnzipVSCode('stable') | ||
|
||
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath) | ||
cp.spawnSync(cliPath, ['--install-extension', 'hbenl.vscode-test-explorer'], { | ||
encoding: 'utf-8', | ||
stdio: 'inherit' | ||
}) | ||
|
||
await runTests( | ||
{ | ||
extensionDevelopmentPath, | ||
extensionTestsPath: path.resolve(__dirname, './suite/frameworks/rspec/index'), | ||
launchArgs: [path.resolve(extensionDevelopmentPath, 'test/fixtures/rspec')] | ||
} | ||
); | ||
} catch (err) { | ||
console.error(err); | ||
console.error('Failed to run tests'); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); |
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,34 @@ | ||
import * as path from 'path'; | ||
import * as Mocha from 'mocha'; | ||
import * as glob from 'glob'; | ||
|
||
export function run(): Promise<void> { | ||
// Create the mocha test | ||
const mocha = new Mocha({ | ||
ui: 'tdd' | ||
}); | ||
|
||
return new Promise((c, e) => { | ||
glob('**.test.js', { cwd: __dirname }, (err, files) => { | ||
if (err) { | ||
return e(err); | ||
} | ||
|
||
// Add files to the test suite | ||
files.forEach(f => mocha.addFile(path.resolve(__dirname, f))); | ||
|
||
try { | ||
// Run the mocha test | ||
mocha.run(failures => { | ||
if (failures > 0) { | ||
e(new Error(`${failures} tests failed.`)); | ||
} else { | ||
c(); | ||
} | ||
}); | ||
} catch (err) { | ||
e(err); | ||
} | ||
}); | ||
}); | ||
} |
Oops, something went wrong.