Use
STDIN.gets.chomp
See this answer.
The best way to test this is to mock IO#gets
with an object and method that returns a canned response. An RSpec mock would look something like:
STDIN.should_receive(:gets).and_return("A Book Title")
See this answer for a couple more examples. Set these up in the appropriate before :each
blocks and they will intercept the call to gets
in your test.