pickled_aruba 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.bundle/config ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_DISABLE_SHARED_GEMS: "1"
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Don't use sister dependencies no one else will have,
4
+ # Use gems so everyone can compile the code.
5
+ group :development do
6
+ gem 'cucumber', ">= 0.9.3"
7
+ gem 'rspec', ">= 2.0.1"
8
+ gem 'background_process', ">= 1.2.0"
9
+ gem 'jeweler', ">= 1.5.0.pre5"
10
+ gem 'sdoc', ">= 0.2.20"
11
+ end
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.1.0
2
+
3
+ Initial project based on Aruba 2.3.0
4
+ Added case insensitive matchers.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Aruba 2.3.0 Copyright (c) 2010 Aslak Hellesøy and David Chelimsky.
2
+ Pickled Aruba Copyright (c) 2010 Mike Bethany.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,55 @@
1
+ = pickled_aruba
2
+
3
+ My own branch of Aruba so I can have needed changes incorporated immediatly. I have features
4
+ I need to add and was waiting till my first pull request was processed but it never was so I
5
+ needed to take control. My additions so far are very minor but I need to be able to use them
6
+ in my apps when I need them. The Aruba project managers are just to busy to actively support
7
+ pull requests.
8
+
9
+ I'll incorporate main Aruba changes as I need them.
10
+
11
+ Based on Aruba 2.3.0
12
+
13
+ == Description
14
+
15
+ Cucumber steps for driving out command line applications. The command line application can be anything,
16
+ a compiled C program, a Java program, a Perl script - anything.
17
+
18
+ == Usage
19
+
20
+ gem install pickled_aruba
21
+
22
+ Then, just require the library in one of your ruby files under <tt>features/support</tt>
23
+
24
+ require 'pickled_aruba'
25
+
26
+ You now have a bunch of step definitions that you can use in your features. Look at pickled_aruba/cucumber.rb
27
+ to see all the step definitions. Look at features/*.feature for examples (which are also testing PickledAruba
28
+ itself).
29
+
30
+ == Getting more output with tags.
31
+
32
+ PickledAruba has several tags you can use to get more information. You can put these tags on individual scenarios, or on a feature. The tags are:
33
+
34
+ * <tt>@announce-cmd</tt> - See what command is is run
35
+ * <tt>@announce-stdout</tt> - See the stdout
36
+ * <tt>@announce-stderr</tt> - See the stderr
37
+ * <tt>@announce-dir</tt> - See the current directory
38
+ * <tt>@announce-env</tt> - See environment variables set by PickledAruba
39
+ * <tt>@announce</tt> - Does all of the above
40
+
41
+ == Note on Patches/Pull Requests
42
+
43
+ * Fork the project.
44
+ * Make your feature addition or bug fix.
45
+ * Add tests for it. This is important so I don't break it in a
46
+ future version unintentionally.
47
+ * Commit, do not mess with rakefile, version, or history.
48
+ (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)
49
+ * Send me a pull request. Bonus points for topic branches.
50
+
51
+ == Copyright
52
+
53
+ Aruba 2.3.0 Copyright (c) 2010 Aslak Hellesøy and David Chelimsky.
54
+ Pickled Aruba Copyright (c) 2010 Mike Bethany.
55
+ See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+
6
+ $:.unshift 'lib'
7
+ require 'pickled_aruba/version'
8
+ version = PickledAruba::Version::STRING
9
+
10
+ # run "rake gemspec" to create gemspec file
11
+ begin
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ gem.name = "pickled_aruba"
15
+ gem.version = version
16
+ gem.summary = %Q{pickled_aruba-#{version}}
17
+ gem.description = %Q{CLI Steps for Cucumber, pickled for freshness (i.e. so I can add changes without waiting months for pulls)}
18
+ gem.email = "picklepumpers@gmail.com"
19
+ gem.homepage = "http://github.com/PicklePumpers/pickled_aruba"
20
+ gem.authors = ["Aslak Hellesøy", "David Chelimsky", "Mike Bethany"]
21
+
22
+ gem.add_development_dependency "cucumber", ">= 0.9.3"
23
+ end
24
+ Jeweler::GemcutterTasks.new
25
+ rescue LoadError
26
+ abort "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
27
+ end
28
+
29
+ begin
30
+ require 'cucumber/rake/task'
31
+ Cucumber::Rake::Task.new(:cucumber) do |t|
32
+ t.cucumber_opts = "features --format pretty"
33
+ end
34
+ task :cucumber => :check_dependencies
35
+ rescue LoadError
36
+ abort "Cucumber is not available. Install it with: gem install cucumber"
37
+ end
38
+
39
+ task :default => :cucumber
data/config/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pickled_aruba-rvm.yml
@@ -0,0 +1,39 @@
1
+ Feature: Debug
2
+ In order to value
3
+ As a role
4
+ I want feature
5
+
6
+ @active
7
+ Scenario Outline: Detect subset of one-line output
8
+ When I run "<command_line> "
9
+ Then the output should contain "<output_array>"
10
+
11
+ Scenarios: Detect subset of one-line output table
12
+ | command_line | output_array |
13
+ | ruby -e \"puts '<output_array>'\" | line1 |
14
+ | ruby -e \"puts '<output_array>'\" | 'Line two' fudgy whale |
15
+ | ruby -e \"puts '<output_array>'\" | fudgy 'line three' whale |
16
+ | ruby -e \"puts '<output_array>'\" | fudgy whale 'line four' |
17
+ | ruby -e \"puts '<output_array>'\" | 'line five' |
18
+ | ruby -e \"puts '<output_array>'\" | line six |
19
+
20
+
21
+ #@active
22
+ Scenario: Detect subset of one-line output, regardless of case
23
+ When I run "echo 'Hello World'"
24
+ Then the output should, regardless of case, contain "hello world"
25
+
26
+
27
+ #@active
28
+ Scenario: create a dir
29
+ Given a directory named "foo/bar"
30
+ When I run "ruby -e \"puts test ?d, 'foo'\""
31
+ Then the stdout should contain "true"
32
+
33
+ #@active
34
+ Scenario: Detect subset of multiline output, regardless of case
35
+ When I run "ruby -e 'puts \"hello\\nworld\"'"
36
+ Then the output should, regardless of case, contain:
37
+ """
38
+ Hello
39
+ """
@@ -0,0 +1,21 @@
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
14
+ And the exit status should not be 0
15
+
16
+ Scenario: Successfully run something
17
+ When I successfully run "ruby -e 'exit 0'"
18
+
19
+ Scenario: Unsuccessfully run something
20
+ When I do pickled_aruba I successfully run "ruby -e 'exit 10'"
21
+ Then pickled_aruba should fail with "Exit status was 10"
@@ -0,0 +1,102 @@
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: create 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 the output should contain "hello world"
19
+
20
+ Scenario: append to a file
21
+ Given a file named "foo/bar/example.rb" with:
22
+ """
23
+ puts "hello world"
24
+ """
25
+ When I append to "foo/bar/example.rb" with:
26
+ """
27
+ puts "this was appended"
28
+ """
29
+ When I run "ruby foo/bar/example.rb"
30
+ Then the output should contain "hello world"
31
+ And the output should contain "this was appended"
32
+
33
+ Scenario: clean up files generated in previous scenario
34
+ When I run "ruby foo/bar/example.rb"
35
+ Then the exit status should be 1
36
+ And the output should contain "No such file or directory -- foo/bar/example.rb"
37
+
38
+ Scenario: change to a subdir
39
+ Given a file named "foo/bar/example.rb" with:
40
+ """
41
+ puts "hello world"
42
+ """
43
+ When I cd to "foo/bar"
44
+ And I run "ruby example.rb"
45
+ Then the output should contain "hello world"
46
+
47
+ Scenario: Reset current directory from previous scenario
48
+ When I run "ruby example.rb"
49
+ Then the exit status should be 1
50
+
51
+ Scenario: Holler if cd to bad dir
52
+ Given a file named "foo/bar/example.rb" with:
53
+ """
54
+ puts "hello world"
55
+ """
56
+ When I do pickled_aruba I cd to "foo/nonexistant"
57
+ Then pickled_aruba should fail with "tmp/pickled_aruba/foo/nonexistant is not a directory"
58
+
59
+ Scenario: Check for presence of a subset of files
60
+ Given an empty file named "lorem/ipsum/dolor"
61
+ Given an empty file named "lorem/ipsum/sit"
62
+ Given an empty file named "lorem/ipsum/amet"
63
+ Then the following files should exist:
64
+ | lorem/ipsum/dolor |
65
+ | lorem/ipsum/amet |
66
+
67
+ Scenario: Check for absence of files
68
+ Then the following files should not exist:
69
+ | lorem/ipsum/dolor |
70
+
71
+ Scenario: Check for presence of a subset of directories
72
+ Given a directory named "foo/bar"
73
+ Given a directory named "foo/bla"
74
+ Then the following directories should exist:
75
+ | foo/bar |
76
+ | foo/bla |
77
+
78
+ Scenario: check for absence of directories
79
+ Given a directory named "foo/bar"
80
+ Given a directory named "foo/bla"
81
+ Then the following step should fail with Spec::Expectations::ExpectationNotMetError:
82
+ """
83
+ Then the following directories should not exist:
84
+ | foo/bar/ |
85
+ | foo/bla/ |
86
+ """
87
+
88
+ Scenario: Check file contents
89
+ Given a file named "foo" with:
90
+ """
91
+ hello world
92
+ """
93
+ Then the file "foo" should contain "hello world"
94
+ And the file "foo" should not contain "HELLO WORLD"
95
+
96
+ Scenario: Check file contents
97
+ Given a file named "foo" with:
98
+ """
99
+ hello world
100
+ """
101
+ Then the file "foo" should match /hel.o world/
102
+ And the file "foo" should not match /HELLO WORLD/
@@ -0,0 +1,30 @@
1
+ Feature: Interactive process control
2
+
3
+ In order to test interactive command line applications
4
+ As a developer using Cucumber
5
+ I want to use the interactive session steps
6
+
7
+ Scenario: Running ruby interactively
8
+ Given a file named "echo.rb" with:
9
+ """
10
+ while res = gets.chomp
11
+ break if res == "quit"
12
+ puts res.reverse
13
+ end
14
+ """
15
+ When I run "ruby echo.rb" interactively
16
+ And I type "hello, world"
17
+ And I type "quit"
18
+ Then the output should contain:
19
+ """
20
+ dlrow ,olleh
21
+ """
22
+
23
+ Scenario: Running a native binary interactively
24
+ When I run "bc -q" interactively
25
+ And I type "4 + 3"
26
+ And I type "quit"
27
+ Then the output should contain:
28
+ """
29
+ 7
30
+ """
@@ -0,0 +1,247 @@
1
+ Feature: Output
2
+
3
+ In order to specify expected output
4
+ As a developer using Cucumber
5
+ I want to use the "the output should contain" step
6
+
7
+ Scenario: Run unknown command
8
+ When I run "neverever gonna work"
9
+ Then the output should contain:
10
+ """
11
+ No such file or directory - neverever gonna work
12
+ """
13
+
14
+ Scenario: Run unknown command, regardless of case
15
+ When I run "neverever gonna work"
16
+ Then the output should, regardless of case, contain:
17
+ """
18
+ no such file or directory - neverever gonna work
19
+ """
20
+
21
+ Scenario: Detect subset of one-line output
22
+ When I run "ruby -e 'puts \"hello world\"'"
23
+ Then the output should contain "hello world"
24
+
25
+ Scenario: Detect subset of one-line output
26
+ When I run "echo 'hello world'"
27
+ Then the output should contain "hello world"
28
+
29
+ Scenario: Detect subset of one-line output, regardless of case
30
+ When I run "echo 'Hello World'"
31
+ Then the output should, regardless of case, contain "hello world"
32
+
33
+ Scenario: Detect absence of one-line output
34
+ When I run "ruby -e 'puts \"hello world\"'"
35
+ Then the output should not contain "good-bye"
36
+ And the output should not contain "Hello World"
37
+
38
+ Scenario: Detect absence of one-line output, regardless of case
39
+ When I run "ruby -e 'puts \"hello world\"'"
40
+ Then the output should not, regardless of case, contain "good-bye"
41
+
42
+ Scenario: Detect subset of multiline output
43
+ When I run "ruby -e 'puts \"hello\\nworld\"'"
44
+ Then the output should contain:
45
+ """
46
+ hello
47
+ """
48
+
49
+ Scenario: Detect subset of multiline output, regardless of case
50
+ When I run "ruby -e 'puts \"hello\\nworld\"'"
51
+ Then the output should, regardless of case, contain:
52
+ """
53
+ Hello
54
+ """
55
+
56
+ Scenario: Detect subset of multiline output
57
+ When I run "ruby -e 'puts \"hello\\nworld\"'"
58
+ Then the output should not contain:
59
+ """
60
+ good-bye
61
+ """
62
+ And the output should not contain:
63
+ """
64
+ Hello
65
+ """
66
+
67
+ Scenario: Detect subset of multiline output, regardless of case
68
+ When I run "ruby -e 'puts \"hello\\nworld\"'"
69
+ Then the output should not, regardless of case, contain:
70
+ """
71
+ good-bye
72
+ """
73
+
74
+ Scenario: Detect exact one-line output
75
+ When I run "ruby -e 'puts \"hello world\"'"
76
+ Then the output should contain exactly "hello world\n"
77
+
78
+ Scenario: Detect exact one-line output, regardless of case
79
+ When I run "ruby -e 'puts \"Hello World\"'"
80
+ Then the output should, regardless of case, contain exactly "hello world\n"
81
+
82
+ Scenario: Detect exact multiline output
83
+ When I run "ruby -e 'puts \"hello\\nworld\"'"
84
+ Then the output should contain exactly:
85
+ """
86
+ hello
87
+ world
88
+
89
+ """
90
+
91
+ Scenario: Detect exact multiline output, regardless of case
92
+ When I run "ruby -e 'puts \"Hello\\nWorld\"'"
93
+ Then the output should, regardless of case, contain exactly:
94
+ """
95
+ hello
96
+ world
97
+
98
+ """
99
+
100
+ @announce
101
+ Scenario: Detect subset of one-line output with regex
102
+ When I run "ruby --version"
103
+ Then the output should contain "ruby"
104
+ And the output should match /ruby ([\d]+\.[\d]+\.[\d]+)(p\d+)? \(.*$/
105
+
106
+
107
+ @announce
108
+ Scenario: Detect subset of one-line output with regex, regardless of case
109
+ When I run "ruby --version"
110
+ Then the output should contain "ruby"
111
+ And the output should match /RuBy ([\d]+\.[\d]+\.[\d]+)(p\d+)? \(.*$/i
112
+
113
+ @announce
114
+ Scenario: Do not detect unwanted text in subset of one-line output with regex
115
+ When I run "ruby --version"
116
+ Then the output should contain "ruby"
117
+ And the output should not match /Ruby/
118
+ And the output should not match /python/
119
+
120
+ @announce
121
+ Scenario: Do not detect unwanted text in subset of one-line output with regex, regardless of case
122
+ When I run "ruby --version"
123
+ Then the output should contain "ruby"
124
+ And the output should not match /Python/i
125
+
126
+ @announce
127
+ Scenario: Detect subset of multiline output with regex
128
+ When I run "ruby -e 'puts \"hello\\nworld\\nextra line1\\nextra line2\\nimportant line\"'"
129
+ Then the output should match:
130
+ """
131
+ he..o
132
+ wor.d
133
+ .*
134
+ important line
135
+ """
136
+
137
+ @announce
138
+ Scenario: Detect subset of multiline output with regex, regardless of case
139
+ When I run "ruby -e 'puts \"Hello\\nWorld\\nExtra line1\\nExtra line2\\nIMPORTANT LINE\"'"
140
+ Then the output should, regardless of case, match:
141
+ """
142
+ he..o
143
+ wor.d
144
+ .*
145
+ important line
146
+ """
147
+
148
+ @announce
149
+ Scenario: Do not detect unwanted text in subset of multiline output with regex
150
+ When I run "ruby -e 'puts \"Hello\\nWorld\\nExtra line1\\nExtra line2\\nIMPORTANT LINE\"'"
151
+ Then the output should not match:
152
+ """
153
+ g..bye
154
+ cruel worl.d
155
+ .*
156
+ unimportant blurb
157
+ """
158
+ And the output should not match:
159
+ """
160
+ he..o
161
+ wor.d
162
+ .*
163
+ important line
164
+ """
165
+
166
+ @announce
167
+ Scenario: Do not detect unwanted text in subset of multiline output with regex, regardless of case
168
+ When I run "ruby -e 'puts \"hello\\nworld\\nextra line1\\nextra line2\\nimportant line\"'"
169
+ Then the output should not, regardless of case, match:
170
+ """
171
+ G..bye
172
+ Cruel Worl.d
173
+ .*
174
+ EXCLAMATION!
175
+ """
176
+
177
+ @announce
178
+ Scenario: Match passing exit status and partial output
179
+ When I run "ruby -e 'puts \"hello\\nworld\"'"
180
+ Then it should pass with:
181
+ """
182
+ hello
183
+ """
184
+
185
+ @announce
186
+ Scenario: Match passing exit status and partial output, regardless of case
187
+ When I run "ruby -e 'puts \"Hello\\nWorld\"'"
188
+ Then it should, regardless of case, pass with:
189
+ """
190
+ hello
191
+ """
192
+
193
+ @announce-stdout
194
+ Scenario: Match failing exit status and partial output
195
+ When I run "ruby -e 'puts \"hello\\nworld\";exit 99'"
196
+ Then it should fail with:
197
+ """
198
+ hello
199
+ """
200
+
201
+ @announce-stdout
202
+ Scenario: Match failing exit status and partial output, regardless of case
203
+ When I run "ruby -e 'puts \"Hello\\nWorld\";exit 99'"
204
+ Then it should, regardless of case, fail with:
205
+ """
206
+ hello
207
+ """
208
+
209
+ @announce-stdout
210
+ Scenario: Match failing exit status and output with regex
211
+ When I run "ruby -e 'puts \"hello\\nworld\";exit 99'"
212
+ Then it should fail with regex:
213
+ """
214
+ hello\s*world
215
+ """
216
+
217
+ @announce-stdout
218
+ Scenario: Match failing exit status and output with regex, regardless of case
219
+ When I run "ruby -e 'puts \"Hello\\nWorld\";exit 99'"
220
+ Then it should, regardless of case, fail with regex:
221
+ """
222
+ hello\s*world
223
+ """
224
+
225
+ @announce-cmd
226
+ Scenario: Match output in stdout
227
+ When I run "ruby -e 'puts \"hello\\nworld\"'"
228
+ Then the stdout should contain "hello"
229
+ Then the stderr should not contain "hello"
230
+
231
+ @announce-cmd
232
+ Scenario: Match output in stdout, regardless of case
233
+ When I run "ruby -e 'puts \"Hello\\nWorld\"'"
234
+ Then the stdout should, regardless of case, contain "hello"
235
+ Then the stderr should not, regardless of case, contain "hello"
236
+
237
+ @announce-stderr
238
+ Scenario: Match output in stderr
239
+ When I run "ruby -e 'STDERR.puts \"hello\\nworld\";exit 99'"
240
+ Then the stderr should contain "hello"
241
+ Then the stdout should not contain "hello"
242
+
243
+ @announce-stderr
244
+ Scenario: Match output in stderr, regardless of case
245
+ When I run "ruby -e 'STDERR.puts \"Hello\\nWorld\";exit 99'"
246
+ Then the stderr should, regardless of case, contain "hello"
247
+ Then the stdout should not, regardless of case, contain "hello"