haiti 0.0.2 → 0.0.3

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/Readme.md CHANGED
@@ -20,6 +20,13 @@ To run tests
20
20
  Todo
21
21
  ====
22
22
 
23
+ **These would actually be useful right now**
24
+
25
+ * All existing defs can take single or double quotes
26
+ * Failures on stdout also display stderr
27
+ * step def for does not include
28
+
29
+ **These should just generally be done**
23
30
  * Add tests showing that curlies get interpreted where expected
24
31
  * Add tests proving that bin gets stuck in the path
25
32
  * Add tests for negative assertions (currently if all step defs were empty, this would pass the suite)
data/haiti.gemspec CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |s|
9
9
  s.email = ["josh.cheek@gmail.com"]
10
10
  s.homepage = "https://github.com/JoshCheek/haiti"
11
11
  s.summary = %q{Simple Cucumber steps for command line programs}
12
- s.description = "Aruba provides Cucumber helpers for command line programs, but it's way more sophisticated than I can understand, " \
13
- "so I wind up reinventing that wheel in miniature for a lot of projects. This is just an extraction of that. " \
14
- "It aims to be simple and easy to understand/extend."
12
+ s.description = "Extraction of cucumber helpers for running binaries that I wind up writing ad-hoc for many projects. " \
13
+ "It is minimal which lowers the barrier for entry, making it easy to understand/extend." \
14
+ "If you need something more powerful, there is Aruba."
15
15
  s.license = "WTFPL"
16
16
 
17
17
  s.files = `git ls-files`.split("\n")
@@ -28,30 +28,22 @@ module Haiti
28
28
  end
29
29
 
30
30
  def in_proving_grounds(&block)
31
- Dir.chdir proving_grounds_dir, &block
32
- end
33
-
34
- def proving_grounds_dir
35
- config.proving_grounds_dir
31
+ Dir.chdir config.proving_grounds_dir, &block
36
32
  end
37
33
 
38
34
  def make_proving_grounds
39
- FileUtils.mkdir_p proving_grounds_dir
40
- end
41
-
42
- def bin_dir
43
- config.bin_dir
35
+ FileUtils.mkdir_p config.proving_grounds_dir
44
36
  end
45
37
 
46
38
  def path_to(filename)
47
- in_proving_grounds { File.join proving_grounds_dir, filename }
39
+ in_proving_grounds { File.join config.proving_grounds_dir, filename }
48
40
  end
49
41
 
50
42
  # workaround for Ruby 2.0 bug where passing the new path as the first arg wasn't working
51
43
  # bug report submitted here: http://bugs.ruby-lang.org/issues/8004
52
44
  def with_bin_in_path
53
45
  original_path = ENV['PATH']
54
- ENV['PATH'] = "#{bin_dir}:#{ENV['PATH']}"
46
+ ENV['PATH'] = "#{config.bin_dir}:#{ENV['PATH']}"
55
47
  yield
56
48
  ensure
57
49
  ENV['PATH'] = original_path
