Skip to content

Commit 5f151d3

Browse files
committed
Remove puts from task & improve specs
1 parent 39c56f7 commit 5f151d3

3 files changed

Lines changed: 13 additions & 33 deletions

File tree

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
variable_types = 3
22
language = 'Ruby'
33
learned = true
4-
5-
puts variable_types
6-
puts language
7-
puts learned
Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,23 @@
11
require 'rspec'
22

33
describe 'Your code' do
4+
[['solution::code']]
45

5-
describe do
6-
before do
7-
allow($stdout).to receive(:puts) {''}
8-
allow($stdout).to receive(:p) {''}
9-
allow($stdout).to receive(:print) {''}
6+
{
7+
variable_types: 3,
8+
language: 'Ruby',
9+
learned: true
10+
}.each do |variable, value|
11+
it "defines a variable with name \"#{variable}\"" do
12+
expect(local_variables.include?(variable)).to be true
1013
end
1114

12-
it 'defines a variable "variable_types" with the value 3' do
13-
[['solution::code']]
14-
expect(!!defined?(variable_types)).to be true
15-
expect(variable_types).to eq 3
16-
end
17-
18-
it 'defines a variable "language" with the value \'Ruby\'' do
19-
[['solution::code']]
20-
expect(!!defined?(language)).to be true
21-
expect(language).to eq 'Ruby'
22-
end
15+
if local_variables.include?(variable)
16+
displayed_value = value.is_a?(String) ? "\"#{value}\"" : value
2317

24-
it 'defines a variable "learned" with the value true' do
25-
[['solution::code']]
26-
expect(!!defined?(learned)).to be true
27-
expect(learned).to eq true
18+
it "defines a variable \"#{variable}\" with the value #{displayed_value}" do
19+
expect(eval(variable.to_s)).to eq value
20+
end
2821
end
2922
end
30-
31-
it 'puts the values of all defined variables to the standard output' do
32-
expect($stdout).to receive(:puts).with(3)
33-
expect($stdout).to receive(:puts).with('Ruby')
34-
expect($stdout).to receive(:puts).with(true)
35-
[['solution::code']]
36-
end
3723
end

1_Introduction/3_Assigning_data/task.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,4 @@ Set the following variables:
6969
` language` to the string *'Ruby'* and
7070
` learned` to the boolean *true*
7171

72-
and print out each variable's value by using the *puts* method!
73-
7472
---

0 commit comments

Comments
 (0)