aruba 0.5.3 → 0.5.4

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fb86636b75dbff7127e814b3e4ddc8d0dbfc17aa
4
+ data.tar.gz: 062abfc4550ad7a49265cc2a1bf1db54f46e1025
5
+ SHA512:
6
+ metadata.gz: 66422110e4192b2e11fa3cd08f6df00cd862312d9bb2a2cb86fda2b4911ef7d10ee8ab85d2199511cb6b0791fbd8720afedbfd02f23a7c5f8294cd69ae31c792
7
+ data.tar.gz: 02126e2869de5ba3301f84c61c79afcbc1c60dd48813fec687ba2a930908023038dbbd5256e61cb13d6b19c7406e412323b14710d7edbdc022021bfcb50db0e7
data/History.md CHANGED
@@ -1,4 +1,11 @@
1
- ## [master](https://github.com/cucumber/aruba/compare/v0.5.2...master)
1
+ ## [master](https://github.com/cucumber/aruba/compare/v0.5.4...master)
2
+
3
+ ## [v0.5.4](https://github.com/cucumber/aruba/compare/v0.5.3...v0.5.4)
4
+ * Added support for piping in files (#154 maxmeyer, dg-vrnetze)
5
+ * Added cucumber steps for environment variables (#156 dg-vrnetze)
6
+ * Added support for file mode (#157 maxmeyer, dg-vrnetze)
7
+
8
+ ## [v0.5.3](https://github.com/cucumber/aruba/compare/v0.5.2...v0.5.3)
2
9
  * Fix for UTF-8 support (#151 Matt Wynne, Jarl Friis)
3
10
  * Fix for open file leakage (#150 @JonRowe)
4
11
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://secure.travis-ci.org/cucumber/aruba.png)](http://travis-ci.org/cucumber/aruba) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/cucumber/aruba)
1
+ [![Build Status](https://secure.travis-ci.org/cucumber/aruba.png)](http://travis-ci.org/cucumber/aruba) [![Code Climate](https://codeclimate.com/github/cucumber/aruba.png)](https://codeclimate.com/github/cucumber/aruba)
2
2
 
3
3
  Aruba is Cucumber extension for testing command line applications written in any programming language. Features at a glance:
4
4
 
@@ -2,10 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'aruba'
5
- s.version = '0.5.3'
5
+ s.version = '0.5.4'
6
6
  s.authors = ["Aslak Hellesøy", "David Chelimsky", "Mike Sassak", "Matt Wynne"]
7
7
  s.description = 'CLI Steps for Cucumber, hand-crafted for you in Aruba'
8
8
  s.summary = "aruba-#{s.version}"
9
+ s.license = 'MIT'
9
10
  s.email = 'cukes@googlegroups.com'
10
11
  s.homepage = 'http://github.com/cucumber/aruba'
11
12
 
@@ -15,7 +16,8 @@ Gem::Specification.new do |s|
15
16
  s.add_development_dependency 'bcat', '>= 0.6.1'
16
17
  s.add_development_dependency 'kramdown', '>= 0.14'
17
18
  s.add_development_dependency 'rake', '>= 0.9.2'
18
- s.add_development_dependency 'rspec', '>= 2.7.0'
19
+ s.add_development_dependency 'rspec', '>= 2.11.0'
20
+ s.add_development_dependency 'fuubar', '>= 1.1.1'
19
21
 
20
22
  s.rubygems_version = ">= 1.6.1"
21
23
  s.files = `git ls-files`.split("\n")
@@ -24,4 +26,3 @@ Gem::Specification.new do |s|
24
26
  s.rdoc_options = ["--charset=UTF-8"]
25
27
  s.require_path = "lib"
26
28
  end
27
-
@@ -0,0 +1,15 @@
1
+ Feature: Command environment variables
2
+
3
+ In order to test command line applications which make use of environment variables
4
+ As a developer using Cucumber
5
+ I want to use the command environment variable step
6
+
7
+ Scenario: Changing the environment
8
+ Given I set the environment variables to:
9
+ | variable | value |
10
+ | LONG_LONG_VARIABLE | long_value |
11
+ When I run `/usr/bin/env`
12
+ Then the output should contain:
13
+ """
14
+ long_value
15
+ """
@@ -89,6 +89,17 @@ Feature: file system commands
89
89
  Scenario: Check for absence of a single file
90
90
  Then a file named "lorem/ipsum/dolor" should not exist
91
91
 
92
+ Scenario: Check for absence of a single file using a regex
93
+ Then a file matching %r<^ipsum> should not exist
94
+
95
+ Scenario: Check for presence of a single file using a regex
96
+ Given an empty file named "lorem/ipsum/dolor"
97
+ Then a file matching %r<dolor$> should exist
98
+
99
+ Scenario: Check for presence of a single file using a more complicated regex
100
+ Given an empty file named "lorem/ipsum/dolor"
101
+ Then a file matching %r<ipsum/dolor> should exist
102
+
92
103
  Scenario: Check for presence of a subset of directories
93
104
  Given a directory named "foo/bar"
94
105
  Given a directory named "foo/bla"
@@ -159,3 +170,18 @@ Feature: file system commands
159
170
  Given an empty file named "a/b.txt"
160
171
  Given an empty file named "a/b/c.txt"
161
172
  Given an empty file named "a/b/c/d.txt"
173
+
174
+ Scenario: Change mode of empty file
175
+ Given an empty file named "test.txt" with mode "0666"
176
+ Then the mode of filesystem object "test.txt" should match "0666"
177
+
178
+ Scenario: Change mode of a directory
179
+ Given a directory named "test.d" with mode "0666"
180
+ Then the mode of filesystem object "test.d" should match "0666"
181
+
182
+ Scenario: Change mode of file
183
+ Given a file named "test.txt" with mode "0666" and with:
184
+ """
185
+ asdf
186
+ """
187
+ Then the mode of filesystem object "test.txt" should match "0666"
@@ -11,12 +11,14 @@ Feature: Flushing output
11
11
  And the exit status should be 0
12
12
 
13
13
  Scenario: Tons of output
14
+ Given The default aruba timeout is 10 seconds
14
15
  When I run `bash -c 'for ((c=0; c<65536; c = c+1)); do echo -n "a"; done'`
15
16
  Then the output should contain "a"
16
17
  And the output should be 65536 bytes long
17
18
  And the exit status should be 0
18
19
 
19
20
  Scenario: Tons of interactive output
21
+ Given The default aruba timeout is 10 seconds
20
22
  When I run `bash -c 'read size; for ((c=0; c<$size; c = c+1)); do echo -n "a"; done'` interactively
21
23
  And I type "65536"
22
24
  Then the output should contain "a"
@@ -31,6 +31,31 @@ Feature: Interactive process control
31
31
  Hello, world
32
32
  """
33
33
 
34
+ @posix
35
+ Scenario: Pipe in a file
36
+ Given a file named "test.txt" with:
37
+ """
38
+ line1
39
+ line2
40
+ """
41
+ When I run `cat` interactively
42
+ And I pipe in the file "test.txt"
43
+ Then the output should contain:
44
+ """
45
+ line1
46
+ line2
47
+ """
48
+
49
+ @posix
50
+ Scenario: Close stdin stream
51
+ When I run `cat` interactively
52
+ And I type "Hello, world"
53
+ And I close the stdin stream
54
+ Then the output should contain:
55
+ """
56
+ Hello, world
57
+ """
58
+
34
59
  @posix
35
60
  Scenario: Stop processes before checking for filesystem changes
36
61
  See: http://github.com/aslakhellesoy/aruba/issues#issue/17 for context
@@ -5,4 +5,4 @@ module Aruba
5
5
  attr_accessor :process
6
6
  end
7
7
  self.process = Aruba::SpawnProcess
8
- end
8
+ end
@@ -4,6 +4,8 @@ require 'rspec/expectations'
4
4
  require 'aruba'
5
5
  require 'aruba/config'
6
6
 
7
+ Dir.glob( File.join( File.expand_path( '../matchers' , __FILE__ ) , '*.rb' ) ).each { |rb| require rb }
8
+
7
9
  module Aruba
8
10
  module Api
9
11
  include RSpec::Matchers
@@ -13,6 +15,11 @@ module Aruba
13
15
  Dir.chdir(current_dir, &block)
14
16
  end
15
17
 
18
+ def clean_current_dir
19
+ _rm_rf(current_dir)
20
+ _mkdir(current_dir)
21
+ end
22
+
16
23
  def current_dir
17
24
  File.join(*dirs)
18
25
  end
@@ -46,6 +53,23 @@ module Aruba
46
53
  end
47
54
  end
48
55
 
56
+ def chmod(mode, name)
57
+ in_current_dir do
58
+ raise "expected #{name} to be present" unless FileTest.exists?(name)
59
+ if mode.kind_of? String
60
+ FileUtils.chmod(mode.to_i(8),name)
61
+ else
62
+ FileUtils.chmod(mode,name)
63
+ end
64
+ end
65
+ end
66
+
67
+ def mod?(mode, name)
68
+ in_current_dir do
69
+ mode == sprintf( "%o", File::Stat.new(name).mode )[-4,4].to_i(8)
70
+ end
71
+ end
72
+
49
73
  def _create_fixed_size_file(file_name, file_size, check_presence)
50
74
  in_current_dir do
51
75
  raise "expected #{file_name} to be present" if check_presence && !File.file?(file_name)
@@ -82,25 +106,41 @@ module Aruba
82
106
  def check_file_presence(paths, expect_presence)
83
107
  prep_for_fs_check do
84
108
  paths.each do |path|
85
- if expect_presence
86
- File.should be_file(path)
109
+ if path.kind_of? Regexp
110
+ if expect_presence
111
+ expect(Dir.glob('**/*')).to include_regexp(path)
112
+ else
113
+ expect(Dir.glob('**/*')).not_to include_regexp(path)
114
+ end
87
115
  else
88
- File.should_not be_file(path)
116
+ if expect_presence
117
+ expect(File).to be_file(path)
118
+ else
119
+ expect(File).not_to be_file(path)
120
+ end
89
121
  end
90
122
  end
91
123
  end
92
124
  end
93
125
 
126
+ def pipe_in_file(file)
127
+ in_current_dir do
128
+ File.open(file, 'r').each_line do |line|
129
+ _write_interactive(line)
130
+ end
131
+ end
132
+ end
133
+
94
134
  def check_file_size(paths_and_sizes)
95
135
  prep_for_fs_check do
96
136
  paths_and_sizes.each do |path, size|
97
- File.size(path).should == size
137
+ expect(File.size(path)).to eq size
98
138
  end
99
139
  end
100
140
  end
101
141
 
102
142
  def with_file_content(file, &block)
103
- prep_for_fs_check do
143
+ prep_for_fs_check do
104
144
  content = IO.read(file)
105
145
  yield(content)
106
146
  end
@@ -108,27 +148,27 @@ module Aruba
108
148
 
109
149
  def check_file_content(file, partial_content, expect_match)
110
150
  regexp = regexp(partial_content)
111
- prep_for_fs_check do
151
+ prep_for_fs_check do
112
152
  content = IO.read(file)
113
153
  if expect_match
114
- content.should =~ regexp
154
+ expect(content).to match regexp
115
155
  else
116
- content.should_not =~ regexp
156
+ expect(content).not_to match regexp
117
157
  end
118
158
  end
119
159
  end
120
160
 
121
161
  def check_exact_file_content(file, exact_content)
122
- prep_for_fs_check { IO.read(file).should == exact_content }
162
+ prep_for_fs_check { expect(IO.read(file)).to eq exact_content }
123
163
  end
124
164
 
125
165
  def check_directory_presence(paths, expect_presence)
126
166
  prep_for_fs_check do
127
167
  paths.each do |path|
128
168
  if expect_presence
129
- File.should be_directory(path)
169
+ expect(File).to be_directory(path)
130
170
  else
131
- File.should_not be_directory(path)
171
+ expect(File).not_to be_directory(path)
132
172
  end
133
173
  end
134
174
  end
@@ -143,6 +183,10 @@ module Aruba
143
183
  FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
144
184
  end
145
185
 
186
+ def _rm_rf(dir_name)
187
+ FileUtils.rm_rf(dir_name)
188
+ end
189
+
146
190
  def unescape(string)
147
191
  string = string.gsub('\n', "\n").gsub('\"', '"').gsub('\e', "\e")
148
192
  string = string.gsub(/\e\[\d+(?>(;\d+)*)m/, '') unless @aruba_keep_ansi
@@ -184,30 +228,30 @@ module Aruba
184
228
 
185
229
  def assert_exact_output(expected, actual)
186
230
  actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
187
- unescape(actual).should == unescape(expected)
231
+ expect(unescape(actual)).to eq unescape(expected)
188
232
  end
189
233
 
190
234
  def assert_partial_output(expected, actual)
191
235
  actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
192
- unescape(actual).should include(unescape(expected))
236
+ expect(unescape(actual)).to include(unescape(expected))
193
237
  end
194
238
 
195
239
  def assert_matching_output(expected, actual)
196
240
  actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
197
- unescape(actual).should =~ /#{unescape(expected)}/m
241
+ expect(unescape(actual)).to match /#{unescape(expected)}/m
198
242
  end
199
243
 
200
244
  def assert_not_matching_output(expected, actual)
201
245
  actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
202
- unescape(actual).should_not =~ /#{unescape(expected)}/m
246
+ expect(unescape(actual)).not_to match /#{unescape(expected)}/m
203
247
  end
204
248
 
205
249
  def assert_no_partial_output(unexpected, actual)
206
250
  actual.force_encoding(unexpected.encoding) if RUBY_VERSION >= "1.9"
207
251
  if Regexp === unexpected
208
- unescape(actual).should_not =~ unexpected
252
+ expect(unescape(actual)).not_to match unexpected
209
253
  else
210
- unescape(actual).should_not include(unexpected)
254
+ expect(unescape(actual)).not_to include(unexpected)
211
255
  end
212
256
  end
213
257
 
@@ -243,12 +287,12 @@ module Aruba
243
287
  end
244
288
 
245
289
  def assert_exit_status(status)
246
- last_exit_status.should eq(status),
290
+ expect(last_exit_status).to eq(status),
247
291
  append_output_to("Exit status was #{last_exit_status} but expected it to be #{status}.")
248
292
  end
249
293
 
250
294
  def assert_not_exit_status(status)
251
- last_exit_status.should_not eq(status),
295
+ expect(last_exit_status).not_to eq(status),
252
296
  append_output_to("Exit status was #{last_exit_status} which was not expected.")
253
297
  end
254
298
 
@@ -278,7 +322,9 @@ module Aruba
278
322
  end
279
323
 
280
324
  def get_process(wanted)
281
- processes.reverse.find{ |name, _| name == wanted }[-1]
325
+ matching_processes = processes.reverse.find{ |name, _| name == wanted }
326
+ raise ArgumentError.new("No process named '#{wanted}' has been started") unless matching_processes
327
+ matching_processes.last
282
328
  end
283
329
 
284
330
  def only_processes
@@ -331,14 +377,19 @@ module Aruba
331
377
  end
332
378
 
333
379
  def type(input)
334
- return eot if "" == input
380
+ return close_input if "" == input
335
381
  _write_interactive(_ensure_newline(input))
336
382
  end
337
383
 
338
- def eot
384
+ def close_input
339
385
  @interactive.stdin.close
340
386
  end
341
387
 
388
+ def eot
389
+ warn(%{\e[35m The \"#eot\"-method is deprecated. It will be deleted with the next major version. Please use \"#close_input\"-method instead.\e[0m})
390
+ close_input
391
+ end
392
+
342
393
  def _write_interactive(input)
343
394
  @interactive.stdin.write(input)
344
395
  @interactive.stdin.flush
@@ -430,8 +481,8 @@ module Aruba
430
481
  end
431
482
 
432
483
  def announcer
433
- Announcer.new(self,
434
- :stdout => @announce_stdout,
484
+ Announcer.new(self,
485
+ :stdout => @announce_stdout,
435
486
  :stderr => @announce_stderr,
436
487
  :dir => @announce_dir,
437
488
  :cmd => @announce_cmd,
@@ -16,10 +16,20 @@ Given /^a directory named "([^"]*)"$/ do |dir_name|
16
16
  create_dir(dir_name)
17
17
  end
18
18
 
19
+ Given /^a directory named "([^"]*)" with mode "([^"]*)"$/ do |dir_name, dir_mode|
20
+ create_dir(dir_name)
21
+ chmod(dir_mode, dir_name)
22
+ end
23
+
19
24
  Given /^a file named "([^"]*)" with:$/ do |file_name, file_content|
20
25
  write_file(file_name, file_content)
21
26
  end
22
27
 
28
+ Given /^a file named "([^"]*)" with mode "([^"]*)" and with:$/ do |file_name, file_mode, file_content|
29
+ write_file(file_name, file_content)
30
+ chmod(file_mode, file_name)
31
+ end
32
+
23
33
  Given /^a (\d+) byte file named "([^"]*)"$/ do |file_size, file_name|
24
34
  write_fixed_size_file(file_name, file_size.to_i)
25
35
  end
@@ -28,6 +38,11 @@ Given /^an empty file named "([^"]*)"$/ do |file_name|
28
38
  write_file(file_name, "")
29
39
  end
30
40
 
41
+ Given /^an empty file named "([^"]*)" with mode "([^"]*)"$/ do |file_name, file_mode|
42
+ write_file(file_name, "")
43
+ chmod(file_mode, file_name)
44
+ end
45
+
31
46
  When /^I write to "([^"]*)" with:$/ do |file_name, file_content|
32
47
  write_file(file_name, file_content)
33
48
  end
@@ -52,6 +67,15 @@ When /^I cd to "([^"]*)"$/ do |dir|
52
67
  cd(dir)
53
68
  end
54
69
 
70
+ Given /^I set the environment variables to:/ do |table|
71
+ table.hashes.each do |row|
72
+ variable = row['variable'].to_s.upcase
73
+ value = row['value'].to_s
74
+
75
+ set_env(variable, value)
76
+ end
77
+ end
78
+
55
79
  When /^I run "(.*)"$/ do |cmd|
56
80
  warn(%{\e[35m The /^I run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
57
81
  run_simple(unescape(cmd), false)
@@ -85,6 +109,16 @@ When /^I type "([^"]*)"$/ do |input|
85
109
  type(input)
86
110
  end
87
111
 
112
+ When /^I close the stdin stream$/ do
113
+ close_input
114
+ end
115
+
116
+ When /^I pipe in the file "([^"]*)"$/ do |file|
117
+ pipe_in_file(file)
118
+
119
+ close_input
120
+ end
121
+
88
122
  When /^I wait for (?:output|stdout) to contain "([^"]*)"$/ do |expected|
89
123
  Timeout::timeout(exit_timeout) do
90
124
  loop do
@@ -269,6 +303,14 @@ Then /^a file named "([^"]*)" should not exist$/ do |file|
269
303
  check_file_presence([file], false)
270
304
  end
271
305
 
306
+ Then /^a file matching %r<(.*?)> should exist$/ do |regex|
307
+ check_file_presence([ Regexp.new( regex ) ], true )
308
+ end
309
+
310
+ Then /^a file matching %r<(.*?)> should not exist$/ do |regex|
311
+ check_file_presence([ Regexp.new( regex ) ], false )
312
+ end
313
+
272
314
  Then /^a (\d+) byte file named "([^"]*)" should exist$/ do |file_size, file_name|
273
315
  check_file_size([[file_name, file_size.to_i]])
274
316
  end
@@ -312,3 +354,7 @@ end
312
354
  Then /^the file "([^"]*)" should not match \/([^\/]*)\/$/ do |file, partial_content|
313
355
  check_file_content(file, /#{partial_content}/, false)
314
356
  end
357
+
358
+ Then /^the mode of filesystem object "([^"]*)" should match "([^"]*)"$/ do |name, mode|
359
+ mod?(mode, name)
360
+ end
@@ -12,7 +12,7 @@ After do
12
12
  end
13
13
 
14
14
  Before('~@no-clobber') do
15
- FileUtils.rm_rf(current_dir)
15
+ clean_current_dir
16
16
  end
17
17
 
18
18
  Before('@puts') do
@@ -30,7 +30,7 @@ module Aruba
30
30
  @kernel = FakeKernel.new
31
31
  end
32
32
 
33
- def run!(&block)
33
+ def run!
34
34
  raise "You need to call Aruba::InProcess.main_class = YourMainClass" unless @@main_class
35
35
  @@main_class.new(@argv, @stdin, @stdout, @stderr, @kernel).execute!
36
36
  yield self if block_given?
@@ -0,0 +1,5 @@
1
+ RSpec::Matchers.define :include_regexp do |expected|
2
+ match do |actual|
3
+ ! actual.grep(expected).empty?
4
+ end
5
+ end
@@ -31,7 +31,22 @@ describe Aruba::Api do
31
31
 
32
32
  describe 'current_dir' do
33
33
  it "should return the current dir as 'tmp/aruba'" do
34
- @aruba.current_dir.should match(/^tmp\/aruba$/)
34
+ expect(@aruba.current_dir).to match(/^tmp\/aruba$/)
35
+ end
36
+
37
+ it "can be cleared" do
38
+ write_file( 'test', 'test test test' )
39
+
40
+ in_current_dir do
41
+ expect( File.exist? 'test' ).to be_true
42
+ end
43
+
44
+ clean_current_dir
45
+
46
+ in_current_dir do
47
+ expect( File.exist? 'test' ).to be_false
48
+ end
49
+
35
50
  end
36
51
  end
37
52
 
@@ -44,7 +59,7 @@ describe Aruba::Api do
44
59
  end
45
60
  it 'should delete directory' do
46
61
  @aruba.remove_dir(@directory_name)
47
- File.exist?(@directory_path).should == false
62
+ expect(File.exist?(@directory_path)).to eq false
48
63
  end
49
64
  end
50
65
  end
@@ -53,8 +68,8 @@ describe Aruba::Api do
53
68
  context 'fixed size' do
54
69
  it "should write a fixed sized file" do
55
70
  @aruba.write_fixed_size_file(@file_name, @file_size)
56
- File.exist?(@file_path).should == true
57
- File.size(@file_path).should == @file_size
71
+ expect(File.exist?(@file_path)).to eq true
72
+ expect(File.size(@file_path)).to eq @file_size
58
73
  end
59
74
 
60
75
  it "should check an existing file size" do
@@ -64,15 +79,70 @@ describe Aruba::Api do
64
79
 
65
80
  it "should check an existing file size and fail" do
66
81
  @aruba.write_fixed_size_file(@file_name, @file_size)
67
- lambda { @aruba.check_file_size([[@file_name, @file_size + 1]]) }.should raise_error
82
+ expect { @aruba.check_file_size([[@file_name, @file_size + 1]]) }.to raise_error
68
83
  end
69
84
  end
70
85
  context 'existing' do
71
86
  before(:each) { File.open(@file_path, 'w') { |f| f << "" } }
72
87
  it "should delete file" do
73
88
  @aruba.remove_file(@file_name)
74
- File.exist?(@file_path).should == false
89
+ expect(File.exist?(@file_path)).to eq false
90
+ end
91
+
92
+ it "should change a file's mode" do
93
+ @aruba.chmod(0644, @file_name)
94
+ result = sprintf( "%o" , File::Stat.new(@file_path).mode )[-4,4]
95
+ expect(result).to eq('0644')
96
+
97
+ @aruba.chmod(0655, @file_name)
98
+ result = sprintf( "%o" , File::Stat.new(@file_path).mode )[-4,4]
99
+ expect(result).to eq('0655')
100
+
101
+ @aruba.chmod("0655", @file_name)
102
+ result = sprintf( "%o" , File::Stat.new(@file_path).mode )[-4,4]
103
+ expect(result).to eq('0655')
104
+ end
105
+
106
+ it "should check the mode of a file" do
107
+ @aruba.chmod(0666, @file_name)
108
+ expect(@aruba.mod?(0666, @file_name) ).to eq(true)
109
+ end
110
+
111
+ it "should check existence using plain match" do
112
+ file_name = 'nested/dir/hello_world.txt'
113
+ file_path = File.join(@aruba.current_dir, file_name)
114
+
115
+ FileUtils.mkdir_p File.dirname( file_path )
116
+ File.open(file_path, 'w') { |f| f << "" }
117
+
118
+ @aruba.check_file_presence( [ file_name ], true )
119
+ @aruba.check_file_presence( [ 'asdf' ] , false )
120
+ end
121
+
122
+ it "should check existence using regex" do
123
+ file_name = 'nested/dir/hello_world.txt'
124
+ file_path = File.join(@aruba.current_dir, file_name)
125
+
126
+ FileUtils.mkdir_p File.dirname( file_path )
127
+ File.open(file_path, 'w') { |f| f << "" }
128
+
129
+ @aruba.check_file_presence([ /test123/ ], false )
130
+ @aruba.check_file_presence([ /hello_world.txt$/ ], true )
131
+ @aruba.check_file_presence([ /dir/ ], true )
132
+ @aruba.check_file_presence([ %r{nested/.+/} ], true )
133
+ end
134
+
135
+ it "is no problem to mix both" do
136
+ file_name = 'nested/dir/hello_world.txt'
137
+ file_path = File.join(@aruba.current_dir, file_name)
138
+
139
+ FileUtils.mkdir_p File.dirname( file_path )
140
+ File.open(file_path, 'w') { |f| f << "" }
141
+
142
+ @aruba.check_file_presence([ file_name, /nested/ ], true )
143
+ @aruba.check_file_presence([ /test123/, 'asdf' ], false )
75
144
  end
145
+
76
146
  end
77
147
  end
78
148
 
@@ -81,19 +151,19 @@ describe Aruba::Api do
81
151
  after(:each){@aruba.stop_processes!}
82
152
  context 'enabled' do
83
153
  it "should announce to stdout exactly once" do
84
- @aruba.should_receive(:announce_or_puts).once
154
+ expect(@aruba).to receive(:announce_or_puts).once
85
155
  @aruba.set_tag(:announce_stdout, true)
86
156
  @aruba.run_simple('echo "hello world"', false)
87
- @aruba.all_output.should match(/hello world/)
157
+ expect(@aruba.all_output).to match(/hello world/)
88
158
  end
89
159
  end
90
160
 
91
161
  context 'disabled' do
92
162
  it "should not announce to stdout" do
93
- @aruba.should_not_receive(:announce_or_puts)
163
+ expect(@aruba).not_to receive(:announce_or_puts)
94
164
  @aruba.set_tag(:announce_stdout, false)
95
165
  @aruba.run_simple('echo "hello world"', false)
96
- @aruba.all_output.should match(/hello world/)
166
+ expect(@aruba.all_output).to match(/hello world/)
97
167
  end
98
168
  end
99
169
  end
@@ -106,7 +176,7 @@ describe Aruba::Api do
106
176
 
107
177
  it "checks the given file's full content against the expectations in the passed block" do
108
178
  @aruba.with_file_content @file_name do |full_content|
109
- full_content.should == "foo bar baz"
179
+ expect(full_content).to eq "foo bar baz"
110
180
  end
111
181
  end
112
182
 
@@ -114,17 +184,17 @@ describe Aruba::Api do
114
184
  it "is successful when the inner expectations match" do
115
185
  expect do
116
186
  @aruba.with_file_content @file_name do |full_content|
117
- full_content.should match /foo/
118
- full_content.should_not match /zoo/
187
+ expect(full_content).to match /foo/
188
+ expect(full_content).not_to match /zoo/
119
189
  end
120
- end . not_to raise_error RSpec::Expectations::ExpectationNotMetError
190
+ end . not_to raise_error
121
191
  end
122
192
 
123
193
  it "raises RSpec::Expectations::ExpectationNotMetError when the inner expectations don't match" do
124
194
  expect do
125
195
  @aruba.with_file_content @file_name do |full_content|
126
- full_content.should match /zoo/
127
- full_content.should_not match /foo/
196
+ expect(full_content).to match /zoo/
197
+ expect(full_content).not_to match /foo/
128
198
  end
129
199
  end . to raise_error RSpec::Expectations::ExpectationNotMetError
130
200
  end
@@ -152,14 +222,47 @@ describe Aruba::Api do
152
222
  it "respond to input" do
153
223
  @aruba.type "Hello"
154
224
  @aruba.type ""
155
- @aruba.all_output.should == "Hello\n"
225
+ expect(@aruba.all_output).to eq "Hello\n"
156
226
  end
157
227
 
158
- it "respond to eot" do
228
+ it "respond to close_input" do
159
229
  @aruba.type "Hello"
160
- @aruba.eot
161
- @aruba.all_output.should == "Hello\n"
230
+ @aruba.close_input
231
+ expect(@aruba.all_output).to eq "Hello\n"
162
232
  end
233
+
234
+ it "pipes data" do
235
+ @aruba.write_file(@file_name, "Hello\nWorld!")
236
+ @aruba.pipe_in_file(@file_name)
237
+ @aruba.close_input
238
+ expect(@aruba.all_output).to eq "Hello\nWorld!"
239
+ end
240
+ end
241
+
242
+ describe "#run_simple" do
243
+ before(:each){@aruba.run_simple "true"}
244
+ after(:each){@aruba.stop_processes!}
245
+ describe "get_process" do
246
+ it "returns a process" do
247
+ expect(@aruba.get_process("true")).not_to be(nil)
248
+ end
249
+
250
+ it "raises a descriptive exception" do
251
+ expect do
252
+ expect(@aruba.get_process("false")).not_to be(nil)
253
+ end.to raise_error(ArgumentError, "No process named 'false' has been started")
254
+ end
255
+ end
256
+ end
257
+
258
+ describe "#run_simple" do
259
+ after(:each){@aruba.stop_processes!}
260
+ it "runs with different env" do
261
+ @aruba.set_env 'LONG_LONG_ENV_VARIABLE', 'true'
262
+ @aruba.run "env"
263
+ expect(@aruba.all_output).to include("LONG_LONG_ENV_VARIABLE")
264
+ end
265
+
163
266
  end
164
267
 
165
268
  end # Aruba::Api
@@ -5,14 +5,14 @@ describe Aruba::Hooks do
5
5
  hook_was_run = false
6
6
  subject.append :hook_label, lambda { hook_was_run = true }
7
7
  subject.execute :hook_label, self
8
- hook_was_run.should be_true
8
+ expect(hook_was_run).to be_true
9
9
  end
10
10
 
11
11
  it 'executes a stored hook that takes multiple arguments' do
12
12
  hook_values = []
13
13
  subject.append :hook_label, lambda { |a,b,c| hook_values = [a,b,c] }
14
14
  subject.execute :hook_label, self, 1, 2, 3
15
- hook_values.should == [1,2,3]
15
+ expect(hook_values).to eq [1,2,3]
16
16
  end
17
17
 
18
18
  end
@@ -17,8 +17,8 @@ describe "Aruba JRuby Startup Helper" do
17
17
  with_constants :ENV => @fake_env, :RUBY_PLATFORM => 'x86_64-chocolate' do
18
18
  load 'aruba/jruby.rb'
19
19
  Aruba.config.hooks.execute :before_cmd, self
20
- ENV['JRUBY_OPTS'].should == "--1.9"
21
- ENV['JAVA_OPTS'].should == "-Xdebug"
20
+ expect(ENV['JRUBY_OPTS']).to eq "--1.9"
21
+ expect(ENV['JAVA_OPTS']).to eq "-Xdebug"
22
22
  end
23
23
  end
24
24
 
@@ -27,8 +27,8 @@ describe "Aruba JRuby Startup Helper" do
27
27
  RbConfig::CONFIG.stub(:[] => 'solaris')
28
28
  load 'aruba/jruby.rb'
29
29
  Aruba.config.hooks.execute :before_cmd, self
30
- ENV['JRUBY_OPTS'].should == "-X-C --1.9"
31
- ENV['JAVA_OPTS'].should == "-d32 -Xdebug"
32
- end
30
+ expect(ENV['JRUBY_OPTS']).to eq "-X-C --1.9"
31
+ expect(ENV['JAVA_OPTS']).to eq "-d32 -Xdebug"
32
+ end
33
33
  end
34
34
  end
@@ -9,12 +9,12 @@ module Aruba
9
9
  before { process.run! }
10
10
 
11
11
  it "returns the stdout" do
12
- process.stdout.should == "yo\n"
12
+ expect(process.stdout).to eq "yo\n"
13
13
  end
14
14
 
15
15
  it "returns all the stdout, every time you call it" do
16
- process.stdout.should == "yo\n"
17
- process.stdout.should == "yo\n"
16
+ expect(process.stdout).to eq "yo\n"
17
+ expect(process.stdout).to eq "yo\n"
18
18
  end
19
19
 
20
20
  end
@@ -23,8 +23,10 @@ module Aruba
23
23
  before { process.run! }
24
24
 
25
25
  it "sends any output to the reader" do
26
- reader = stub.as_null_object
27
- reader.should_receive(:stdout).with("yo\n")
26
+ reader = double( 'null_object' )
27
+ allow( reader ).to receive( :stderr )
28
+ expect( reader ).to receive( :stdout ).with("yo\n")
29
+
28
30
  process.stop(reader)
29
31
  end
30
32
  end
@@ -34,7 +36,7 @@ module Aruba
34
36
  let(:process_failure) { SpawnProcess.new('does_not_exists', 1, 1) }
35
37
 
36
38
  it "raises a Aruba::LaunchError" do
37
- lambda{process_failure.run!}.should raise_error(::Aruba::LaunchError)
39
+ expect{process_failure.run!}.to raise_error(::Aruba::LaunchError)
38
40
  end
39
41
  end
40
42
  end
@@ -40,4 +40,11 @@ RSpec.configure do |config|
40
40
  config.run_all_when_everything_filtered = true
41
41
  config.treat_symbols_as_metadata_keys_with_true_values = true
42
42
  config.include(ManipulatesConstants)
43
+ config.expect_with :rspec do |c|
44
+ c.syntax = :expect
45
+ end
46
+
47
+ config.before( :each ) {
48
+ clean_current_dir
49
+ }
43
50
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aruba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
5
- prerelease:
4
+ version: 0.5.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Aslak Hellesøy
@@ -12,120 +11,120 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2013-05-17 00:00:00.000000000 Z
14
+ date: 2014-01-10 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: cucumber
19
18
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
19
  requirements:
22
- - - ! '>='
20
+ - - '>='
23
21
  - !ruby/object:Gem::Version
24
22
  version: 1.1.1
25
23
  type: :runtime
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
- - - ! '>='
27
+ - - '>='
31
28
  - !ruby/object:Gem::Version
32
29
  version: 1.1.1
33
30
  - !ruby/object:Gem::Dependency
34
31
  name: childprocess
35
32
  requirement: !ruby/object:Gem::Requirement
36
- none: false
37
33
  requirements:
38
- - - ! '>='
34
+ - - '>='
39
35
  - !ruby/object:Gem::Version
40
36
  version: 0.3.6
41
37
  type: :runtime
42
38
  prerelease: false
43
39
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
40
  requirements:
46
- - - ! '>='
41
+ - - '>='
47
42
  - !ruby/object:Gem::Version
48
43
  version: 0.3.6
49
44
  - !ruby/object:Gem::Dependency
50
45
  name: rspec-expectations
51
46
  requirement: !ruby/object:Gem::Requirement
52
- none: false
53
47
  requirements:
54
- - - ! '>='
48
+ - - '>='
55
49
  - !ruby/object:Gem::Version
56
50
  version: 2.7.0
57
51
  type: :runtime
58
52
  prerelease: false
59
53
  version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
54
  requirements:
62
- - - ! '>='
55
+ - - '>='
63
56
  - !ruby/object:Gem::Version
64
57
  version: 2.7.0
65
58
  - !ruby/object:Gem::Dependency
66
59
  name: bcat
67
60
  requirement: !ruby/object:Gem::Requirement
68
- none: false
69
61
  requirements:
70
- - - ! '>='
62
+ - - '>='
71
63
  - !ruby/object:Gem::Version
72
64
  version: 0.6.1
73
65
  type: :development
74
66
  prerelease: false
75
67
  version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
68
  requirements:
78
- - - ! '>='
69
+ - - '>='
79
70
  - !ruby/object:Gem::Version
80
71
  version: 0.6.1
81
72
  - !ruby/object:Gem::Dependency
82
73
  name: kramdown
83
74
  requirement: !ruby/object:Gem::Requirement
84
- none: false
85
75
  requirements:
86
- - - ! '>='
76
+ - - '>='
87
77
  - !ruby/object:Gem::Version
88
78
  version: '0.14'
89
79
  type: :development
90
80
  prerelease: false
91
81
  version_requirements: !ruby/object:Gem::Requirement
92
- none: false
93
82
  requirements:
94
- - - ! '>='
83
+ - - '>='
95
84
  - !ruby/object:Gem::Version
96
85
  version: '0.14'
97
86
  - !ruby/object:Gem::Dependency
98
87
  name: rake
99
88
  requirement: !ruby/object:Gem::Requirement
100
- none: false
101
89
  requirements:
102
- - - ! '>='
90
+ - - '>='
103
91
  - !ruby/object:Gem::Version
104
92
  version: 0.9.2
105
93
  type: :development
106
94
  prerelease: false
107
95
  version_requirements: !ruby/object:Gem::Requirement
108
- none: false
109
96
  requirements:
110
- - - ! '>='
97
+ - - '>='
111
98
  - !ruby/object:Gem::Version
112
99
  version: 0.9.2
113
100
  - !ruby/object:Gem::Dependency
114
101
  name: rspec
115
102
  requirement: !ruby/object:Gem::Requirement
116
- none: false
117
103
  requirements:
118
- - - ! '>='
104
+ - - '>='
119
105
  - !ruby/object:Gem::Version
120
- version: 2.7.0
106
+ version: 2.11.0
121
107
  type: :development
122
108
  prerelease: false
123
109
  version_requirements: !ruby/object:Gem::Requirement
124
- none: false
125
110
  requirements:
126
- - - ! '>='
111
+ - - '>='
127
112
  - !ruby/object:Gem::Version
128
- version: 2.7.0
113
+ version: 2.11.0
114
+ - !ruby/object:Gem::Dependency
115
+ name: fuubar
116
+ requirement: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: 1.1.1
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: 1.1.1
129
128
  description: CLI Steps for Cucumber, hand-crafted for you in Aruba
130
129
  email: cukes@googlegroups.com
131
130
  executables: []
@@ -146,6 +145,7 @@ files:
146
145
  - config/.gitignore
147
146
  - cucumber.yml
148
147
  - features/before_cmd_hooks.feature
148
+ - features/command_environment_variables.feature
149
149
  - features/custom_ruby_process.feature
150
150
  - features/exit_statuses.feature
151
151
  - features/file_system_commands.feature
@@ -166,6 +166,7 @@ files:
166
166
  - lib/aruba/errors.rb
167
167
  - lib/aruba/in_process.rb
168
168
  - lib/aruba/jruby.rb
169
+ - lib/aruba/matchers/rspec_matcher_include_regexp.rb
169
170
  - lib/aruba/reporting.rb
170
171
  - lib/aruba/spawn_process.rb
171
172
  - spec/aruba/api_spec.rb
@@ -187,34 +188,28 @@ files:
187
188
  - templates/js/jquery-1.6.1.min.js
188
189
  - templates/main.erb
189
190
  homepage: http://github.com/cucumber/aruba
190
- licenses: []
191
+ licenses:
192
+ - MIT
193
+ metadata: {}
191
194
  post_install_message:
192
195
  rdoc_options:
193
196
  - --charset=UTF-8
194
197
  require_paths:
195
198
  - lib
196
199
  required_ruby_version: !ruby/object:Gem::Requirement
197
- none: false
198
200
  requirements:
199
- - - ! '>='
201
+ - - '>='
200
202
  - !ruby/object:Gem::Version
201
203
  version: '0'
202
- segments:
203
- - 0
204
- hash: 4547606792464091190
205
204
  required_rubygems_version: !ruby/object:Gem::Requirement
206
- none: false
207
205
  requirements:
208
- - - ! '>='
206
+ - - '>='
209
207
  - !ruby/object:Gem::Version
210
208
  version: '0'
211
- segments:
212
- - 0
213
- hash: 4547606792464091190
214
209
  requirements: []
215
210
  rubyforge_project:
216
- rubygems_version: 1.8.23
211
+ rubygems_version: 2.0.14
217
212
  signing_key:
218
- specification_version: 3
219
- summary: aruba-0.5.3
213
+ specification_version: 4
214
+ summary: aruba-0.5.4
220
215
  test_files: []