test_officer 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cc5fcac55f3408d2e7e4eff1cfb1c0946b5b5886
4
+ data.tar.gz: 308ebdbe2fd0a43297e7e4657f04e0984fabd4ef
5
+ SHA512:
6
+ metadata.gz: f13ac2aebcae377196b555555546f8bcc070d44b852ad7b1c9c40aef7a912aca40486c6142b01819e8109e7b2b5c039921c539535c2ab98a1dca809513d8adb9
7
+ data.tar.gz: bd0a9d53134edfb7c69bc2233140da54f95b356c6daded0560308b38b81abce0722836d9e51f4ee21d4c70c49454389a730fab0a383661b397f681692ddd4e5d
data/.gitignore ADDED
@@ -0,0 +1,19 @@
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
+ *.swo
19
+ *.swp
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - "2.0.0"
6
+
7
+ script: rspec spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in test_officer.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
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,42 @@
1
+ # TestOfficer
2
+
3
+ [![Build Status](https://secure.travis-ci.org/danbickford007/test_officer.png)](http://travis-ci.org/danbickford007/test_officer?branch=master)
4
+
5
+ This gem will run your specs for you automatically by watching the project for creates, saves and deletes.
6
+ Upon such action, either the saved file is run against rspec or the project is searched for the specified
7
+ spec file. For example, the file user.rb was edited, the file user_spec.rb will then be run. If no file
8
+ can be found to run against, the full test suite will be run.
9
+
10
+ Note: Please ensure all specs are within your spec directory at the root of the project
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ gem 'test_officer'
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install test_officer
25
+
26
+ ## Usage
27
+
28
+ in terminal
29
+
30
+ $ test_officer
31
+
32
+ or
33
+
34
+ $ patrol
35
+
36
+ ## Contributing!
37
+
38
+ 1. Fork it
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/patrol ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'test_officer'
5
+
6
+ ARGV.each do |arg|
7
+ p arg
8
+ end
9
+
10
+ print 'on patrol ... '
11
+ officer = Officer.new
12
+ officer.on_duty
data/bin/test_officer ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'test_officer'
5
+
6
+ ARGV.each do |arg|
7
+ p arg
8
+ end
9
+
10
+ print 'officer on duty ... '
11
+ officer = Officer.new
12
+ officer.on_duty
@@ -0,0 +1,8 @@
1
+ require "test_officer/version"
2
+ require 'fssm'
3
+ require 'rspec'
4
+ require 'colorize'
5
+ require_relative 'test_officer/officer.rb'
6
+
7
+ module TestOfficer
8
+ end
@@ -0,0 +1,45 @@
1
+ class Dispatch
2
+
3
+ SPEC_FILE = /\_{1}s{1}p{1}e{1}c{1}.+/
4
+
5
+ attr_accessor :list
6
+
7
+ def initialize(file, path)
8
+ @file = file.to_s
9
+ @path = path.to_s
10
+ end
11
+
12
+ def run_test
13
+ begin
14
+ found = false
15
+ @list = Dir.glob("**/*").each{|f| found = true if f.to_s == @file and @file =~ SPEC_FILE}
16
+ if found
17
+ run @file, "running #{@file}"
18
+ else
19
+ if found = alternative_file(@file)
20
+ run found, "alternative find, running"
21
+ else
22
+ run 'spec', 'could not find file, running full suite ... '
23
+ end
24
+ end
25
+ rescue => e
26
+ run 'spec', "could not find file due to errors, running full suite ... ERROR: #{e}"
27
+ end
28
+ end
29
+
30
+ def alternative_file file
31
+ file = file.split("/").last.split(".")[0]
32
+ file = "#{file}_spec.rb"
33
+ found = false
34
+ @list.each{|f| found = f if f.include? file}
35
+ found
36
+ end
37
+
38
+ private
39
+
40
+ def run file, message
41
+ puts "#{message} #{file} ... ".yellow
42
+ print `rspec #{file}`
43
+ end
44
+
45
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'dispatch'
2
+
3
+ class Officer
4
+
5
+ def on_duty
6
+ FSSM.monitor(".") do
7
+ update do |b, r|
8
+ puts "--------------------------------------------------------------------------------------".blue
9
+ puts "Updated file '#{r}' from '#{b}'".blue
10
+ dispatch = Dispatch.new(r, b)
11
+ dispatch.run_test
12
+ end
13
+
14
+ create do |b, r|
15
+ puts "--------------------------------------------------------------------------------------".green
16
+ puts "Created file '#{r}' from '#{b}'".green
17
+ dispatch = Dispatch.new(r, b)
18
+ dispatch.run_test
19
+ end
20
+
21
+ delete do |b, r|
22
+ puts "--------------------------------------------------------------------------------------".red
23
+ puts "Removed file '#{r}' from '#{b}'".red
24
+ dispatch = Dispatch.new(r, b)
25
+ dispatch.run_test
26
+ end
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,3 @@
1
+ module TestOfficer
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dispatch do
4
+
5
+ let(:dispatch) { Dispatch.new("/test.rb", "/this/is/a/") }
6
+
7
+ describe "#alternative_find" do
8
+
9
+ context 'searching the list of files' do
10
+
11
+ it 'should find spec file in list' do
12
+ dispatch.list = ["test_spec.rb", "test.rb"]
13
+ expect(dispatch.alternative_file("/this/is/a/test.rb")).to eq("test_spec.rb")
14
+ end
15
+
16
+ it 'should return false if spec file is not found' do
17
+ dispatch.list = ["test_xxxx.rb", "test.rb"]
18
+ expect(dispatch.alternative_file("/this/is/a/test.rb")).to eq(false)
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Officer do
4
+
5
+ describe '#on_duty' do
6
+
7
+ before(:all) do
8
+ @officer = Officer.new
9
+ end
10
+
11
+ it 'should return null' do
12
+ FSSM.should_receive(:monitor)
13
+ @officer.on_duty
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,2 @@
1
+ require_relative '../lib/test_officer/officer'
2
+ require 'fssm'
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'test_officer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "test_officer"
8
+ spec.version = TestOfficer::VERSION
9
+ spec.authors = ["Dan Bickford"]
10
+ spec.email = ["danbickford007@yahoo.com"]
11
+ spec.description = %q{This gem watches your project for changes and runs specs accordingly.}
12
+ spec.summary = %q{Watching your project for saves, creates or deletes on files...this gem will either run the file altered or will find the specific spec file to run. }
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "fssm"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "colorize"
26
+ spec.add_dependency "fssm"
27
+ spec.add_dependency "rspec"
28
+ spec.add_dependency "colorize"
29
+
30
+ end
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test_officer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dan Bickford
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fssm
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: colorize
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: fssm
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: colorize
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: This gem watches your project for changes and runs specs accordingly.
126
+ email:
127
+ - danbickford007@yahoo.com
128
+ executables:
129
+ - patrol
130
+ - test_officer
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - .gitignore
135
+ - .travis.yml
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - bin/patrol
141
+ - bin/test_officer
142
+ - lib/test_officer.rb
143
+ - lib/test_officer/dispatch.rb
144
+ - lib/test_officer/officer.rb
145
+ - lib/test_officer/version.rb
146
+ - spec/dispatch_spec.rb
147
+ - spec/officer_spec.rb
148
+ - spec/spec_helper.rb
149
+ - test_officer.gemspec
150
+ homepage: ''
151
+ licenses:
152
+ - MIT
153
+ metadata: {}
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - '>='
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - '>='
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubyforge_project:
170
+ rubygems_version: 2.0.6
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: Watching your project for saves, creates or deletes on files...this gem will
174
+ either run the file altered or will find the specific spec file to run.
175
+ test_files:
176
+ - spec/dispatch_spec.rb
177
+ - spec/officer_spec.rb
178
+ - spec/spec_helper.rb