minitest-capistrano 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,4 +1,11 @@
1
1
  language: ruby
2
+
3
+ matrix:
4
+ allow_failures:
5
+ - rvm: ruby-head
6
+ - rvm: rbx-19mode
7
+ - rvm: rbx-18mode
8
+
2
9
  rvm:
3
10
  - 1.9.3
4
11
  - 1.9.2
@@ -8,4 +15,5 @@ rvm:
8
15
  - ree
9
16
  - rbx-18mode
10
17
  - jruby-18mode
18
+ - ruby-head
11
19
  - jruby-head
data/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
- ## 0.1.3.dev (unreleased)
1
+ ## 0.1.4.dev (unreleased)
2
+
3
+
4
+ ## 0.1.3 (August 23, 2012)
5
+
6
+ ### New features
7
+
8
+ * Add assertions and expectations for #stream. ([@fnichol][])
2
9
 
3
10
 
4
11
  ## 0.1.2 (July 12, 2012)
data/README.md CHANGED
@@ -20,10 +20,13 @@ Or install it yourself as:
20
20
 
21
21
  TODO: Write usage instructions here
22
22
 
23
- ## Contributing
23
+ ## <a name="development"></a> Development
24
24
 
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Added some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
25
+ * Source hosted at [GitHub][repo]
26
+ * Report issues/Questions/Feature requests on [GitHub Issues][issues]
27
+
28
+ Pull requests are very welcome! Make sure your patches are well tested.
29
+ Ideally create a topic branch for every separate change you make.
30
+
31
+ [repo]: https://github.com/fnichol/minitest-capistrano
32
+ [issues]: https://github.com/fnichol/minitest-capistrano/issues
@@ -62,6 +62,24 @@ module MiniTest
62
62
  assert_nil configuration.captures[cmd], msg
63
63
  end
64
64
 
65
+ ##
66
+ # Fails unless +configuration+ has streamed +cmd+.
67
+ #
68
+ # assert_have_streamed "tail -f /hi", configuration
69
+
70
+ def assert_have_streamed(cmd, configuration, msg = nil)
71
+ msg ||= "Expected configuration to stream #{cmd}, but did not"
72
+ refute_nil configuration.streams[cmd], msg
73
+ end
74
+
75
+ ##
76
+ # Fails if +configuration+ has streamed +cmd+.
77
+
78
+ def refute_have_streamed(cmd, configuration, msg = nil)
79
+ msg ||= "Expected configuration to not stream #{cmd}, but did"
80
+ assert_nil configuration.streams[cmd], msg
81
+ end
82
+
65
83
  ##
66
84
  # Fails unless +configuration+ has put +cmd+.
67
85
  #
@@ -50,6 +50,19 @@ module MiniTest::Capistrano
50
50
  @captures_responses ||= {}
51
51
  end
52
52
 
53
+ def stream(command, options={})
54
+ streams[command] = {:options => options}
55
+ streams_responses[command]
56
+ end
57
+
58
+ def streams
59
+ @streams ||= {}
60
+ end
61
+
62
+ def streams_responses
63
+ @streams_responses ||= {}
64
+ end
65
+
53
66
  def find_callback(on, task)
54
67
  task = find_task(task) if task.kind_of?(String)
55
68
 
@@ -1,5 +1,5 @@
1
1
  module MiniTest
2
2
  module Capistrano
3
- VERSION = "0.1.2" # :nodoc:
3
+ VERSION = "0.1.3" # :nodoc:
4
4
  end
5
5
  end
@@ -59,6 +59,24 @@ module MiniTest
59
59
 
60
60
  infect_an_assertion :refute_have_captured, :wont_have_captured
61
61
 
62
+ ##
63
+ # See MiniTest::Assertions#assert_have_streamd
64
+ #
65
+ # config.must_have_streamed cmd
66
+ #
67
+ # :method: must_have_streamed
68
+
69
+ infect_an_assertion :assert_have_streamed, :must_have_streamed
70
+
71
+ ##
72
+ # See MiniTest::Assertions#refute_have_streamed
73
+ #
74
+ # config.wont_have_streamed cmd
75
+ #
76
+ # :method: wont_have_streamed
77
+
78
+ infect_an_assertion :refute_have_streamed, :wont_have_streamed
79
+
62
80
  ##
63
81
  # See MiniTest::Assertions#assert_have_put
64
82
  #
@@ -38,6 +38,15 @@ describe MiniTest::Assertions do
38
38
  subject.refute_have_captured "cat /tmp/anything", @config
39
39
  end
40
40
 
41
+ it "assert a command has been streamed" do
42
+ @config.stream "tail -f /tmp/surprise.txt"
43
+ subject.assert_have_streamed "tail -f /tmp/surprise.txt", @config
44
+ end
45
+
46
+ it "refutes a command has been streamed" do
47
+ subject.refute_have_streamed "tail -f /tmp/anything", @config
48
+ end
49
+
41
50
  it "assert a file has been put" do
42
51
  @config.put "#!/usr/bin/env ruby", "/tmp/server.rb"
43
52
  subject.assert_have_put "/tmp/server.rb", @config, "#!/usr/bin/env ruby"
@@ -83,6 +83,29 @@ describe MiniTest::Capistrano::ConfigurationExtension do
83
83
  end
84
84
  end
85
85
 
86
+ describe "#stream" do
87
+ it "starts with an empty hash" do
88
+ @config.streams.must_be_empty
89
+ end
90
+
91
+ it "adds an entry to the hash when called" do
92
+ @config.streams.must_be_empty
93
+ @config.stream "tail -f /tmp/output"
94
+ @config.streams.wont_be_empty
95
+ @config.streams["tail -f /tmp/output"].wont_be_nil
96
+ end
97
+
98
+ it "retuns a nil response if one is not pre-set" do
99
+ @config.stream("cat /nope").must_be_nil
100
+ end
101
+
102
+ it "returns a response if one is pre-set" do
103
+ @config.streams_responses["tail -f /tmp/file"] = "blah bleh"
104
+
105
+ @config.stream("tail -f /tmp/file").must_equal "blah bleh"
106
+ end
107
+ end
108
+
86
109
  describe "#find_callback" do
87
110
  it "returns an empty array when no callbacks are found" do
88
111
  @config.find_callback(:before, @config.find_task("startup")).must_equal []
@@ -37,6 +37,16 @@ describe MiniTest::Expectations do
37
37
  @config.wont_have_captured "yabba dabba"
38
38
  end
39
39
 
40
+ it "needs to verify a command has streamed" do
41
+ @config.stream "boop"
42
+ @config.must_have_streamed "boop"
43
+ end
44
+
45
+ it "needs to verify a command has not been streamed" do
46
+ @config.stream "wot?"
47
+ @config.wont_have_streamed "boop"
48
+ end
49
+
40
50
  it "needs to verify a file has been put" do
41
51
  @config.put "thedata", "thepath"
42
52
  @config.must_have_put "thepath", "thedata"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-capistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-12 00:00:00.000000000 Z
12
+ date: 2012-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &70183344234920 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70183344234920
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: capistrano
27
- requirement: &70183344234420 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '2.9'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70183344234420
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.9'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: guard-minitest
38
- requirement: &70183344233880 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,7 +53,12 @@ dependencies:
43
53
  version: 0.5.0
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70183344233880
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.5.0
47
62
  description: MiniTest assertions and expectations for testing Capistrano recipes
48
63
  email:
49
64
  - fnichol@nichol.ca
@@ -85,15 +100,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
100
  - - ! '>='
86
101
  - !ruby/object:Gem::Version
87
102
  version: '0'
103
+ segments:
104
+ - 0
105
+ hash: -4475172573281583995
88
106
  required_rubygems_version: !ruby/object:Gem::Requirement
89
107
  none: false
90
108
  requirements:
91
109
  - - ! '>='
92
110
  - !ruby/object:Gem::Version
93
111
  version: '0'
112
+ segments:
113
+ - 0
114
+ hash: -4475172573281583995
94
115
  requirements: []
95
116
  rubyforge_project:
96
- rubygems_version: 1.8.15
117
+ rubygems_version: 1.8.24
97
118
  signing_key:
98
119
  specification_version: 3
99
120
  summary: MiniTest assertions and expectations for testing Capistrano recipes