forked from grosser/rspec-instafail
/
instafail_spec.rb
77 lines (61 loc) · 1.83 KB
/
instafail_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
describe 'RSpec::Instafail' do
it "works correctly with RSpec 1.x" do
output = `cd spec/rspec_1 && bundle exec spec a_test.rb --format RSpec::Instafail`
expected_output = <<EXP
1\\) x a
expected: 2,
got: 1 \\(using ==\\)
# (\\.\\/)?a_test\\.rb:5:(in `block \\(2 levels\\) in <top \\(required\\)>')?
\\.\\.\\*\\.
Pending:
x d \\(TODO\\)
(\\.\\/)?a_test\\.rb:14(\:in `block in <top \\(required\\)>')?
1\\)
'x a' FAILED
expected: 2,
got: 1 \\(using ==\\)
(\\./)?a_test\\.rb:5:(in `block \\(2 levels\\) in <top \\(required\\)>')?
EXP
output.should =~ Regexp.new(expected_output, 'x')
end
it "works correctly with RSpec 2.x (but backtrace might be broken)" do
output = `cd spec/rspec_2 && bundle exec rspec a_test.rb --require ../../lib/rspec/instafail --format RSpec::Instafail --no-color`
expected = <<EXP
1\\) x a
Failure\\/Error: 1\\.should == 2
expected: 2,
got: 1 \\(using ==\\)
EXP
output.should =~ Regexp.new(expected, 'x')
output.should include('/a_test.rb:5')
expected = <<EXP
\\.\\.\\*\\.
Pending:
x d
# No reason given
# \\./a_test\\.rb:14
Finished in \\d\\.\\d+ seconds
5 examples, 1 failure, 1 pending
EXP
output.should =~ Regexp.new(expected, 'x')
end
it "works correctly with RSpec 2.x" do
pending 'the backtrace for the error is always absolute on my machine'
output = `cd spec/rspec_2 && bundle exec rspec a_test.rb --require ../../lib/rspec/instafail --format RSpec::Instafail --no-color`
expected_output = <<EXP
1\\) x a
Failure\\/Error: 1\\.should == 2
expected: 2,
got: 1 \\(using ==\\)
# \\./a_test\\.rb:5
\\.\\.\\*\\.
Pending:
x d
# No reason given
# \\./a_test\\.rb:14
Finished in \\d\\.\\d+ seconds
5 examples, 1 failure, 1 pending
EXP
output.should =~ Regexp.new(expected_output, 'x')
end
end