Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit e1cb669

Browse files
authored
Merge pull request #416 from kazk/fix/LF/crystal
[Crystal] Fix LF issue
2 parents a9b1f72 + 3a1e37c commit e1cb669

File tree

2 files changed

+53
-24
lines changed

2 files changed

+53
-24
lines changed

frameworks/crystal/formatter.cr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ module Spec
66
end
77

88
def self.example(msg, mode = "")
9-
puts format_message("<LOG:#{mode.upcase}:Example>#{msg}")
9+
puts format_message("\n<LOG:#{mode.upcase}:Example>#{msg}")
1010
end
1111

1212
def self.log(msg, mode = "", label = "")
13-
puts format_message("<LOG:#{mode.upcase}:#{label}>#{msg}")
13+
puts format_message("\n<LOG:#{mode.upcase}:#{label}>#{msg}")
1414
end
1515

1616
class RootContext
1717
def print_results(elapsed_time)
18-
puts "<COMPLETEDIN::>#{Spec.to_human(elapsed_time)}"
18+
puts "\n<COMPLETEDIN::>#{Spec.to_human(elapsed_time)}"
1919
end
2020
end
2121

@@ -25,15 +25,15 @@ module Spec
2525
end
2626

2727
def push(context)
28-
puts "<DESCRIBE::>#{Spec.format_message(context.description)}"
28+
puts "\n<DESCRIBE::>#{Spec.format_message(context.description)}"
2929
end
3030

3131
def pop
32-
puts "<COMPLETEDIN::>"
32+
puts "\n<COMPLETEDIN::>"
3333
end
3434

3535
def before_example(description)
36-
puts "<IT::>#{Spec.format_message(description)}"
36+
puts "\n<IT::>#{Spec.format_message(description)}"
3737
end
3838

3939
def report(result)
@@ -49,18 +49,18 @@ module Spec
4949

5050
case result.kind
5151
when :success
52-
puts "<PASSED::>Test Passed"
52+
puts "\n<PASSED::>Test Passed"
5353
when :fail
54-
puts "<FAILED::>Test Failed: #{msg}"
54+
puts "\n<FAILED::>Test Failed: #{msg}"
5555

5656
when :error
57-
puts "<ERROR::>#{msg}"
57+
puts "\n<ERROR::>#{msg}"
5858
end
5959

6060
if result.exception
61-
puts "<ERROR::>#{Spec.format_message(result.exception.to_s)}"
61+
puts "\n<ERROR::>#{Spec.format_message(result.exception.to_s)}"
6262
end
63-
puts "<COMPLETEDIN::>"
63+
puts "\n<COMPLETEDIN::>"
6464
end
6565

6666
def finish

test/runners/crystal_spec.js

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ describe('crystal runner', function() {
77
runner.assertCodeExamples('crystal');
88

99
it('should handle basic code evaluation', function(done) {
10-
runner.run({language: 'crystal', code: 'puts 42'}, function(buffer) {
10+
runner.run({
11+
language: 'crystal',
12+
code: 'puts 42'
13+
}, function(buffer) {
1114
expect(buffer.stdout).to.equal('42\n');
1215
done();
1316
});
@@ -18,12 +21,14 @@ describe('crystal runner', function() {
1821
runner.run({
1922
language: 'crystal',
2023
code: 'a = 1',
21-
fixture: 'describe "test" do\n' +
22-
'it("test2") { 1.should eq(1)}\n' +
23-
'end',
24+
fixture: [
25+
'describe "test" do',
26+
' it("test2") { 1.should eq(1) }',
27+
'end',
28+
].join('\n'),
2429
testFramework: 'spec'
2530
}, function(buffer) {
26-
expect(buffer.stdout).to.include('<DESCRIBE::>test\n<IT::>test2\n<PASSED::>');
31+
expect(buffer.stdout).to.include('<DESCRIBE::>test\n\n<IT::>test2\n\n<PASSED::>');
2732
done();
2833
});
2934
});
@@ -32,32 +37,56 @@ describe('crystal runner', function() {
3237
runner.run({
3338
language: 'crystal',
3439
code: 'a = 1',
35-
fixture: 'describe "test" do\n' +
36-
'it("test2") { 1.should eq(2)}\n' +
37-
'end',
40+
fixture: [
41+
'describe "test" do',
42+
' it("test2") { 1.should eq(2) }',
43+
'end',
44+
].join('\n'),
3845
testFramework: 'spec'
3946
}, function(buffer) {
40-
expect(buffer.stdout).to.contain('<DESCRIBE::>test\n<IT::>test2');
47+
expect(buffer.stdout).to.contain('<DESCRIBE::>test\n\n<IT::>test2');
4148
expect(buffer.stdout).to.contain('<FAILED::>');
4249
expect(buffer.stdout).to.not.contain('<PASSED::>');
4350
done();
4451
});
4552
});
53+
4654
it('should handle errored code', function(done) {
4755
runner.run({
4856
language: 'crystal',
4957
code: 'A = 1',
50-
fixture: 'describe "test" do\n' +
51-
'it("test2") { A.should eq 1 }\n' +
52-
'it("test2") { A.idontexist()}\n' +
53-
'end',
58+
fixture: [
59+
'describe "test" do',
60+
' it("test2") { A.should eq 1 }',
61+
' it("test2") { A.idontexist() }',
62+
'end',
63+
].join('\n'),
5464
testFramework: 'spec'
5565
}, function(buffer) {
5666
expect(buffer.stdout).to.eq('');
5767
expect(buffer.stderr).to.contain('undefined method');
5868
done();
5969
});
6070
});
71+
72+
it('should have output format command on independent line', function(done) {
73+
runner.run({
74+
language: 'crystal',
75+
testFramework: 'spec',
76+
code: '#',
77+
fixture: [
78+
'describe "tests" do',
79+
' it "test case" do',
80+
' print "foo"',
81+
' 1.should eq 2',
82+
' end',
83+
'end',
84+
].join('\n'),
85+
}, function(buffer) {
86+
expect(buffer.stdout).to.contain('\n<FAILED::>');
87+
done();
88+
});
89+
});
6190
});
6291
});
6392
});

0 commit comments

Comments
 (0)