aruba 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +28 -0
- data/Rakefile +45 -0
- data/aruba.gemspec +55 -0
- data/features/exit_statuses.feature +13 -0
- data/features/file_system_commands.feature +24 -0
- data/features/output.feature +53 -0
- data/features/step_definitions/aruba_steps.rb +0 -0
- data/features/support/env.rb +4 -0
- data/lib/aruba.rb +114 -0
- metadata +87 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Aslak Hellesøy, David Chelimsky
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
= aruba
|
2
|
+
|
3
|
+
Cucumber steps for driving out command line applications.
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
gem install aruba
|
8
|
+
|
9
|
+
Then, just require the library in one of your ruby files under <tt>features/support</tt>
|
10
|
+
|
11
|
+
require 'aruba'
|
12
|
+
|
13
|
+
You now have a bunch of step definitions that you can use in your features. See aruba.rb
|
14
|
+
for details.
|
15
|
+
|
16
|
+
== Note on Patches/Pull Requests
|
17
|
+
|
18
|
+
* Fork the project.
|
19
|
+
* Make your feature addition or bug fix.
|
20
|
+
* Add tests for it. This is important so I don't break it in a
|
21
|
+
future version unintentionally.
|
22
|
+
* Commit, do not mess with rakefile, version, or history.
|
23
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
24
|
+
* Send me a pull request. Bonus points for topic branches.
|
25
|
+
|
26
|
+
== Copyright
|
27
|
+
|
28
|
+
Copyright (c) 2010 Aslak Hellesøy and David Chelimsky. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.version = "0.1.0"
|
8
|
+
gem.name = "aruba"
|
9
|
+
gem.summary = %Q{CLI Steps for Cucumber}
|
10
|
+
gem.description = %Q{CLI Steps for Cucumber, hand-crafted for you in Aruba}
|
11
|
+
gem.email = "cukes@groups.google.com"
|
12
|
+
gem.homepage = "http://github.com/aslakhellesoy/aruba"
|
13
|
+
gem.authors = ["Aslak Hellesøy", "David Chelimsky"]
|
14
|
+
gem.add_development_dependency "rspec", ">= 1.3.0"
|
15
|
+
gem.add_development_dependency "cucumber", ">= 0.6.2"
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
begin
|
23
|
+
require 'cucumber/rake/task'
|
24
|
+
Cucumber::Rake::Task.new do |t|
|
25
|
+
t.rcov = true
|
26
|
+
end
|
27
|
+
|
28
|
+
task :features => :check_dependencies
|
29
|
+
rescue LoadError
|
30
|
+
task :features do
|
31
|
+
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :cucumber
|
36
|
+
|
37
|
+
require 'rake/rdoctask'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "aruba #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/aruba.gemspec
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{aruba}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Aslak Helles\303\270y", "David Chelimsky"]
|
12
|
+
s.date = %q{2010-02-13}
|
13
|
+
s.description = %q{CLI Steps for Cucumber, hand-crafted for you in Aruba}
|
14
|
+
s.email = %q{cukes@groups.google.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"aruba.gemspec",
|
26
|
+
"features/exit_statuses.feature",
|
27
|
+
"features/file_system_commands.feature",
|
28
|
+
"features/output.feature",
|
29
|
+
"features/step_definitions/aruba_steps.rb",
|
30
|
+
"features/support/env.rb",
|
31
|
+
"lib/aruba.rb"
|
32
|
+
]
|
33
|
+
s.homepage = %q{http://github.com/aslakhellesoy/aruba}
|
34
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.5}
|
37
|
+
s.summary = %q{CLI Steps for Cucumber}
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
41
|
+
s.specification_version = 3
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
|
45
|
+
s.add_development_dependency(%q<cucumber>, [">= 0.6.2"])
|
46
|
+
else
|
47
|
+
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
48
|
+
s.add_dependency(%q<cucumber>, [">= 0.6.2"])
|
49
|
+
end
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
52
|
+
s.add_dependency(%q<cucumber>, [">= 0.6.2"])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: exit statuses
|
2
|
+
|
3
|
+
In order to specify expected exit statuses
|
4
|
+
As a developer using Cucumber
|
5
|
+
I want to use the "the exit status should be" step
|
6
|
+
|
7
|
+
Scenario: exit status of 0
|
8
|
+
When I run "ruby -h"
|
9
|
+
Then the exit status should be 0
|
10
|
+
|
11
|
+
Scenario: non-zero exit status
|
12
|
+
When I run "ruby -e 'exit 56'"
|
13
|
+
Then the exit status should be 56
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Feature: file system commands
|
2
|
+
|
3
|
+
In order to specify commands that load files
|
4
|
+
As a developer using Cucumber
|
5
|
+
I want to create temporary files
|
6
|
+
|
7
|
+
Scenario: create a dir
|
8
|
+
Given a directory named "foo/bar"
|
9
|
+
When I run "ruby -e \"puts test ?d, 'foo'\""
|
10
|
+
Then the stdout should contain "true"
|
11
|
+
|
12
|
+
Scenario: cat a file
|
13
|
+
Given a file named "foo/bar/example.rb" with:
|
14
|
+
"""
|
15
|
+
puts "hello world"
|
16
|
+
"""
|
17
|
+
When I run "ruby foo/bar/example.rb"
|
18
|
+
Then I should see "hello world"
|
19
|
+
|
20
|
+
Scenario: clean up files generated in previous scenarios
|
21
|
+
When I run "ruby foo/bar/example.rb"
|
22
|
+
Then the exit status should be 1
|
23
|
+
And I should see "No such file or directory -- foo/bar/example.rb"
|
24
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Feature: Output
|
2
|
+
|
3
|
+
In order to specify expected output
|
4
|
+
As a developer using Cucumber
|
5
|
+
I want to use the "I should see" step
|
6
|
+
|
7
|
+
Scenario: Detect subset of one-line output
|
8
|
+
When I run "ruby -e 'puts \"hello world\"'"
|
9
|
+
Then I should see "hello world"
|
10
|
+
|
11
|
+
Scenario: Detect subset of multiline output
|
12
|
+
When I run "ruby -e 'puts \"hello\nworld\"'"
|
13
|
+
Then I should see:
|
14
|
+
"""
|
15
|
+
hello
|
16
|
+
"""
|
17
|
+
|
18
|
+
Scenario: Detect exact one-line output
|
19
|
+
When I run "ruby -e 'puts \"hello world\"'"
|
20
|
+
Then I should see exactly "hello world\n"
|
21
|
+
|
22
|
+
Scenario: Detect exact multiline output
|
23
|
+
When I run "ruby -e 'puts \"hello\nworld\"'"
|
24
|
+
Then I should see exactly:
|
25
|
+
"""
|
26
|
+
hello
|
27
|
+
world
|
28
|
+
|
29
|
+
"""
|
30
|
+
|
31
|
+
Scenario: Match passing exit status and partial output
|
32
|
+
When I run "ruby -e 'puts \"hello\nworld\"'"
|
33
|
+
Then it should pass with:
|
34
|
+
"""
|
35
|
+
hello
|
36
|
+
"""
|
37
|
+
|
38
|
+
Scenario: Match failing exit status and partial output
|
39
|
+
When I run "ruby -e 'puts \"hello\nworld\";exit 99'"
|
40
|
+
Then it should fail with:
|
41
|
+
"""
|
42
|
+
hello
|
43
|
+
"""
|
44
|
+
|
45
|
+
Scenario: Match output in stdout
|
46
|
+
When I run "ruby -e 'puts \"hello\nworld\"'"
|
47
|
+
Then the stdout should contain "hello"
|
48
|
+
Then the stderr should not contain "hello"
|
49
|
+
|
50
|
+
Scenario: Match output in stderr
|
51
|
+
When I run "ruby -e 'STDERR.puts \"hello\nworld\";exit 99'"
|
52
|
+
Then the stderr should contain "hello"
|
53
|
+
Then the stdout should not contain "hello"
|
File without changes
|
data/lib/aruba.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
module ArubaWorld
|
4
|
+
def in_current_dir(&block)
|
5
|
+
_mkdir(current_dir)
|
6
|
+
Dir.chdir(current_dir, &block)
|
7
|
+
end
|
8
|
+
|
9
|
+
def current_dir
|
10
|
+
'tmp/aruba'
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_file(file_name, file_content)
|
14
|
+
in_current_dir do
|
15
|
+
_mkdir(File.dirname(file_name))
|
16
|
+
File.open(file_name, 'w') { |f| f << file_content }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_dir(dir_name)
|
21
|
+
in_current_dir do
|
22
|
+
_mkdir(dir_name)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def _mkdir(dir_name)
|
27
|
+
FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
|
28
|
+
end
|
29
|
+
|
30
|
+
def unescape(string)
|
31
|
+
eval(%{"#{string}"})
|
32
|
+
end
|
33
|
+
|
34
|
+
def combined_output
|
35
|
+
@last_stdout + (@last_stderr == '' ? '' : "\n#{'-'*70}\n#{@last_stderr}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def run(command)
|
39
|
+
stderr_file = Tempfile.new('cucumber')
|
40
|
+
stderr_file.close
|
41
|
+
in_current_dir do
|
42
|
+
mode = Cucumber::RUBY_1_9 ? {:external_encoding=>"UTF-8"} : 'r'
|
43
|
+
IO.popen("#{command} 2> #{stderr_file.path}", mode) do |io|
|
44
|
+
@last_stdout = io.read
|
45
|
+
end
|
46
|
+
|
47
|
+
@last_exit_status = $?.exitstatus
|
48
|
+
end
|
49
|
+
@last_stderr = IO.read(stderr_file.path)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
World(ArubaWorld)
|
54
|
+
|
55
|
+
Before do
|
56
|
+
FileUtils.rm_rf(current_dir)
|
57
|
+
end
|
58
|
+
|
59
|
+
Given /^a directory named "([^\"]*)"$/ do |dir_name|
|
60
|
+
create_dir(dir_name)
|
61
|
+
end
|
62
|
+
|
63
|
+
Given /^a file named "([^\"]*)" with:$/ do |file_name, file_content|
|
64
|
+
create_file(file_name, file_content)
|
65
|
+
end
|
66
|
+
|
67
|
+
When /^I run "(.*)"$/ do |cmd|
|
68
|
+
run(unescape(cmd))
|
69
|
+
end
|
70
|
+
|
71
|
+
Then /^I should see "([^\"]*)"$/ do |partial_output|
|
72
|
+
combined_output.should =~ /#{partial_output}/
|
73
|
+
end
|
74
|
+
|
75
|
+
Then /^I should see:$/ do |partial_output|
|
76
|
+
combined_output.should =~ /#{partial_output}/
|
77
|
+
end
|
78
|
+
|
79
|
+
Then /^I should see exactly "([^\"]*)"$/ do |exact_output|
|
80
|
+
combined_output.should == unescape(exact_output)
|
81
|
+
end
|
82
|
+
|
83
|
+
Then /^I should see exactly:$/ do |exact_output|
|
84
|
+
combined_output.should == exact_output
|
85
|
+
end
|
86
|
+
|
87
|
+
Then /^the exit status should be (\d+)$/ do |exit_status|
|
88
|
+
@last_exit_status.should == exit_status.to_i
|
89
|
+
end
|
90
|
+
|
91
|
+
Then /^it should (pass|fail) with:$/ do |pass_fail, partial_output|
|
92
|
+
if pass_fail == 'pass'
|
93
|
+
@last_exit_status.should == 0
|
94
|
+
else
|
95
|
+
@last_exit_status.should_not == 0
|
96
|
+
end
|
97
|
+
Then "I should see:", partial_output
|
98
|
+
end
|
99
|
+
|
100
|
+
Then /^the stderr should contain "([^\"]*)"$/ do |partial_output|
|
101
|
+
@last_stderr.should =~ /#{partial_output}/
|
102
|
+
end
|
103
|
+
|
104
|
+
Then /^the stdout should contain "([^\"]*)"$/ do |partial_output|
|
105
|
+
@last_stdout.should =~ /#{partial_output}/
|
106
|
+
end
|
107
|
+
|
108
|
+
Then /^the stderr should not contain "([^\"]*)"$/ do |partial_output|
|
109
|
+
@last_stderr.should_not =~ /#{partial_output}/
|
110
|
+
end
|
111
|
+
|
112
|
+
Then /^the stdout should not contain "([^\"]*)"$/ do |partial_output|
|
113
|
+
@last_stdout.should_not =~ /#{partial_output}/
|
114
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aruba
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Aslak Helles\xC3\xB8y"
|
8
|
+
- David Chelimsky
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2010-02-13 00:00:00 -04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
type: :development
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 1.3.0
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: cucumber
|
28
|
+
type: :development
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.6.2
|
35
|
+
version:
|
36
|
+
description: CLI Steps for Cucumber, hand-crafted for you in Aruba
|
37
|
+
email: cukes@groups.google.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- LICENSE
|
44
|
+
- README.rdoc
|
45
|
+
files:
|
46
|
+
- .document
|
47
|
+
- .gitignore
|
48
|
+
- LICENSE
|
49
|
+
- README.rdoc
|
50
|
+
- Rakefile
|
51
|
+
- aruba.gemspec
|
52
|
+
- features/exit_statuses.feature
|
53
|
+
- features/file_system_commands.feature
|
54
|
+
- features/output.feature
|
55
|
+
- features/step_definitions/aruba_steps.rb
|
56
|
+
- features/support/env.rb
|
57
|
+
- lib/aruba.rb
|
58
|
+
has_rdoc: true
|
59
|
+
homepage: http://github.com/aslakhellesoy/aruba
|
60
|
+
licenses: []
|
61
|
+
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options:
|
64
|
+
- --charset=UTF-8
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
version:
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
version:
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.3.5
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: CLI Steps for Cucumber
|
86
|
+
test_files: []
|
87
|
+
|