@@ -1,12 +1,50 @@
1
- Given('the file "$filename" "$body"') { |filename, body| Haiti::CommandLineHelpers.write_file filename, eval_curlies(body) }
2
- Given('the file "$filename":') { |filename, body| Haiti::CommandLineHelpers.write_file filename, eval_curlies(body) }
3
- Given('the stdin content "$content"') { |content| @stdin_data = eval_curlies(content) }
4
- Given('the stdin content:') { |content| @stdin_data = eval_curlies(content) }
5
- When('I run "$command"') { |command| @last_executed = Haiti::CommandLineHelpers.execute command, @stdin_data }
6
- When("I run '$command'") { |command| @last_executed = Haiti::CommandLineHelpers.execute command, @stdin_data }
7
- Then(/^(stderr|stdout) is:$/) { |stream_name, output| @last_executed.send(stream_name).chomp.should == eval_curlies(output) }
8
- Then(/^(stderr|stdout) is ["'](.*?)["']$/) { |stream_name, output| @last_executed.send(stream_name).chomp.should == eval_curlies(output) }
9
- Then(/^(stderr|stdout) is empty$/) { |stream_name| @last_executed.send(stream_name).should == '' }
10
- Then(/^(stderr|stdout) is not empty$/) { |stream_name| @last_executed.send(stream_name).chomp.should_not be_empty }
11
- Then(/^(stderr|stdout) includes "([^"]*)"$/) { |stream_name, content| @last_executed.send(stream_name).should include eval_curlies(content) }
12
- Then('the exit status is $status') { |status| @last_executed.exitstatus.to_s.should == status }
1
+ define_steps = lambda do |*matchers, &definition|
2
+ matchers.each { |matcher| Given matcher, &definition }
3
+ end
4
+
5
+ define_steps.call(
6
+ 'the file "$filename" "$body"',
7
+ 'the file "$filename":'
8
+ ) { |filename, body| Haiti::CommandLineHelpers.write_file filename, eval_curlies(body) }
9
+
10
+ define_steps.call(
11
+ 'the stdin content "$content"',
12
+ 'the stdin content:'
13
+ ) { |content| @stdin_data = eval_curlies(content) }
14
+
15
+
16
+ define_steps.call(
17
+ 'I run "$command"',
18
+ "I run '$command'",
19
+ ) { |command| @last_executed = Haiti::CommandLineHelpers.execute command, @stdin_data }
20
+
21
+ define_steps.call(
22
+ /^(stderr|stdout) is:$/,
23
+ /^(stderr|stdout) is "(.*?)"$/,
24
+ /^(stderr|stdout) is '(.*?)'$/
25
+ ) { |stream_name, output| @last_executed.send(stream_name).chomp.should == eval_curlies(output) }
26
+
27
+ define_steps.call(
28
+ /^(stderr|stdout) is empty$/
29
+ ) { |stream_name| @last_executed.send(stream_name).should == '' }
30
+
31
+ define_steps.call(
32
+ /^(stderr|stdout) is not empty$/
33
+ ) { |stream_name| @last_executed.send(stream_name).chomp.should_not be_empty }
34
+
35
+ define_steps.call(
36
+ /^(stderr|stdout) includes "(.*?)"$/
37
+ ) { |stream_name, content| @last_executed.send(stream_name).should include eval_curlies(content) }
38
+
39
+ define_steps.call(
40
+ /^(stderr|stdout) includes:$/
41
+ ) { |stream_name, content| @last_executed.send(stream_name).should include eval_curlies(content) }
42
+
43
+ define_steps.call(
44
+ 'the exit status is $status'
45
+ ) { |status| @last_executed.exitstatus.to_s.should == status }
46
+
47
+ define_steps.call(
48
+ /^(stderr|stdout) does not include "(.*?)"$/,
49
+ /^(stderr|stdout) does not include:$/
50
+ ) { |stream_name, content| @last_executed.send(stream_name).should_not include eval_curlies(content) }
data/lib/haiti/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Haiti
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts ARGV.join(' ')
@@ -0,0 +1,14 @@
1
+ Feature: Configuring Haiti
2
+ In order for Haiti to know how to put binaries in your path and where to execute,
3
+ you must configure it.
4
+
5
+ Scenario: bin is in path
6
+ When I run "repeat_this_back_to_me thank you for your patience"
7
+ Then stdout is "thank you for your patience"
8
+
9
+ Scenario: execution happens in the proving grounds
10
+ When I run "pwd"
11
+ Then stdout is "{{Haiti.config.proving_grounds_dir}}"
12
+ Given the file "my_file" "my_body"
13
+ When I run "cat my_file"
14
+ Then stdout is "my_body"
@@ -53,11 +53,54 @@ Feature:
53
53
  Then stderr is not empty
54
54
 
55
55
  # stdout includes
56
- Scenario: stdout includes
56
+ Scenario: stdout includes inline
57
57
  When I run "ruby -e '$stdout.puts %(abc)'"
58
58
  Then stdout includes "b"
59
59
 
60
+ Scenario: stdout includes multiline
61
+ When I run "ruby -e '5.times { |i| $stdout.puts i }'"
62
+ Then stdout includes:
63
+ """
64
+ 2
65
+ 3
66
+ """
67
+
60
68
  # stderr includes
61
- Scenario: stderr includes
69
+ Scenario: stderr includes inline
62
70
  When I run "ruby -e '$stderr.puts %(abc)'"
63
71
  Then stderr includes "b"
72
+
73
+ Scenario: stderr includes multiline
74
+ When I run "ruby -e '5.times { |i| $stderr.puts i }'"
75
+ Then stderr includes:
76
+ """
77
+ 2
78
+ 3
79
+ """
80
+
81
+ # stdout does not include
82
+ Scenario: stdout does not include, inline
83
+ When I run "ruby -e '$stdout.puts %(abc)'"
84
+ Then stdout does not include "z"
85
+
86
+ Scenario: stdout does not include multiline
87
+ When I run "ruby -e '5.times { |i| $stdout.puts i }'"
88
+ Then stdout does not include:
89
+ """
90
+ 3
91
+ 2
92
+ """
93
+
94
+ # stderr does not include
95
+ Scenario: stderr does not include inline
96
+ When I run "ruby -e '$stderr.puts %(abc)'"
97
+ Then stderr does not include "z"
98
+
99
+ Scenario: stderr does not include multiline
100
+ When I run "ruby -e '5.times { |i| $stderr.puts i }'"
101
+ Then stderr does not include:
102
+ """
103
+ 3
104
+ 2
105
+ """
106
+
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: haiti
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Josh Cheek
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-26 00:00:00.000000000 Z
12
+ date: 2013-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,10 +43,9 @@ dependencies:
43
43
  - !ruby/object:Gem::Version
44
44
  version: '2.0'
45
45
  none: false
46
- description: Aruba provides Cucumber helpers for command line programs, but it's way
47
- more sophisticated than I can understand, so I wind up reinventing that wheel in
48
- miniature for a lot of projects. This is just an extraction of that. It aims to
49
- be simple and easy to understand/extend.
46
+ description: Extraction of cucumber helpers for running binaries that I wind up writing
47
+ ad-hoc for many projects. It is minimal which lowers the barrier for entry, making
48
+ it easy to understand/extend.If you need something more powerful, there is Aruba.
50
49
  email:
51
50
  - josh.cheek@gmail.com
52
51
  executables: []
@@ -64,6 +63,8 @@ files:
64
63
  - test/.gitignore
65
64
  - test/Gemfile
66
65
  - test/Gemfile.lock
66
+ - test/bin/repeat_this_back_to_me
67
+ - test/features/config.feature
67
68
  - test/features/given_the_file.feature
68
69
  - test/features/given_the_stdin_content.feature
69
70
  - test/features/support/env.rb
@@ -98,6 +99,8 @@ summary: Simple Cucumber steps for command line programs
98
99
  test_files:
99
100
  - test/Gemfile
100
101
  - test/Gemfile.lock
102
+ - test/bin/repeat_this_back_to_me
103
+ - test/features/config.feature
101
104
  - test/features/given_the_file.feature
102
105
  - test/features/given_the_stdin_content.feature
103
106
  - test/features/support/env.rb