ile komut satırı için test çıktısı yapmak istiyorum Komut satırında ruby sayhello.rb
çalıştırmak, sonra Hello from Rspec
almak.RSpec
Bununla o var:
class Hello
def speak
puts 'Hello from RSpec'
end
end
hi = Hello.new #brings my object into existence
hi.speak
Şimdi komut satırı çıktı aslında "RSpec dan Merhaba" ve olmadığını kontrol etmek RSpec bir test yazmak istiyorum "ben Unix gibi "
ÇALIŞMA". Şu anda benim sayhello_spec.rb dosyasında bu var
require_relative 'sayhello.rb' #points to file so I can 'see' it
describe "sayhello.rb" do
it "should say 'Hello from Rspec' when ran" do
STDOUT.should_receive(:puts).with('Hello from RSpec')
end
end
birisi bana doğru yönde lütfen işaret edebilir?
bu üzerine inşa etmek için: def expect_stdout (dize, ve blok); output = capture_stdout (& block); output.should string içerir; end –