aruba-rspec 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +86 -0
- data/Rakefile +1 -0
- data/aruba-rspec.gemspec +26 -0
- data/lib/aruba/rspec/matchers/shellout.rb +19 -0
- data/lib/aruba/rspec/matchers.rb +1 -0
- data/lib/aruba/rspec/version.rb +5 -0
- data/lib/aruba/rspec.rb +21 -0
- data/spec/aruba/rspec_spec.rb +4 -0
- data/spec/spec_helper.rb +17 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a0263867302d80bead092e5bb3dfc3158697125a
|
4
|
+
data.tar.gz: be51547f565e2bfc4561c9b8dd4dd87e9604dff6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ca019ded0d113fb6d1b332f4cf0f60015fdc0ba08d3604261548428407a28a0bebfcf17cd25c4dbd5597ef10cfb5b0c19680969abaeafd92115b9ce3899e8c7
|
7
|
+
data.tar.gz: 3a89b8cab8043b2a84dddbb3672f490dc0e9402e18f7f9498d9b94ee9303d20cd5c78959a6e4b3f7da9098e8858354b691fc937516475bd7ef4671650463963f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
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,86 @@
|
|
1
|
+
Aruba::RSpec
|
2
|
+
============
|
3
|
+
|
4
|
+
Aruba and ArubaDoubles are tools for testing command-line programs using
|
5
|
+
Cucumber. They allow for setting up command stubs, then testing
|
6
|
+
expectations on those stubs. This gem helps to integrate the two
|
7
|
+
directly in RSpec.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
group :test do
|
15
|
+
gem 'aruba-rspec'
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Add `aruba-rspec` to your `spec_helper.rb` file as follows:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'aruba/rspec'
|
25
|
+
|
26
|
+
RSpec.configure do |config|
|
27
|
+
config.include Aruba::RSpec
|
28
|
+
|
29
|
+
config.before :each do
|
30
|
+
Aruba::RSpec.setup
|
31
|
+
end
|
32
|
+
|
33
|
+
config.after :each do
|
34
|
+
Aruba::RSpec.teardown
|
35
|
+
end
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
## Command doubles
|
40
|
+
|
41
|
+
This comes out of ArubaDoubles:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
describe 'Using doubles' do
|
45
|
+
before do
|
46
|
+
double_cmd('which', puts: '/some/path')
|
47
|
+
double_cmd('sudo', warn: 'No!', exit: 1)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'can run a command that succeeds' do
|
51
|
+
expect(`which thing`).to eq('/some/path')
|
52
|
+
expect($?.exitstatus).to eq(0)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'can run a command that fails' do
|
56
|
+
expect(`sudo do soemthing`).to be nil
|
57
|
+
expect($?.exitstatus).to eq(1)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
## Matchers
|
63
|
+
|
64
|
+
### :shellout
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
describe MyThing do
|
68
|
+
it 'calls out to an external command' do
|
69
|
+
double_cmd('thing')
|
70
|
+
expect {
|
71
|
+
`thing --with --options`
|
72
|
+
}.to shellout('thing --with --options')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
## References
|
78
|
+
|
79
|
+
* `https://github.com/cucumber/aruba`
|
80
|
+
* `https://github.com/bjoernalbers/aruba-doubles`
|
81
|
+
|
82
|
+
## Contributing
|
83
|
+
|
84
|
+
1. Fork it ( http://github.com/<my-github-username>/aruba-rspec/fork )
|
85
|
+
2. Use feature branches
|
86
|
+
3. Write tests for any changes
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/aruba-rspec.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'aruba/rspec/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "aruba-rspec"
|
8
|
+
spec.version = Aruba::RSpec::VERSION
|
9
|
+
spec.authors = ["Eric Saxby"]
|
10
|
+
spec.email = %w(sax@livinginthepast.org)
|
11
|
+
spec.summary = %q{Bridge RSpec and Aruba to test command-line tools}
|
12
|
+
spec.description = %q{Aruba and ArubaDoubles help to test command-line tools, but they are build around Cucumber. This gem helps integrate with RSpec.}
|
13
|
+
spec.homepage = "https://github.com/livinginthepast/aruba-rspec"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'rspec'
|
22
|
+
spec.add_dependency 'aruba'
|
23
|
+
spec.add_dependency 'aruba-doubles'
|
24
|
+
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
RSpec::Matchers.define :shellout do |cmd|
|
2
|
+
match do |ruby|
|
3
|
+
raise ArgumentError, "expected should be a Proc" unless ruby.is_a?(Proc)
|
4
|
+
@ruby = ruby.call
|
5
|
+
Aruba::RSpec.history.include?(cmd.shellsplit)
|
6
|
+
end
|
7
|
+
|
8
|
+
failure_message_for_should do |ruby|
|
9
|
+
"expected that #{@ruby} would run command #{cmd}\nfound: #{Aruba::RSpec.history.map(&:shelljoin)}"
|
10
|
+
end
|
11
|
+
|
12
|
+
failure_message_for_should_not do |ruby|
|
13
|
+
"expected that #{@ruby} would NOT run command #{cmd}"
|
14
|
+
end
|
15
|
+
|
16
|
+
description do
|
17
|
+
"run command #{cmd}"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'aruba/rspec/matchers/shellout'
|
data/lib/aruba/rspec.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'aruba/rspec/version'
|
2
|
+
|
3
|
+
require 'aruba-doubles'
|
4
|
+
require 'aruba/rspec/matchers'
|
5
|
+
|
6
|
+
module Aruba
|
7
|
+
module RSpec
|
8
|
+
def self.history
|
9
|
+
@history ||= ArubaDoubles::History.new(File.join(ArubaDoubles::Double.bindir, ArubaDoubles::HISTORY_FILE))
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.setup
|
13
|
+
ArubaDoubles::Double.setup
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.teardown
|
17
|
+
ArubaDoubles::Double.teardown
|
18
|
+
history.clear
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aruba-rspec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Saxby
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aruba
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aruba-doubles
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Aruba and ArubaDoubles help to test command-line tools, but they are
|
84
|
+
build around Cucumber. This gem helps integrate with RSpec.
|
85
|
+
email:
|
86
|
+
- sax@livinginthepast.org
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- aruba-rspec.gemspec
|
98
|
+
- lib/aruba/rspec.rb
|
99
|
+
- lib/aruba/rspec/matchers.rb
|
100
|
+
- lib/aruba/rspec/matchers/shellout.rb
|
101
|
+
- lib/aruba/rspec/version.rb
|
102
|
+
- spec/aruba/rspec_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: https://github.com/livinginthepast/aruba-rspec
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.2.0
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Bridge RSpec and Aruba to test command-line tools
|
128
|
+
test_files:
|
129
|
+
- spec/aruba/rspec_spec.rb
|
130
|
+
- spec/spec_helper.rb
|