Skip to content

Commit

Permalink
Add better test coverage to body spec
Browse files Browse the repository at this point in the history
  • Loading branch information
zacstewart committed Apr 20, 2014
1 parent d830dae commit cf96807
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion spec/models/body_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@

let(:mars_data) { Fixtures.mars }

let(:parsed_data) { {
revised_on: 'Sep 28, 2012',
name: 'Mars',
id: '499'
} }

let(:parser) { double('Parser', parse: nil) }

describe '#find' do
before do
allow(client).to receive(:cmd).and_return(mars_data)
allow(parser).to receive(:parse).and_return(parsed_data)
end

it 'sends to body id as a telnet command' do
expect(client).to receive(:cmd).
with('String' => '499', 'Match' => /<cr>:\s*$/).
Expand All @@ -17,9 +28,17 @@
end

it 'parses the data received from the client' do
expect(parser).to receive(:parse).with(mars_data)
expect(parser).to receive(:parse).with(mars_data).and_return(parsed_data)
described_class.find(client, 499, parser)
end

it 'creates a new Body using the parsed data' do
body = described_class.find(client, 499, parser)
expect(body).to be_a(Tengai::Body)
expect(body.revised_on).to eq(Date.new(2012, 9, 28))
expect(body.name).to eq('Mars')
expect(body.id).to eq(499)
end
end

describe '#==' do
Expand Down

0 comments on commit cf96807

Please sign in to comment.