bahia 0.4.0 → 0.5.0

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.
data/.gemspec CHANGED
@@ -11,9 +11,9 @@ Gem::Specification.new do |s|
11
11
  s.summary = "aruba for non-cucumber test frameworks"
12
12
  s.description = "Bahia - where commandline acceptance tests are easy, the people are festive and onde nasceu capoeira. In other words, aruba for any non-cucumber test framework."
13
13
  s.required_rubygems_version = ">= 1.3.6"
14
- s.add_development_dependency 'rspec', '~> 2.7.0'
15
- s.files = Dir.glob(%w[{lib,spec}/**/*.rb bin/* [A-Z]*.{md,txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
16
- s.files += %w{.travis.yml}
14
+ s.add_dependency 'open4', '~> 1.3.0'
15
+ s.add_development_dependency 'rspec', '~> 2.8.0'
16
+ s.files = Dir.glob(%w[{lib,spec}/**/*.rb bin/* [A-Z]*.{md,txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec .travis.yml}
17
17
  s.extra_rdoc_files = ["README.md", "LICENSE.txt"]
18
18
  s.license = 'MIT'
19
19
  end
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.5
2
+ * Add support for other rubies with open4
3
+
1
4
  == 0.4
2
5
  * Add support for 1.8.7
3
6
  * Fix handling of nil and blank $RUBYLIB
data/README.md CHANGED
@@ -3,6 +3,7 @@ Description
3
3
 
4
4
  Bahia - where commandline acceptance tests are easy, the people are festive and
5
5
  onde nasceu capoeira. In other words, aruba for any non-cucumber test framework.
6
+ Works across rubies on 1.8 and 1.9.
6
7
 
7
8
  Usage
8
9
  =====
@@ -63,6 +64,9 @@ About
63
64
  Bahia uses open3 and is dead simple - so simple that you probably should've read
64
65
  the source instead of this readme. Ha!
65
66
 
67
+ Edit: open3 isn't so simple for other rubies so the joke is on me. Rubinius uses
68
+ open4 and jruby doesn't support process.
69
+
66
70
  Contributing
67
71
  ============
68
72
  [See here](http://tagaholic.me/contributing.html)
data/deps.rip ADDED
@@ -0,0 +1 @@
1
+ open4 ~>1.3.0
data/lib/bahia.rb CHANGED
@@ -2,7 +2,7 @@ require 'open3'
2
2
  require 'shellwords'
3
3
 
4
4
  module Bahia
5
- VERSION = '0.4.0'
5
+ VERSION = '0.5.0'
6
6
 
7
7
  class DetectionError < StandardError
8
8
  def initialize(name)
@@ -30,7 +30,28 @@ module Bahia
30
30
  args.unshift Bahia.command
31
31
  args.unshift('RUBYLIB' =>
32
32
  "#{Bahia.project_directory}/lib:#{ENV['RUBYLIB']}".sub(/:\s*$/, ''))
33
- Open3.capture3(*args)
33
+ exec_command *args
34
+ end
35
+
36
+ def self.exec_command(*args)
37
+ unless RUBY_ENGINE[/rbx/] || RUBY_ENGINE[/jruby/]
38
+ return Open3.capture3(*args)
39
+ end
40
+
41
+ args.shift.each {|k,v| ENV[k] = v }
42
+
43
+ if RUBY_ENGINE[/jruby/]
44
+ i, o, e = IO.popen3(*args)
45
+ stdout, stderr = read_and_close(i, o, e)
46
+ # status not supported until Open3 actually works
47
+ [stdout, stderr, nil]
48
+ else
49
+ require 'open4'
50
+ pid, stdin, stdout, stderr = Open4.open4(*args)
51
+ _, status = Process.wait2(pid)
52
+ out, err = read_and_close(stdin, stdout, stderr)
53
+ [out, err, status]
54
+ end
34
55
  end
35
56
 
36
57
  def self.set_project_directory(arr)
@@ -46,4 +67,12 @@ module Bahia
46
67
  end
47
68
  File.dirname dir
48
69
  end
70
+
71
+ private
72
+ def self.read_and_close(stdin, stdout, stderr)
73
+ out_reader = Thread.new { stdout.read }
74
+ err_reader = Thread.new { stderr.read }
75
+ stdin.close
76
+ [out_reader.value, err_reader.value]
77
+ end
49
78
  end
data/spec/bahia_spec.rb CHANGED
@@ -9,8 +9,8 @@ describe Bahia do
9
9
  end
10
10
 
11
11
  def stub_directory(dir)
12
- Bahia.should_receive(:caller).and_return(["#{dir}/helper.rb:5"])
13
- File.should_receive(:exists?).and_return(true)
12
+ Bahia.should_receive(:caller).at_least(1).and_return(["#{dir}/helper.rb:5"])
13
+ File.should_receive(:exists?).at_least(1).and_return(true)
14
14
  end
15
15
 
16
16
  subject { test_class.send :include, Bahia }
@@ -67,35 +67,35 @@ describe Bahia do
67
67
  Bahia.instance_method(:blarg).should_not be_nil
68
68
  end
69
69
 
70
- context "helper method blarg correctly calls Open3.capture" do
71
- def open3_receives(*args)
72
- Open3.should_receive(:capture3).with(
70
+ context "helper method blarg correctly executes command" do
71
+ def command_executes(*args)
72
+ Bahia.should_receive(:exec_command).with(
73
73
  {'RUBYLIB' => "/dir/lib:#{ENV['RUBYLIB']}".sub(/:\s*$/, '')},
74
74
  executable, *args)
75
75
  end
76
76
 
77
77
  it "with no arguments" do
78
- open3_receives
78
+ command_executes
79
79
  test_class.new.blarg
80
80
  end
81
81
 
82
82
  it "with word arguments" do
83
- open3_receives 'is', 'blarg'
83
+ command_executes 'is', 'blarg'
84
84
  test_class.new.blarg('is blarg')
85
85
  end
86
86
 
87
87
  it "with single quoted arguments" do
88
- open3_receives 'this', 'single quoteness'
88
+ command_executes 'this', 'single quoteness'
89
89
  test_class.new.blarg("this 'single quoteness'")
90
90
  end
91
91
 
92
92
  it "with double quoted arguments" do
93
- open3_receives 'this', 'double quoteness'
93
+ command_executes 'this', 'double quoteness'
94
94
  test_class.new.blarg('this "double quoteness"')
95
95
  end
96
96
 
97
97
  it "with escaped quote arguments" do
98
- open3_receives "can't", 'be', 'stopped'
98
+ command_executes "can't", 'be', 'stopped'
99
99
  test_class.new.blarg("can\\'t be stopped")
100
100
  end
101
101
 
@@ -104,13 +104,13 @@ describe Bahia do
104
104
  after { ENV['RUBYLIB'] = @rubylib }
105
105
 
106
106
  it "is nil" do
107
- open3_receives
107
+ command_executes
108
108
  test_class.new.blarg
109
109
  end
110
110
 
111
111
  it "is blank" do
112
112
  ENV['RUBYLIB'] = ''
113
- open3_receives
113
+ command_executes
114
114
  test_class.new.blarg
115
115
  end
116
116
  end
data/spec/deps.rip CHANGED
@@ -1 +1 @@
1
- rspec ~>2.7.0
1
+ rspec ~>2.8.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bahia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,19 +9,30 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-16 00:00:00.000000000 Z
12
+ date: 2012-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: open4
16
+ requirement: &70104834382940 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.3.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70104834382940
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: rspec
16
- requirement: &70169129224660 !ruby/object:Gem::Requirement
27
+ requirement: &70104834382440 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
30
  - - ~>
20
31
  - !ruby/object:Gem::Version
21
- version: 2.7.0
32
+ version: 2.8.0
22
33
  type: :development
23
34
  prerelease: false
24
- version_requirements: *70169129224660
35
+ version_requirements: *70104834382440
25
36
  description: Bahia - where commandline acceptance tests are easy, the people are festive
26
37
  and onde nasceu capoeira. In other words, aruba for any non-cucumber test framework.
27
38
  email: gabriel.horner@gmail.com
@@ -36,6 +47,7 @@ files:
36
47
  - README.md
37
48
  - LICENSE.txt
38
49
  - CHANGELOG.rdoc
50
+ - deps.rip
39
51
  - spec/deps.rip
40
52
  - Rakefile
41
53
  - .gemspec