minitest-capistrano 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .rvmrc
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - 1.8.7
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in minitest-capistrano.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'rake', '~> 0.9'
8
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Fletcher Nichol
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Minitest::Capistrano [![Build Status](https://secure.travis-ci.org/fnichol/minitest-capistrano.png)](http://travis-ci.org/fnichol/minitest-capistrano)
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'minitest-capistrano'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install minitest-capistrano
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
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
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs.push "lib"
8
+ t.test_files = FileList['spec/*_spec.rb']
9
+ t.verbose = true
10
+ end
11
+
12
+ task :default => 'test'
@@ -0,0 +1,5 @@
1
+ module MiniTest
2
+ module Capistrano
3
+ VERSION = "0.0.1" # :nodoc:
4
+ end
5
+ end
@@ -0,0 +1,87 @@
1
+ require 'minitest/spec'
2
+
3
+ module MiniTest
4
+ ##
5
+ # MiniTest Assertions. All assertion methods accept a +msg+ which is
6
+ # printed if the assertion fails.
7
+
8
+ module Assertions
9
+ ##
10
+ # Fails unless +configuration+ has run +cmd+.
11
+ #
12
+ # assert_have_run "echo hi", configuration
13
+
14
+ def assert_have_run(cmd, configuration, msg = nil)
15
+ msg = message(msg) { "Expected configuration to run #{cmd}, but did not" }
16
+ refute_nil configuration.runs[cmd], msg
17
+ end
18
+
19
+ ##
20
+ # Fails if +configuration+ has run +cmd+.
21
+
22
+ def refute_have_run(cmd, configuration, msg = nil)
23
+ msg = message(msg) { "Expected configuration to not run #{cmd}, but did" }
24
+ assert_nil configuration.runs[cmd], msg
25
+ end
26
+ end
27
+
28
+ ##
29
+ # It's where you hide your "assertions".
30
+
31
+ module Expectations
32
+ ##
33
+ # See MiniTest::Assertions#assert_have_run
34
+ #
35
+ # config.must_have_run cmd
36
+ #
37
+ # :method: must_have_run
38
+
39
+ infect_an_assertion :assert_have_run, :must_have_run
40
+
41
+ ##
42
+ # See MiniTest::Assertions#refute_have_run
43
+ #
44
+ # config.wont_have_run cmd
45
+ #
46
+ # :method: wont_have_run
47
+
48
+ infect_an_assertion :refute_have_run, :wont_have_run
49
+ end
50
+
51
+ module Capistrano
52
+ ##
53
+ # Patches to Capistrano::Configuration to track invocations. Taken from
54
+ # the awesome capistrano-spec gem
55
+ # (https://github.com/technicalpickles/capistrano-spec)
56
+
57
+ module ConfigurationExtension
58
+ def get(remote_path, path, options={}, &block)
59
+ gets[remote_path] = {:path => path, :options => options, :block => block}
60
+ end
61
+
62
+ def gets
63
+ @gets ||= {}
64
+ end
65
+
66
+ def run(cmd, options={}, &block)
67
+ runs[cmd] = {:options => options, :block => block}
68
+ end
69
+
70
+ def runs
71
+ @runs ||= {}
72
+ end
73
+
74
+ def upload(from, to, options={}, &block)
75
+ uploads[from] = {:to => to, :options => options, :block => block}
76
+ end
77
+
78
+ def uploads
79
+ @uploads ||= {}
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ class Object # :nodoc:
86
+ include MiniTest::Expectations
87
+ end
@@ -0,0 +1,2 @@
1
+ require "minitest/capistrano"
2
+ require "minitest/capistrano/version"
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/minitest/capistrano/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Fletcher Nichol"]
6
+ gem.email = ["fnichol@nichol.ca"]
7
+ gem.description = %q{MiniTest assertions and expectations for testing Capistrano recipes}
8
+ gem.summary = %q{MiniTest assertions and expectations for testing Capistrano recipes}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "minitest-capistrano"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = MiniTest::Capistrano::VERSION
17
+
18
+ gem.add_dependency "minitest", "~> 2.10.0"
19
+ gem.add_dependency "capistrano", "~> 2.9"
20
+ end
@@ -0,0 +1,85 @@
1
+ gem 'minitest'
2
+ require 'minitest/autorun'
3
+ require 'minitest/capistrano'
4
+
5
+ describe MiniTest::Capistrano::ConfigurationExtension do
6
+ before do
7
+ @config = Object.new
8
+ @config.extend(MiniTest::Capistrano::ConfigurationExtension)
9
+ end
10
+
11
+ describe "#get" do
12
+ it "starts with an empty hash" do
13
+ @config.gets.must_be_empty
14
+ end
15
+
16
+ it "adds an entry to the hash when called" do
17
+ @config.gets.must_be_empty
18
+ @config.get "hurdy", "gurdy"
19
+ @config.gets.wont_be_empty
20
+ @config.gets["hurdy"].wont_be_nil
21
+ end
22
+ end
23
+
24
+ describe "#run" do
25
+ it "starts with an empty hash" do
26
+ @config.runs.must_be_empty
27
+ end
28
+
29
+ it "adds an entry to the hash when called" do
30
+ @config.runs.must_be_empty
31
+ @config.run "echo hi"
32
+ @config.runs.wont_be_empty
33
+ @config.runs["echo hi"].wont_be_nil
34
+ end
35
+ end
36
+
37
+ describe "#upload" do
38
+ it "starts with an empty hash" do
39
+ @config.uploads.must_be_empty
40
+ end
41
+
42
+ it "adds an entry to the hash when called" do
43
+ @config.uploads.must_be_empty
44
+ @config.upload "path_to", "nowhere"
45
+ @config.uploads.wont_be_empty
46
+ @config.uploads["path_to"].wont_be_nil
47
+ end
48
+ end
49
+ end
50
+
51
+ describe MiniTest::Assertions do
52
+ before do
53
+ @config = Object.new
54
+ @config.extend(MiniTest::Capistrano::ConfigurationExtension)
55
+ end
56
+
57
+ subject { MiniTest::Unit::TestCase.new 'fake tc' }
58
+
59
+ it "asserts a command has run" do
60
+ @config.run "yabba dabba"
61
+ subject.assert_have_run "yabba dabba", @config
62
+ end
63
+
64
+ it "refutes a command has been run" do
65
+ @config.run "nothing"
66
+ subject.refute_have_run "yoyodyne", @config
67
+ end
68
+ end
69
+
70
+ describe MiniTest::Expectations do
71
+ before do
72
+ @config = Object.new
73
+ @config.extend(MiniTest::Capistrano::ConfigurationExtension)
74
+ end
75
+
76
+ it "needs to verify a command has run" do
77
+ @config.run "yabba dabba"
78
+ @config.must_have_run "yabba dabba"
79
+ end
80
+
81
+ it "needs to verify a command has not been run" do
82
+ @config.run "wot?"
83
+ @config.wont_have_run "yabba dabba"
84
+ end
85
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-capistrano
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Fletcher Nichol
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: &70124627428360 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.10.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70124627428360
25
+ - !ruby/object:Gem::Dependency
26
+ name: capistrano
27
+ requirement: &70124627427100 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '2.9'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70124627427100
36
+ description: MiniTest assertions and expectations for testing Capistrano recipes
37
+ email:
38
+ - fnichol@nichol.ca
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - .travis.yml
45
+ - Gemfile
46
+ - LICENSE
47
+ - README.md
48
+ - Rakefile
49
+ - lib/minitest-capistrano.rb
50
+ - lib/minitest/capistrano.rb
51
+ - lib/minitest/capistrano/version.rb
52
+ - minitest-capistrano.gemspec
53
+ - spec/minitest_capistrano_spec.rb
54
+ homepage: ''
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 1.8.10
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: MiniTest assertions and expectations for testing Capistrano recipes
78
+ test_files:
79
+ - spec/minitest_capistrano_spec.rb