bahia 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gemspec CHANGED
@@ -11,7 +11,8 @@ 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.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{md,txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
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}
15
16
  s.extra_rdoc_files = ["README.md", "LICENSE.txt"]
16
17
  s.license = 'MIT'
17
18
  end
data/CHANGELOG.rdoc CHANGED
@@ -1,2 +1,6 @@
1
+ == 0.2
2
+ * Tests!
3
+ * Improve finding project directory
4
+
1
5
  == 0.1
2
6
  * Bahia viva!
data/README.md CHANGED
@@ -60,7 +60,11 @@ About
60
60
  Bahia uses open3 and is dead simple - so simple that you probably should've read
61
61
  the source instead of this readme. Ha!
62
62
 
63
- Todo
64
- ====
63
+ Contributing
64
+ ============
65
+ [See here](http://tagaholic.me/contributing.html)
65
66
 
66
- * Tests!
67
+ Credits
68
+ =======
69
+
70
+ * @spicycode
data/Rakefile CHANGED
@@ -29,7 +29,7 @@ end
29
29
 
30
30
  desc 'Run tests'
31
31
  task :test do |t|
32
- sh 'bacon -q -Ilib -I. test/*_test.rb'
32
+ sh 'rspec spec'
33
33
  end
34
34
 
35
35
  task :default => :test
data/lib/bahia.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'open3'
2
2
 
3
3
  module Bahia
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
 
6
6
  class DetectionError < StandardError
7
7
  def initialize(name)
@@ -31,7 +31,13 @@ module Bahia
31
31
  arr[0][/^([^:]+):\d+/] or raise DetectionError.new(:project_directory)
32
32
  file = $1
33
33
  raise DetectionError.new(:project_directory) unless File.exists?(file)
34
- # Assume include happens in {spec,test}/helper.rb
35
- File.dirname File.dirname(file)
34
+
35
+ dir = File.dirname(file)
36
+ # Assume test directory called spec or test
37
+ until dir[%r{/(spec|test)$}]
38
+ raise DetectionError.new(:project_directory) if dir == '/'
39
+ dir = File.dirname(dir)
40
+ end
41
+ File.dirname dir
36
42
  end
37
43
  end
@@ -0,0 +1,76 @@
1
+ require 'bahia'
2
+ require 'rspec'
3
+
4
+ describe Bahia do
5
+ let(:test_class) { Class.new }
6
+
7
+ before do
8
+ Bahia.command = Bahia.project_directory = Bahia.command_method = nil
9
+ end
10
+
11
+ def stub_directory(dir)
12
+ Bahia.should_receive(:caller).and_return(["#{dir}/helper.rb:5"])
13
+ File.should_receive(:exists?).and_return(true)
14
+ end
15
+
16
+ subject { test_class.send :include, Bahia }
17
+
18
+ context "fails to include and raises DetectionError" do
19
+ it "if directory not detected" do
20
+ Bahia.should_receive(:caller).and_return(["(eval)"])
21
+ msg = Bahia::DetectionError.new(:project_directory).message
22
+ expect { subject }.to raise_error(msg)
23
+ end
24
+
25
+ it "if directory does not exist" do
26
+ Bahia.should_receive(:caller).and_return(["(irb):5"])
27
+ msg = Bahia::DetectionError.new(:project_directory).message
28
+ expect { subject }.to raise_error(msg)
29
+ end
30
+
31
+ it "if test directory is not test or spec" do
32
+ stub_directory '/dir/my_test'
33
+ msg = Bahia::DetectionError.new(:project_directory).message
34
+ expect { subject }.to raise_error(msg)
35
+ end
36
+
37
+ it "if command isn't detected" do
38
+ stub_directory '/dir/spec'
39
+ Dir.should_receive(:[]).with('/dir/bin/*').and_return([])
40
+ msg = Bahia::DetectionError.new(:command).message
41
+ expect { subject }.to raise_error(msg)
42
+ end
43
+ end
44
+
45
+ context "on successful inclusion" do
46
+ let(:executable) { '/dir/bin/blarg' }
47
+
48
+ before do
49
+ stub_directory '/dir/spec'
50
+ Dir.stub(:[]).with('/dir/bin/*').and_return([executable])
51
+ subject
52
+ end
53
+
54
+ it "sets project_directory" do
55
+ Bahia.project_directory.should == '/dir'
56
+ end
57
+
58
+ it "sets command" do
59
+ Bahia.command.should == executable
60
+ end
61
+
62
+ it "sets command_method" do
63
+ Bahia.command_method.should == 'blarg'
64
+ end
65
+
66
+ it "defines helper method named blarg" do
67
+ Bahia.instance_method(:blarg).should_not be_nil
68
+ end
69
+
70
+ it "helper method blarg calls Open3.capture with correct args" do
71
+ Open3.should_receive(:capture3).with(
72
+ {'RUBYLIB' => "/dir/lib:#{ENV['RUBYLIB']}"}, executable, 'arg1', 'arg2')
73
+ test_class.new.blarg('arg1 arg2')
74
+ end
75
+ end
76
+ end
data/spec/deps.rip ADDED
@@ -0,0 +1 @@
1
+ rspec ~>2.7.0
metadata CHANGED
@@ -1,54 +1,74 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bahia
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.2.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Gabriel Horner
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-12 00:00:00.000000000 Z
13
- dependencies: []
14
- description: Bahia - where commandline acceptance tests are easy, the people are festive
15
- and onde nasceu capoeira. In other words, aruba for any non-cucumber test framework.
12
+
13
+ date: 2011-12-16 00:00:00 -05:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rspec
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 2.7.0
25
+ type: :development
26
+ version_requirements: *id001
27
+ 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.
16
28
  email: gabriel.horner@gmail.com
17
29
  executables: []
30
+
18
31
  extensions: []
19
- extra_rdoc_files:
32
+
33
+ extra_rdoc_files:
20
34
  - README.md
21
35
  - LICENSE.txt
22
- files:
36
+ files:
23
37
  - lib/bahia.rb
38
+ - spec/bahia_spec.rb
24
39
  - README.md
25
40
  - LICENSE.txt
26
41
  - CHANGELOG.rdoc
42
+ - spec/deps.rip
27
43
  - Rakefile
28
44
  - .gemspec
45
+ has_rdoc: true
29
46
  homepage: http://github.com/cldwalker/bahia
30
- licenses:
47
+ licenses:
31
48
  - MIT
32
49
  post_install_message:
33
50
  rdoc_options: []
34
- require_paths:
51
+
52
+ require_paths:
35
53
  - lib
36
- required_ruby_version: !ruby/object:Gem::Requirement
54
+ required_ruby_version: !ruby/object:Gem::Requirement
37
55
  none: false
38
- requirements:
39
- - - ! '>='
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
- required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
61
  none: false
44
- requirements:
45
- - - ! '>='
46
- - !ruby/object:Gem::Version
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
47
65
  version: 1.3.6
48
66
  requirements: []
67
+
49
68
  rubyforge_project:
50
- rubygems_version: 1.8.10
69
+ rubygems_version: 1.6.2
51
70
  signing_key:
52
71
  specification_version: 3
53
72
  summary: aruba for non-cucumber test frameworks
54
73
  test_files: []
74
+