-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution_spec.rb
More file actions
41 lines (32 loc) · 1.21 KB
/
solution_spec.rb
File metadata and controls
41 lines (32 loc) · 1.21 KB
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
require 'rspec'
require 'code_breaker'
describe 'Your code' do
[['solution::code']]
VARIABLE = :baggage
ITEMS = ['glasses', 'shirt', 'trousers', 'socks', 'shoes']
it 'defines a variable with name "baggage"' do
expect(local_variables.include?(VARIABLE)).to be true
end
if local_variables.include?(VARIABLE)
before(:all) do
@statements = CodeBreaker.parse( %q{ [['solution::code']] })
end
it 'uses the unshift method to add "glasses"' do
unshift = [{ lvar: VARIABLE }, :unshift, String]
expect(@statements.include?(unshift)).to be true
end
it 'uses the push or << method to add "shoes"' do
push = [{ lvar: VARIABLE }, :push, String]
arrows = [{ lvar: VARIABLE }, :<<, String]
includes_code = @statements.include?(push) || @statements.include?(arrows)
expect(includes_code).to be true
end
it 'uses the insert method to add "trousers" and "socks"' do
insert = [{ lvar: VARIABLE }, :insert, Fixnum, String, String]
expect(@statements.include?(insert)).to be true
end
it 'changes your baggage to contain "glasses", "shirt", "trousers", "socks", & "shoes"' do
expect(eval(VARIABLE.to_s)).to eq ITEMS
end
end
end