bahia 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ == 0.6.0
2
+ * Fix overriding project_directory and command
3
+ * Actually auto detect project_directory for rspec
4
+
1
5
  == 0.5.1
2
6
  * Support unusually named test directories
3
7
 
data/README.md CHANGED
@@ -77,4 +77,5 @@ Contributing
77
77
  Credits
78
78
  =======
79
79
 
80
- * @spicycode
80
+ * @spicycode - initial testing
81
+ * @rsanheim - allow project\_directory override
@@ -2,7 +2,7 @@ require 'open3'
2
2
  require 'shellwords'
3
3
 
4
4
  module Bahia
5
- VERSION = '0.5.1'
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 = set_project_directory(caller)
18
- self.command = Dir[self.project_directory + '/bin/*'][0] or
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 ane optional arg, thank 1.8.7 for the splat
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)
@@ -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
- Bahia.should_receive(:caller).at_least(1).and_return(["#{dir}/helper.rb:5"])
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 "on successful inclusion" do
46
- let(:executable) { '/dir/bin/blarg' }
47
-
46
+ context "when overriding" do
48
47
  before do
49
- stub_directory '/dir/spec'
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.should == '/dir'
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
- Bahia.command.should == executable
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
- Bahia.command_method.should == 'blarg'
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
- it "defines helper method named blarg" do
67
- Bahia.instance_method(:blarg).should_not be_nil
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.5.1
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-13 00:00:00.000000000 Z
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: &70096433531440 !ruby/object:Gem::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: *70096433531440
24
+ version_requirements: *70110518358440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70096433530940 !ruby/object:Gem::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: *70096433530940
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