Skip to content

Commit

Permalink
refactored spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
takaokouji committed Jul 28, 2015
1 parent 0b0e186 commit 19e26b5
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions spec/lib/dxruby_sdl/sound_spec.rb
Expand Up @@ -2,6 +2,16 @@
require 'spec_helper'

describe DXRubySDL::Sound, '音を表すクラス' do
shared_context 'WAVE file', wave: true do
let(:path) { fixture_path('sound.wav') }
let(:sound) { DXRubySDL::Sound.new(path) }
end

shared_context 'MIDI file', midi: true do
let(:path) { fixture_path('bgm.mid') }
let(:sound) { DXRubySDL::Sound.new(path) }
end

describe '.new' do
shared_context '.new' do
subject { DXRubySDL::Sound.new(fixture_path(filename)) }
Expand All @@ -25,10 +35,7 @@
end

describe '#play' do
context 'WAVE形式のファイルの場合' do
let(:path) { fixture_path('sound.wav') }
let(:sound) { DXRubySDL::Sound.new(path) }

context 'WAVE file', wave: true do
subject { sound.play }

it 'SDL::Mixer.play_channelを呼び出す' do
Expand Down Expand Up @@ -62,10 +69,7 @@
end
end

context 'MIDI形式のファイルの場合' do
let(:path) { fixture_path('bgm.mid') }
let(:sound) { DXRubySDL::Sound.new(path) }

context 'MIDI file', midi: true do
subject { sound.play }

it 'SDL::Mixer.play_musicを呼び出す' do
Expand All @@ -78,7 +82,7 @@
end

describe '#stop' do
context 'WAVE file' do
context 'WAVE file', wave: true do
let(:path) { fixture_path('sound.wav') }
let(:sound) { DXRubySDL::Sound.new(path) }

Expand All @@ -95,7 +99,7 @@
end
end

context 'MIDI file' do
context 'MIDI file', midi: true do
let(:path) { fixture_path('bgm.mid') }
let(:sound) { DXRubySDL::Sound.new(path) }

Expand Down

0 comments on commit 19e26b5

Please sign in to comment.