Skip to content

Commit f361509

Browse files
committed
done
1 parent 43e735f commit f361509

File tree

6 files changed

+27
-2
lines changed

6 files changed

+27
-2
lines changed

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
--color
22
--require spec_helper
3+
--format documentation

lib/a_broken_program.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
puts "A language's keywords, like 'if' or 'end' (approximately 43)."
1818
puts "Literal pieces of data like this very sentence (or String)."
1919
puts "Finally, barewords, or variables, that are set equal to things."
20-
20+
r
2121
puts "Anything that isn't one of those will cause an error."
2222

2323
see

lib/a_working_program.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
puts "Hello World!"

spec/a_broken_program_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
it 'raises an error when loaded' do
44
expect{
5-
load '../lib/a_broken_program'
5+
load 'lib/a_broken_program.rb'
66
}.to raise_error
77
end
88

spec/a_working_program_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
describe 'A working program' do
2+
3+
it 'not to raise an error when loaded' do
4+
expect{
5+
load 'lib/a_working_program.rb'
6+
}.to_not raise_error
7+
end
8+
9+
end

spec/spec_helper.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,17 @@
8787
Kernel.srand config.seed
8888
=end
8989
end
90+
91+
RSpec.configure do |config|
92+
original_stderr = $stderr
93+
original_stdout = $stdout
94+
config.before(:all) do
95+
# Redirect stderr and stdout
96+
$stderr = File.new(File.join(File.dirname(__FILE__),'../..','null.txt'), 'w')
97+
$stdout = File.new(File.join(File.dirname(__FILE__),'../..','null.txt'), 'w')
98+
end
99+
config.after(:all) do
100+
$stderr = original_stderr
101+
$stdout = original_stdout
102+
end
103+
end

0 commit comments

Comments
 (0)