bahia 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/README.md +2 -1
- data/lib/bahia.rb +6 -4
- data/spec/bahia_spec.rb +62 -13
- metadata +6 -6
data/CHANGELOG.rdoc
CHANGED
data/README.md
CHANGED
data/lib/bahia.rb
CHANGED
@@ -2,7 +2,7 @@ require 'open3'
|
|
2
2
|
require 'shellwords'
|
3
3
|
|
4
4
|
module Bahia
|
5
|
-
VERSION = '0.
|
5
|
+
VERSION = '0.6.0'
|
6
6
|
|
7
7
|
class DetectionError < StandardError
|
8
8
|
def initialize(name)
|
@@ -14,12 +14,12 @@ module Bahia
|
|
14
14
|
attr_reader :stdout, :stderr, :process
|
15
15
|
|
16
16
|
def self.included(mod)
|
17
|
-
self.project_directory
|
18
|
-
self.command
|
17
|
+
self.project_directory ||= set_project_directory(caller)
|
18
|
+
self.command ||= Dir[self.project_directory + '/bin/*'][0] or
|
19
19
|
raise DetectionError.new(:command)
|
20
20
|
self.command_method ||= File.basename(command)
|
21
21
|
|
22
|
-
# We want only want
|
22
|
+
# We want only want one optional arg, thank 1.8.7 for the splat
|
23
23
|
define_method(command_method) do |*cmd|
|
24
24
|
@stdout, @stderr, @process = Bahia.run_command(cmd.shift || '')
|
25
25
|
end
|
@@ -55,6 +55,8 @@ module Bahia
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def self.set_project_directory(arr)
|
58
|
+
# get rid of rspec backtrace
|
59
|
+
arr = arr.drop_while {|e| e[/rspec/] } if arr[0][/rspec/]
|
58
60
|
arr[0][/^([^:]+):\d+/] or raise DetectionError.new(:project_directory)
|
59
61
|
file = $1
|
60
62
|
raise DetectionError.new(:project_directory) unless File.exists?(file)
|
data/spec/bahia_spec.rb
CHANGED
@@ -8,8 +8,9 @@ describe Bahia do
|
|
8
8
|
Bahia.command = Bahia.project_directory = Bahia.command_method = nil
|
9
9
|
end
|
10
10
|
|
11
|
-
def stub_directory(dir)
|
12
|
-
|
11
|
+
def stub_directory(dir, options = {})
|
12
|
+
stack = options[:stack] || ["#{dir}/helper.rb:5"]
|
13
|
+
Bahia.should_receive(:caller).at_least(1).and_return(stack)
|
13
14
|
File.should_receive(:exists?).at_least(1).and_return(true)
|
14
15
|
end
|
15
16
|
|
@@ -42,29 +43,77 @@ describe Bahia do
|
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
|
-
context "
|
46
|
-
let(:executable) { '/dir/bin/blarg' }
|
47
|
-
|
46
|
+
context "when overriding" do
|
48
47
|
before do
|
49
|
-
|
50
|
-
Dir.stub(:[]).with('/dir/bin/*').and_return([executable])
|
51
|
-
subject
|
48
|
+
Dir.stub(:[]).with('/blah/bin/*').and_return(["/blah/bin/blah"])
|
52
49
|
end
|
53
50
|
|
54
51
|
it "sets project_directory" do
|
55
|
-
Bahia.project_directory
|
52
|
+
Bahia.project_directory = "/blah"
|
53
|
+
|
54
|
+
subject
|
55
|
+
Bahia.project_directory.should == "/blah"
|
56
56
|
end
|
57
57
|
|
58
58
|
it "sets command" do
|
59
|
-
|
59
|
+
stub_directory '/blah/spec'
|
60
|
+
Bahia.command = 'blarg'
|
61
|
+
|
62
|
+
subject
|
63
|
+
Bahia.command.should == "blarg"
|
60
64
|
end
|
61
65
|
|
62
66
|
it "sets command_method" do
|
63
|
-
|
67
|
+
stub_directory '/blah/spec'
|
68
|
+
Bahia.command_method = 'derp'
|
69
|
+
|
70
|
+
subject
|
71
|
+
Bahia.command_method.should == 'derp'
|
64
72
|
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "on successful inclusion" do
|
76
|
+
let(:executable) { '/dir/bin/blarg' }
|
77
|
+
let(:stub_directory_options) { {} }
|
65
78
|
|
66
|
-
|
67
|
-
|
79
|
+
before do
|
80
|
+
stub_directory '/dir/spec', stub_directory_options
|
81
|
+
Dir.stub(:[]).with('/dir/bin/*').and_return([executable])
|
82
|
+
subject
|
83
|
+
end
|
84
|
+
|
85
|
+
context "for normal backtrace" do
|
86
|
+
it "sets project_directory" do
|
87
|
+
Bahia.project_directory.should == '/dir'
|
88
|
+
end
|
89
|
+
|
90
|
+
it "sets command" do
|
91
|
+
Bahia.command.should == executable
|
92
|
+
end
|
93
|
+
|
94
|
+
it "sets command_method" do
|
95
|
+
Bahia.command_method.should == 'blarg'
|
96
|
+
end
|
97
|
+
|
98
|
+
it "defines helper method named blarg" do
|
99
|
+
Bahia.instance_method(:blarg).should_not be_nil
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "for rspec backtrace" do
|
104
|
+
let(:stub_directory_options) {
|
105
|
+
{
|
106
|
+
:stack => [
|
107
|
+
"/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:680: in `include'",
|
108
|
+
"/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:680: in `block in configure_group'",
|
109
|
+
'/dir/spec/helper.rb:5'
|
110
|
+
]
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
it "sets project_directory" do
|
115
|
+
Bahia.project_directory.should == '/dir'
|
116
|
+
end
|
68
117
|
end
|
69
118
|
|
70
119
|
context "helper method blarg correctly executes command" do
|
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
|
+
version: 0.6.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-03-
|
12
|
+
date: 2012-03-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: open4
|
16
|
-
requirement: &
|
16
|
+
requirement: &70110518358440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70110518358440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70110518357520 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 2.8.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70110518357520
|
36
36
|
description: Bahia - where commandline acceptance tests are easy, the people are festive
|
37
37
|
and onde nasceu capoeira. In other words, aruba for any non-cucumber test framework.
|
38
38
|
email: gabriel.horner@gmail.com
|