Skip to content

Commit

Permalink
add specs for move()
Browse files Browse the repository at this point in the history
  • Loading branch information
John Ledbetter committed Jul 3, 2014
1 parent a4c0705 commit 5148e02
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions spec/systemd/journal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,39 @@
end
end

describe 'move' do
it 'moves by the specified number of entries' do
j.move(1)
expect(j.read_field(:message)).to eq(journal_json[1]['MESSAGE'])
end

it 'does not move with 0' do
j.move(1)
j.move(0)
expect(j.read_field(:message)).to eq(journal_json[1]['MESSAGE'])
end

it 'moves backwards' do
j.move(3)
j.move(-1)
expect(j.read_field(:message)).to eq(journal_json[2]['MESSAGE'])
end

it 'returns the number of entries moved' do
expect(j.move(3)).to eq(3)
end

it 'returns the number of entries moved even if if less' do
j.move(2)
expect(j.read_field(:message)).to eq(journal_json[2]['MESSAGE'])
expect(j.move(-5)).to eq(2)
end

it 'returns 0 if it did not move' do
expect(j.move(-1)).to eq(0)
end
end

describe 'seek' do
it 'treats a string parameter as the cursor' do
cursor = j.cursor
Expand Down

0 comments on commit 5148e02

Please sign in to comment.