mplayer.rb 0.0.1 → 0.0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ describe MPlayer do
4
+ before :each do
5
+ @mplayer = MPlayer.new
6
+ end
7
+
8
+ describe "#new" do
9
+ it 'returns a new MPlayer-object' do
10
+ @mplayer.should be_an_instance_of MPlayer
11
+ end
12
+
13
+ it 'creates a file, whichs path is described in the fifo-option' do
14
+ fifo_file= @mplayer.instance_variable_get(:@options)[:fifo]
15
+ File.exists?(fifo_file).should be_true
16
+ end
17
+
18
+ it 'creates a file, whichs path is described in the logfile-option' do
19
+ logfile = @mplayer.instance_variable_get(:@options)[:logfile]
20
+ File.exists?(logfile).should be_true
21
+ end
22
+ end
23
+
24
+ describe "#player_pid" do
25
+ it 'returns a fixnum' do
26
+ @mplayer.player_pid.should be_an_instance_of Fixnum
27
+ end
28
+
29
+ it 'returns a pid of a mplayer-process' do
30
+ `pidof mplayer`.should include @mplayer.player_pid.to_s
31
+ end
32
+ end
33
+
34
+ describe "#run" do
35
+ it 'sends the given command to the fifo' do
36
+ fifo_file = @mplayer.instance_variable_get(:@options)[:fifo]
37
+ cmd = "stop"
38
+ @mplayer.run cmd
39
+ fifo_stream = File.open(fifo_file)
40
+ data = fifo_stream.read_nonblock(6)
41
+ data.should eql cmd+"\n"
42
+ end
43
+ end
44
+
45
+ context "using mplayer-commands as method-calls" do
46
+ it "responds to method-calls which represent a mplayer method" do
47
+ [
48
+ :get_audio_bitrate,
49
+ :get_audio_codec,
50
+ :pause,
51
+ :frame_step,
52
+ :radio_set_channel,
53
+ :seek_chapter,
54
+ :stop
55
+ ].each do |command|
56
+ @mplayer.should respond_to command
57
+ end
58
+ end
59
+
60
+ it "doesnt respond to method-calls which are nonsene" do
61
+ [
62
+ :nonsense,
63
+ :stupid,
64
+ :quirks
65
+ ].each do |nonsense|
66
+ @mplayer.should_not respond_to nonsense.to_sym
67
+ end
68
+ end
69
+
70
+ it "sends the command to the related fifo" do
71
+ fifo_file = @mplayer.instance_variable_get(:@options)[:fifo]
72
+ @mplayer.pause
73
+ fifo_stream = File.open(fifo_file)
74
+ data = fifo_stream.read_nonblock(6)
75
+ data.should eql "pause\n"
76
+ @mplayer.stop
77
+ data = fifo_stream.read_nonblock(5)
78
+ data.should eql "stop\n"
79
+ end
80
+
81
+ it "encapsulates filepathes with quotes" do
82
+ fifo_file = @mplayer.instance_variable_get(:@options)[:fifo]
83
+ @mplayer.loadfile '/path/to/song.mp3'
84
+ fifo_stream = File.open(fifo_file)
85
+ data = fifo_stream.read_nonblock(29)
86
+ data.should eql "loadfile '/path/to/song.mp3'\n"
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,2 @@
1
+ require 'rspec'
2
+ require_relative '../lib/mplayer'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mplayer.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -25,6 +25,8 @@ extra_rdoc_files: []
25
25
  files:
26
26
  - lib/mplayer.rb
27
27
  - lib/mplayer_commands.rb
28
+ - spec/mplayer_spec.rb
29
+ - spec/spec_helper.rb
28
30
  homepage: http://github.com/chaosprinz/mplayer.rb
29
31
  licenses:
30
32
  - MIT