bahia 0.1.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 +17 -0
- data/CHANGELOG.rdoc +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +35 -0
- data/lib/bahia.rb +37 -0
- metadata +54 -0
data/.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'rubygems' unless Object.const_defined?(:Gem)
|
3
|
+
require File.dirname(__FILE__) + "/lib/bahia"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "bahia"
|
7
|
+
s.version = Bahia::VERSION
|
8
|
+
s.authors = ["Gabriel Horner"]
|
9
|
+
s.email = "gabriel.horner@gmail.com"
|
10
|
+
s.homepage = "http://github.com/cldwalker/bahia"
|
11
|
+
s.summary = "aruba for non-cucumber test frameworks"
|
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
|
+
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}
|
15
|
+
s.extra_rdoc_files = ["README.md", "LICENSE.txt"]
|
16
|
+
s.license = 'MIT'
|
17
|
+
end
|
data/CHANGELOG.rdoc
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2011 Gabriel Horner
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
Description
|
2
|
+
===========
|
3
|
+
|
4
|
+
Bahia - where commandline acceptance tests are easy, the people are festive and
|
5
|
+
onde nasceu capoeira. In other words, aruba for any non-cucumber test framework.
|
6
|
+
|
7
|
+
Usage
|
8
|
+
=====
|
9
|
+
|
10
|
+
Say you want to test your gem's executable, blarg. So in your
|
11
|
+
{test,spec}/helper.rb, you:
|
12
|
+
|
13
|
+
require 'bahia'
|
14
|
+
|
15
|
+
# for rspec
|
16
|
+
Rspec.configure {|c| c.include Bahia }
|
17
|
+
|
18
|
+
# for minitest
|
19
|
+
class MiniTest::Unit::TestCase
|
20
|
+
include Bahia
|
21
|
+
end
|
22
|
+
|
23
|
+
# for bacon
|
24
|
+
class Bacon::Context
|
25
|
+
include Bahia
|
26
|
+
end
|
27
|
+
|
28
|
+
# for your preferred framework
|
29
|
+
include some shit ...
|
30
|
+
|
31
|
+
Now acceptance test away your executable:
|
32
|
+
|
33
|
+
describe "blarg" do
|
34
|
+
it "prints usage without args" do
|
35
|
+
blarg ""
|
36
|
+
stdout.should == 'Usage: blarg COMMAND'
|
37
|
+
process.success?.should == true
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'prints error for double blarging' do
|
41
|
+
blarg "blarg"
|
42
|
+
stderr.should == "Bad human! No double blarging allowed"
|
43
|
+
process.success?.should == false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
As you can see, bahia provided helpers stdout, stderr and process as well as
|
48
|
+
automatically creates a blarg method.
|
49
|
+
|
50
|
+
If the above doesn't automagically work for you, configure Bahia before
|
51
|
+
including it:
|
52
|
+
|
53
|
+
Bahia.command = 'blarg 3.0'
|
54
|
+
Bahia.command_method = 'not blarg'
|
55
|
+
Bahia.project_directory = '/path/to/gem/root/dir'
|
56
|
+
|
57
|
+
About
|
58
|
+
=====
|
59
|
+
|
60
|
+
Bahia uses open3 and is dead simple - so simple that you probably should've read
|
61
|
+
the source instead of this readme. Ha!
|
62
|
+
|
63
|
+
Todo
|
64
|
+
====
|
65
|
+
|
66
|
+
* Tests!
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
def gemspec
|
5
|
+
@gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Build the gem"
|
9
|
+
task :gem=>:gemspec do
|
10
|
+
sh "gem build .gemspec"
|
11
|
+
FileUtils.mkdir_p 'pkg'
|
12
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Install the gem locally"
|
16
|
+
task :install => :gem do
|
17
|
+
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Generate the gemspec"
|
21
|
+
task :generate do
|
22
|
+
puts gemspec.to_ruby
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Validate the gemspec"
|
26
|
+
task :gemspec do
|
27
|
+
gemspec.validate
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Run tests'
|
31
|
+
task :test do |t|
|
32
|
+
sh 'bacon -q -Ilib -I. test/*_test.rb'
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
data/lib/bahia.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Bahia
|
4
|
+
VERSION = '0.1.0'
|
5
|
+
|
6
|
+
class DetectionError < StandardError
|
7
|
+
def initialize(name)
|
8
|
+
super "Unable to detect #{name}. Set it with Bahia.#{name}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self; attr_accessor :command, :project_directory, :command_method; end
|
13
|
+
attr_reader :stdout, :stderr, :process
|
14
|
+
|
15
|
+
def self.included(mod)
|
16
|
+
self.project_directory = set_project_directory(caller)
|
17
|
+
self.command = Dir[self.project_directory + '/bin/*'][0] or
|
18
|
+
raise DetectionError.new(:command)
|
19
|
+
self.command_method ||= File.basename(command)
|
20
|
+
|
21
|
+
define_method(command_method) do |cmd|
|
22
|
+
args = cmd.split(/\s+/)
|
23
|
+
args.unshift Bahia.command
|
24
|
+
args.unshift({'RUBYLIB' => "#{Bahia.project_directory}/lib:" +
|
25
|
+
ENV['RUBYLIB']})
|
26
|
+
@stdout, @stderr, @process = Open3.capture3(*args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.set_project_directory(arr)
|
31
|
+
arr[0][/^([^:]+):\d+/] or raise DetectionError.new(:project_directory)
|
32
|
+
file = $1
|
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)
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bahia
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gabriel Horner
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
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.
|
16
|
+
email: gabriel.horner@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files:
|
20
|
+
- README.md
|
21
|
+
- LICENSE.txt
|
22
|
+
files:
|
23
|
+
- lib/bahia.rb
|
24
|
+
- README.md
|
25
|
+
- LICENSE.txt
|
26
|
+
- CHANGELOG.rdoc
|
27
|
+
- Rakefile
|
28
|
+
- .gemspec
|
29
|
+
homepage: http://github.com/cldwalker/bahia
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.6
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.8.10
|
51
|
+
signing_key:
|
52
|
+
specification_version: 3
|
53
|
+
summary: aruba for non-cucumber test frameworks
|
54
|
+
test_files: []
|