Skip to content

Commit

Permalink
Merge pull request #387 from unhappychoice/misc/fixTest
Browse files Browse the repository at this point in the history
💚 Fix test
  • Loading branch information
unhappychoice authored Aug 19, 2023
2 parents 112cc15 + 6a218a1 commit ac9ec8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Install libsixel
run: sudo apt-get install libsixel-bin
- name: Install bundler
run: gem install bundler
- name: Install dependencies
Expand Down
18 changes: 9 additions & 9 deletions spec/terminal_image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

context 'with iTerm2' do
let(:expected) { "\e]1337;#{File.read('spec/files/sample_encoded_iterm')}\a\n" }
before { allow(ENV).to receive(:[]) { 'iTerm.app' } }
before { allow(ENV).to receive(:fetch) { 'iTerm.app' } }
it { expect { TerminalImage.show_url('http://example.com/sample.png') }.to output(expected).to_stdout }
end

context 'with sixel' do
let(:expected) { "\eP#{File.read('spec/files/sample_encoded_sixel')}\e\\\n" }
before do
allow(ENV).to receive(:[]) { 'Not a iTerm' }
allow(ENV).to receive(:fetch) { 'Not a iTerm' }
allow(TerminalImage).to receive(:which) { true }
end
it { expect { TerminalImage.show_url('http://example.com/sample.png') }.to output(expected).to_stdout }
Expand All @@ -43,14 +43,14 @@

context 'with iTerm2' do
let(:expected) { "\e]1337;#{File.read('spec/files/sample_encoded_iterm')}\a\n" }
before { allow(ENV).to receive(:[]) { 'iTerm.app' } }
before { allow(ENV).to receive(:fetch) { 'iTerm.app' } }
it { expect { TerminalImage.show(file) }.to output(expected).to_stdout }
end

context 'with sixel' do
let(:expected) { "\eP#{File.read('spec/files/sample_encoded_sixel')}\e\\\n" }
before do
allow(ENV).to receive(:[]) { 'Not a iTerm' }
allow(ENV).to receive(:fetch) { 'Not a iTerm' }
allow(TerminalImage).to receive(:which) { true }
end
it { expect { TerminalImage.show(file) }.to output(expected).to_stdout }
Expand All @@ -62,13 +62,13 @@

context 'with iTerm2' do
let(:expected) { "\e]1337;#{File.read('spec/files/sample_encoded_iterm')}\a" }
before { allow(ENV).to receive(:[]) { 'iTerm.app' } }
before { allow(ENV).to receive(:fetch) { 'iTerm.app' } }
it { expect(TerminalImage.encode_url('http://example.com/sample.png')).to eq(expected) }
end

context 'with sixel' do
let(:expected) { "\eP#{File.read('spec/files/sample_encoded_sixel')}\e\\" }
before { allow(ENV).to receive(:[]) { 'Not a iTerm' } }
before { allow(ENV).to receive(:fetch) { 'Not a iTerm' } }
before { allow(TerminalImage).to receive(:which) { true } }
it { expect(TerminalImage.encode_url('http://example.com/sample.png')).to eq(expected) }
end
Expand All @@ -79,20 +79,20 @@

context 'with iTerm2' do
let(:expected) { "\e]1337;#{File.read('spec/files/sample_encoded_iterm')}\a" }
before { allow(ENV).to receive(:[]) { 'iTerm.app' } }
before { allow(ENV).to receive(:fetch) { 'iTerm.app' } }
it { expect(TerminalImage.encode(file)).to eq(expected) }
end

context 'with sixel' do
let(:expected) { "\eP#{File.read('spec/files/sample_encoded_sixel')}\e\\" }
before { allow(ENV).to receive(:[]) { 'Not a iTerm' } }
before { allow(ENV).to receive(:fetch) { 'Not a iTerm' } }
before { allow(TerminalImage).to receive(:which) { true } }
it { expect(TerminalImage.encode(file)).to eq(expected) }
end

context 'with unsupported terminal' do
let(:expected) { "\eP#{File.read('spec/files/sample_encoded_sixel')}\e\\" }
before { allow(ENV).to receive(:[]) { 'Not a iTerm' } }
before { allow(ENV).to receive(:fetch) { 'Not a iTerm' } }
before { allow(TerminalImage).to receive(:which) { false } }
it { expect { TerminalImage.encode(file) }.to raise_error(TerminalImage::UnsupportedTerminal) }
end
Expand Down

0 comments on commit ac9ec8e

Please sign in to comment.