screenomat/spec/lib/screenie/dsl/session_spec.rb

67 lines
1.5 KiB
Ruby
Raw Normal View History

2010-12-09 21:20:21 +00:00
require 'spec_helper'
require 'screenie/dsl/session'
describe Screenie::DSL::Session do
describe '#to_cmd' do
context 'one screen' do
subject {
Screenie::DSL::Session.new("my-session") { screen "test" }.to_cmd
}
it { should == [
%{screen -dmS "my-session"},
%{screen -X -S "my-session" -p 0 stuff "test
"},
%{screen -x "my-session" -p 0}
] }
end
context 'two screens' do
subject {
Screenie::DSL::Session.new("my-session") { screen "test"; screen "test2" }.to_cmd
}
it { should == [
%{screen -dmS "my-session"},
%{screen -X -S "my-session" -p 0 stuff "test
"},
%{screen -X -S "my-session" screen 1},
%{screen -X -S "my-session" -p 1 stuff "test2
"},
%{screen -x "my-session" -p 0}
] }
end
end
describe 'from string' do
subject {
Screenie::DSL::Session.new("my-session", <<-EOR).to_cmd
screen "test"
EOR
}
it { should == [
%{screen -dmS "my-session"},
%{screen -X -S "my-session" -p 0 stuff "test
"},
%{screen -x "my-session" -p 0}
] }
end
describe 'screen!' do
subject {
Screenie::DSL::Session.new("my-session") { screen "test"; screen! "test2" }.to_cmd
}
it { should == [
%{screen -dmS "my-session"},
%{screen -X -S "my-session" -p 0 stuff "test
"},
%{screen -X -S "my-session" screen 1},
%{screen -X -S "my-session" -p 1 stuff "test2
"},
%{screen -x "my-session" -p 1}
] }
end
end