expectr 0.5.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.7.0
data/expectr.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "expectr"
8
- s.version = "0.5.1"
8
+ s.version = "0.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chris Wuest"]
12
- s.date = "2012-02-23"
12
+ s.date = "2012-03-01"
13
13
  s.description = "Implementation of functionality from NIST Expect in Ruby, with an emphasis on control and extensibility"
14
14
  s.email = "chris@chriswuest.com"
15
15
  s.extra_rdoc_files = [
data/lib/expectr.rb CHANGED
@@ -101,7 +101,7 @@ class Expectr
101
101
  #
102
102
  # === Arguments
103
103
  # +cmd+::
104
- # Command to be executed (String)
104
+ # Command to be executed (String or File)
105
105
  # +args+::
106
106
  # Hash of modifiers for Expectr. Meaningful values are:
107
107
  # * :buffer_size::
@@ -116,13 +116,11 @@ class Expectr
116
116
  # Spawn +cmd+ and attach to STDIN and STDOUT for new process. Fall back
117
117
  # to using Open4 if PTY is not present (this is the case on Windows
118
118
  # implementations of ruby.
119
- #
120
- # === BUGS
121
- #
122
- # * Passing a File object to be executed does not work
123
119
  #
124
120
  def initialize(cmd, args={})
125
- raise ArgumentError, "String Expected" unless cmd.kind_of?(String)
121
+ raise ArgumentError, "String or File expected, was given #{cmd.class}" unless cmd.kind_of? String or cmd.kind_of? File
122
+ cmd = cmd.path if cmd.kind_of? File
123
+
126
124
  args[0] = {} unless args[0]
127
125
  @buffer = String.new
128
126
  @discard = String.new
data/test/test_expectr.rb CHANGED
@@ -58,4 +58,18 @@ class TestExpectr < Test::Unit::TestCase
58
58
  assert_not_nil exp.expect /321/
59
59
  end
60
60
  end
61
+
62
+ def test_create_with_file
63
+ assert_nothing_raised { exp = Expectr.new File.new("/bin/ls"), :flush_buffer => false }
64
+ end
65
+
66
+ def test_executable
67
+ assert_nothing_raised { exp = Expectr.new "/bin/ls", :flush_buffer => false }
68
+
69
+ # Ruby 1.8's PTY allows execution of non-executable/nonexistent files without complaint
70
+ unless RUBY_VERSION =~ /1.8/
71
+ assert_raises(Errno::ENOENT) { exp = Expectr.new "/bin/ThisFileShouldNotExist", :flush_buffer => false }
72
+ assert_raises(Errno::EACCES) { exp = Expectr.new "lib/expectr.rb", :flush_buffer => false }
73
+ end
74
+ end
61
75
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expectr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-23 00:00:00.000000000 Z
12
+ date: 2012-03-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
16
- requirement: &17995220 !ruby/object:Gem::Requirement
16
+ requirement: &10161400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *17995220
24
+ version_requirements: *10161400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &17990180 !ruby/object:Gem::Requirement
27
+ requirement: &10160320 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.12'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *17990180
35
+ version_requirements: *10160320
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &17944880 !ruby/object:Gem::Requirement
38
+ requirement: &10158840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *17944880
46
+ version_requirements: *10158840
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &18334240 !ruby/object:Gem::Requirement
49
+ requirement: &10157640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 1.8.3
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *18334240
57
+ version_requirements: *10157640
58
58
  description: Implementation of functionality from NIST Expect in Ruby, with an emphasis
59
59
  on control and extensibility
60
60
  email: chris@chriswuest.com
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  segments:
91
91
  - 0
92
- hash: 3628151474188738487
92
+ hash: -593338713244342977
93
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements: