my 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -8,10 +8,9 @@ features/aliases.feature
8
8
  features/files.feature
9
9
  features/folder.feature
10
10
  features/questions.feature
11
- features/sinatra.feature
12
11
  features/support/env.rb
13
12
  features/support/hooks.rb
14
- features/support/interactive_steps.rb
13
+ features/support/aruba_interactive.rb
15
14
  features/support/steps.rb
16
15
  features/usage.feature
17
16
  lib/my.rb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -4,6 +4,7 @@ As a My script writer
4
4
  I want to nest tasks inside of questions
5
5
  So I can respond dynamically to the user's needs
6
6
 
7
+ @aruba_interactive
7
8
  Scenario: Nesting questions
8
9
  Given a file named "yes.template" with:
9
10
  """
@@ -24,6 +25,5 @@ And a file named "script.rb" with:
24
25
  When I run "../../bin/my script.rb" interactively
25
26
  And I type "y"
26
27
  And I type "y"
27
- And the program completes
28
28
  Then the file "foo.txt" should contain "The user picked yes"
29
29
  Then the file "bar.txt" should contain "The user picked yes"
@@ -4,6 +4,7 @@ As a user of the My gem
4
4
  I want to optionally run tasks
5
5
  So that I can be explicit
6
6
 
7
+ @aruba_interactive
7
8
  Scenario: Accepting a prompt
8
9
  Given a file named "yes.txt.template" with:
9
10
  """
@@ -20,9 +21,9 @@ When I run "../../bin/my script.rb" interactively
20
21
  Then the program should prompt "Would you like to add a file? [y/N]"
21
22
 
22
23
  When I type "y"
23
- And the program completes
24
24
  Then the file "yes.txt" should contain "The user picked yes"
25
25
 
26
+ @aruba_interactive
26
27
  Scenario: Declining a prompt
27
28
  Given a file named "no.txt.template" with:
28
29
  """
@@ -39,5 +40,4 @@ When I run "../../bin/my script.rb" interactively
39
40
  Then the program should prompt "Would you like to add a file? [y/N]"
40
41
 
41
42
  When I type "n"
42
- And the program completes
43
43
  Then the file "no.txt" should contain "The user picked no"
@@ -0,0 +1,42 @@
1
+ require 'open3'
2
+
3
+ Before '@aruba_interactive' do
4
+ @stdout_stream = nil
5
+ @stderr_stream = nil
6
+ @stdout = ""
7
+ @stdin = ""
8
+
9
+ @stdout_listener = Thread.new do
10
+ Thread.stop
11
+ loop do
12
+ @stdout << @stdout_stream.readpartial(1)
13
+ end
14
+ end
15
+
16
+ @stderr_listener = Thread.new do
17
+ Thread.stop
18
+ loop do
19
+ @stderr << @stderr_stream.readpartial(1)
20
+ end
21
+ end
22
+ end
23
+
24
+ When /^I run "([^\"]*)" interactively$/ do |arg1|
25
+ old_dir = Dir.pwd
26
+ Dir.chdir("tmp/aruba") unless Dir.pwd.split('/')[-1] == "aruba"
27
+ @stdin_stream, @stdout_stream, @stderr_stream = Open3.popen3(arg1)
28
+ Dir.chdir(old_dir)
29
+ sleep 1
30
+ @stdout_listener.run
31
+ @stderr_listener.run
32
+ end
33
+
34
+ When /^I type "([^\"]*)"$/ do |arg1|
35
+ @stdin_stream.puts arg1
36
+ sleep 0.5
37
+ end
38
+
39
+ Then /^the program should prompt "([^\"]*)"$/ do |arg1|
40
+ sleep 0.5
41
+ @stdout.should include(arg1)
42
+ end
@@ -1,6 +1,3 @@
1
- Then /^I debug$/ do
2
- end
3
-
4
1
  Given /^there are no scripts installed$/ do
5
2
  File.open(My::Config.scripts,"w"){|f|f.write({}.to_yaml)}
6
3
  end
@@ -20,3 +17,7 @@ Then /^the following folders should (not )?exist:$/ do |negation,table|
20
17
  File.exist?(folder).should == !negation
21
18
  end
22
19
  end
20
+
21
+ When /^I wait (\d+) seconds?$/ do |arg1|
22
+ sleep arg1.to_f
23
+ end
@@ -23,7 +23,7 @@ module My
23
23
  #
24
24
  # My::Config.environment = 'test'
25
25
  # My::Config.scripts
26
- # # => "/home/gisikw/.rvm/gems/ruby-1.8.7-p249/gems/my-0.3.0/test.yml"
26
+ # # => "/home/gisikw/.rvm/gems/ruby-1.8.7-p249/gems/my-0.3.1/test.yml"
27
27
  def scripts
28
28
  case self.environment||='production'
29
29
  when /^production$/
@@ -48,7 +48,7 @@ module My
48
48
  #
49
49
  # <em>produces (for example):</em>
50
50
  #
51
- # My v.0.3.0
51
+ # My v.0.3.1
52
52
  # USAGE: my [NAME|URL]
53
53
  #
54
54
  # Additional commands:
data/my.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{my}
5
- s.version = "0.3.0"
5
+ s.version = "0.3.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Kevin W. Gisi"]
9
- s.date = %q{2010-06-07}
9
+ s.date = %q{2010-06-08}
10
10
  s.default_executable = %q{my}
11
11
  s.description = %q{Ruby template and configuration manager}
12
12
  s.email = %q{kevin@kevingisi.com}
13
13
  s.executables = ["my"]
14
14
  s.extra_rdoc_files = ["LICENSE", "README.rdoc", "bin/my", "lib/my.rb", "lib/my/config.rb", "lib/my/runner.rb", "lib/my/script.rb"]
15
- s.files = ["LICENSE", "README.rdoc", "Rakefile", "VERSION", "bin/my", "features/advanced.feature", "features/aliases.feature", "features/files.feature", "features/folder.feature", "features/questions.feature", "features/sinatra.feature", "features/support/env.rb", "features/support/hooks.rb", "features/support/interactive_steps.rb", "features/support/steps.rb", "features/usage.feature", "lib/my.rb", "lib/my/config.rb", "lib/my/runner.rb", "lib/my/script.rb", "spec/config_spec.rb", "spec/runner_spec.rb", "spec/script_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "Manifest", "my.gemspec"]
15
+ s.files = ["LICENSE", "README.rdoc", "Rakefile", "VERSION", "bin/my", "features/advanced.feature", "features/aliases.feature", "features/files.feature", "features/folder.feature", "features/questions.feature", "features/support/env.rb", "features/support/hooks.rb", "features/support/aruba_interactive.rb", "features/support/steps.rb", "features/usage.feature", "lib/my.rb", "lib/my/config.rb", "lib/my/runner.rb", "lib/my/script.rb", "spec/config_spec.rb", "spec/runner_spec.rb", "spec/script_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "Manifest", "my.gemspec"]
16
16
  s.homepage = %q{http://gisikw.github.com/my}
17
17
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "My", "--main", "README.rdoc"]
18
18
  s.require_paths = ["lib"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kevin W. Gisi
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-07 00:00:00 -05:00
17
+ date: 2010-06-08 00:00:00 -05:00
18
18
  default_executable: my
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -84,10 +84,9 @@ files:
84
84
  - features/files.feature
85
85
  - features/folder.feature
86
86
  - features/questions.feature
87
- - features/sinatra.feature
88
87
  - features/support/env.rb
89
88
  - features/support/hooks.rb
90
- - features/support/interactive_steps.rb
89
+ - features/support/aruba_interactive.rb
91
90
  - features/support/steps.rb
92
91
  - features/usage.feature
93
92
  - lib/my.rb
@@ -1,72 +0,0 @@
1
- Feature: Ensuring README examples
2
-
3
- As a My project maintainer
4
- I want to ensure my Sinatra example works
5
- So I that I avoid humiliation
6
-
7
- Background:
8
- Given a file named "script.rb" with:
9
- """
10
- # Sinatra My Script
11
-
12
- file "app.rb" => "http://pastie.org/944315.txt"
13
- file "config.ru" => "http://pastie.org/994640.txt"
14
-
15
- ask "Will you be using external views?"
16
- yes do
17
- folder "views"
18
- file "views/index.html" => "http://pastie.org/944311.txt"
19
- end
20
-
21
- ask "Will you be using an external stylesheet?"
22
- yes do
23
- folder "views"
24
- file "views/style.sass" => "http://pastie.org/944313.txt"
25
- end
26
- """
27
-
28
- Scenario: Answering yes and yes
29
- When I run "../../bin/my script.rb" interactively
30
- And I type "y"
31
- And I type "y"
32
- And the program completes
33
- Then the following files should exist:
34
- | app.rb |
35
- | config.ru |
36
- | views/index.html |
37
- | views/style.sass |
38
-
39
- Scenario: Answering yes and no
40
- When I run "../../bin/my script.rb" interactively
41
- And I type "y"
42
- And I type "n"
43
- And the program completes
44
- Then the following files should exist:
45
- | app.rb |
46
- | config.ru |
47
- | views/index.html |
48
- And the following files should not exist:
49
- | views/style.sass |
50
-
51
- Scenario: Answering no and yes
52
- When I run "../../bin/my script.rb" interactively
53
- And I type "n"
54
- And I type "y"
55
- And the program completes
56
- Then the following files should exist:
57
- | app.rb |
58
- | config.ru |
59
- | views/style.sass |
60
- And the following files should not exist:
61
- | views/index.html |
62
-
63
- Scenario: Answering no and no
64
- When I run "../../bin/my script.rb" interactively
65
- And I type "n"
66
- And I type "n"
67
- And the program completes
68
- Then the following files should exist:
69
- | app.rb |
70
- | config.ru |
71
- And the following folders should not exist:
72
- | views |
@@ -1,41 +0,0 @@
1
- require 'open3'
2
-
3
- @interactive_history = []
4
-
5
- def run_interactive_program
6
- old_dir = Dir.pwd
7
- Dir.chdir("tmp/aruba") unless Dir.pwd.split('/')[-1] == "aruba"
8
- @stdin, @stdout, @stderr = Open3.popen3(@interactive_prog)
9
- @interactive_history.each do |input|
10
- @stdin.puts input
11
- end
12
- @output = ""
13
- begin
14
- loop do
15
- Timeout::timeout(1) do
16
- @output << @stdout.readpartial(1)
17
- end
18
- end
19
- rescue Timeout::Error
20
- rescue EOFError
21
- end
22
- Dir.chdir(old_dir)
23
- end
24
-
25
- When /^I run "([^\"]*)" interactively$/ do |arg1|
26
- @interactive_prog = arg1
27
- @interactive_history = []
28
- end
29
-
30
- Then /^the program should prompt "([^\"]*)"$/ do |arg1|
31
- run_interactive_program
32
- @output.should include(arg1)
33
- end
34
-
35
- When /^I type "([^\"]*)"/ do |arg1|
36
- @interactive_history << arg1
37
- end
38
-
39
- When /^the program completes$/ do
40
- run_interactive_program
41
- end