Skip to content

Commit

Permalink
add for statement test
Browse files Browse the repository at this point in the history
  • Loading branch information
decoch committed Nov 2, 2019
1 parent 512c9f7 commit fc64a9c
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions spec/basic/step02_if_for_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,60 @@
else
sea = 9
end
if land
sea = 10
sea = 10 if land
log(sea) # your answer? =>
end
end

let (:stage_array) { ['broadway', 'dockside', 'hangar', 'magiclamp'] }
context 'for statement' do
# Same as the previous method question. (前のメソッドの質問と同じ)
it 'spec for inti basic' do
sea = nil
for i in (0...stage_array.size)
stage = stage_array[i]
if i == 1
sea = stage
end
end
log(sea) # your answer? =>
end

# Same as the previous method question. (前のメソッドの質問と同じ)
it 'spec for basic' do
sea = nil
for stage in stage_array do
sea = stage
end
log(sea) # your answer? =>
end

# Same as the previous method question. (前のメソッドの質問と同じ)
it 'spec for next break' do
sea = nil
for stage in stage_array do
if stage.start_with?('br')
next
end
sea = stage
break if stage.include?('ga')
end
log(sea) # your answer? =>
end

# Same as the previous method question. (前のメソッドの質問と同じ)
it 'spec each basic' do
str = ''
stage_array.each do |stage|
if str.length > 0
next
end
if stage.include?('i')
str << stage
end
end
log(str) # your answer? =>
end
end
end

0 comments on commit fc64a9c

Please sign in to comment.