Skip to content

Instantly share code, notes, and snippets.

@SophieDeBenedetto
Created July 1, 2015 18:54
Show Gist options
  • Save SophieDeBenedetto/eef14ecf6d5b595d7513 to your computer and use it in GitHub Desktop.
Save SophieDeBenedetto/eef14ecf6d5b595d7513 to your computer and use it in GitHub Desktop.
looping repl
## Using the `loop` method
It's your first year at Hogwarts and you're having a tough time getting the hang of that levitation spell. Fill out the content of the method `looping` puts the
levitation charm "Wingardium Leviosa" 10 times using the `loop` keyword.
```ruby
def looping
#your code here
end
~~~solution
def looping
loop do
puts "Wingardium Leviosa"
puts "Wingardium Leviosa"
puts "Wingardium Leviosa"
puts "Wingardium Leviosa"
puts "Wingardium Leviosa"
puts "Wingardium Leviosa"
puts "Wingardium Leviosa"
end
end
looping
~~~validation
looping_string = "Wingardium Leviosa\nWingardium Leviosa\nWingardium Leviosa\nWingardium Leviosa\nWingardium Leviosa\nWingardium Leviosa\nWingardium Leviosa\n"
expect{ looping }.to output(looping_string).to_stdout
```
%%%
my question: I realize that I can’t use expectation like that but I’m wondering if there is anyway to test “puts”-ing in the repl? what is the `response` that the assertions/expectations are testing? is it the return value of what is executed in the repl that the student’s code?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment