rformat 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +78 -0
- data/Guardfile +9 -0
- data/HELP.txt +4 -0
- data/LICENSE.txt +20 -0
- data/README.md +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/bin/rformat +5 -0
- data/lib/rformat/application.rb +94 -0
- data/lib/rformat/environment.rb +55 -0
- data/lib/rformat/formatters.yml +8 -0
- data/lib/rformat.rb +28 -0
- data/spec/application_spec.rb +90 -0
- data/spec/environment_spec.rb +93 -0
- data/spec/rformat_spec.rb +29 -0
- data/spec/spec_helper.rb +17 -0
- metadata +295 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'fuubar'
|
4
|
+
gem 'nyan-cat-formatter'
|
5
|
+
gem 'rspec-formatter-webkit'
|
6
|
+
gem 'rspec-nc'
|
7
|
+
gem 'unicorn-formatter'
|
8
|
+
|
9
|
+
group :development do
|
10
|
+
gem "bundler"
|
11
|
+
gem "jeweler"
|
12
|
+
gem "rspec"
|
13
|
+
gem "terminal-notifier"
|
14
|
+
gem 'guard-rspec'
|
15
|
+
gem 'pry'
|
16
|
+
gem 'pry-nav'
|
17
|
+
gem 'rb-fsevent'
|
18
|
+
gem 'terminal-notifier-guard'
|
19
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
coderay (1.0.8)
|
5
|
+
diff-lcs (1.1.3)
|
6
|
+
fuubar (1.1.0)
|
7
|
+
rspec (~> 2.0)
|
8
|
+
rspec-instafail (~> 0.2.0)
|
9
|
+
ruby-progressbar (~> 1.0.0)
|
10
|
+
git (1.2.5)
|
11
|
+
guard (1.5.4)
|
12
|
+
listen (>= 0.4.2)
|
13
|
+
lumberjack (>= 1.0.2)
|
14
|
+
pry (>= 0.9.10)
|
15
|
+
thor (>= 0.14.6)
|
16
|
+
guard-rspec (2.1.2)
|
17
|
+
guard (>= 1.1)
|
18
|
+
rspec (~> 2.11)
|
19
|
+
jeweler (1.8.4)
|
20
|
+
bundler (~> 1.0)
|
21
|
+
git (>= 1.2.5)
|
22
|
+
rake
|
23
|
+
rdoc
|
24
|
+
json (1.7.5)
|
25
|
+
listen (0.5.3)
|
26
|
+
lumberjack (1.0.2)
|
27
|
+
method_source (0.8.1)
|
28
|
+
nyan-cat-formatter (0.2.0)
|
29
|
+
pry (0.9.10)
|
30
|
+
coderay (~> 1.0.5)
|
31
|
+
method_source (~> 0.8)
|
32
|
+
slop (~> 3.3.1)
|
33
|
+
pry-nav (0.2.2)
|
34
|
+
pry (~> 0.9.10)
|
35
|
+
rake (10.0.1)
|
36
|
+
rb-fsevent (0.9.2)
|
37
|
+
rdoc (3.12)
|
38
|
+
json (~> 1.4)
|
39
|
+
rspec (2.12.0)
|
40
|
+
rspec-core (~> 2.12.0)
|
41
|
+
rspec-expectations (~> 2.12.0)
|
42
|
+
rspec-mocks (~> 2.12.0)
|
43
|
+
rspec-core (2.12.0)
|
44
|
+
rspec-expectations (2.12.0)
|
45
|
+
diff-lcs (~> 1.1.3)
|
46
|
+
rspec-formatter-webkit (2.2.0)
|
47
|
+
rspec-core (~> 2.7)
|
48
|
+
rspec-instafail (0.2.4)
|
49
|
+
rspec-mocks (2.12.0)
|
50
|
+
rspec-nc (0.0.4)
|
51
|
+
rspec (~> 2.9)
|
52
|
+
terminal-notifier (~> 1.4.2)
|
53
|
+
ruby-progressbar (1.0.2)
|
54
|
+
slop (3.3.3)
|
55
|
+
terminal-notifier (1.4.2)
|
56
|
+
terminal-notifier-guard (1.5.3)
|
57
|
+
thor (0.16.0)
|
58
|
+
unicorn-formatter (0.1.3)
|
59
|
+
rspec
|
60
|
+
|
61
|
+
PLATFORMS
|
62
|
+
ruby
|
63
|
+
|
64
|
+
DEPENDENCIES
|
65
|
+
bundler
|
66
|
+
fuubar
|
67
|
+
guard-rspec
|
68
|
+
jeweler
|
69
|
+
nyan-cat-formatter
|
70
|
+
pry
|
71
|
+
pry-nav
|
72
|
+
rb-fsevent
|
73
|
+
rspec
|
74
|
+
rspec-formatter-webkit
|
75
|
+
rspec-nc
|
76
|
+
terminal-notifier
|
77
|
+
terminal-notifier-guard
|
78
|
+
unicorn-formatter
|
data/Guardfile
ADDED
data/HELP.txt
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Dayton Nolan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# rformat
|
2
|
+
|
3
|
+
rformat is a command line utility to manage and use multiple rspec formatters on the fly
|
4
|
+
|
5
|
+
## Contributing to rformat
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
## Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Dayton Nolan. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "rformat"
|
18
|
+
gem.homepage = "http://github.com/daytonn/rformat"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{rformat is a command line utility to manage rspec formatters}
|
21
|
+
gem.description = %Q{rformat will swap out the formatter contents of your ~/.rspec file so you can switch rspec formatters on the fly.}
|
22
|
+
gem.email = "dnolan@gmail.com"
|
23
|
+
gem.authors = ["Dayton Nolan"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "rformat #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/rformat
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'rformat'
|
3
|
+
require 'rformat/environment'
|
4
|
+
|
5
|
+
module RFormat
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def application
|
10
|
+
@application ||= RFormat::Application.new
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
class Application
|
16
|
+
|
17
|
+
attr_reader :args,
|
18
|
+
:command,
|
19
|
+
:options,
|
20
|
+
:environment
|
21
|
+
|
22
|
+
def initialize(output = $stdout, env = RFormat::Environment.new)
|
23
|
+
@output = output
|
24
|
+
@environment = env
|
25
|
+
@args = Array.try_convert(ARGV)
|
26
|
+
end
|
27
|
+
|
28
|
+
def run
|
29
|
+
parse_command
|
30
|
+
parse_options
|
31
|
+
|
32
|
+
if @command && @command !~ /^-/
|
33
|
+
self.send(@command, @args)
|
34
|
+
else
|
35
|
+
help
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def help
|
41
|
+
@output.puts File.read File.join(RFormat::root_dir, 'HELP.txt')
|
42
|
+
end
|
43
|
+
|
44
|
+
def list(args)
|
45
|
+
@output.puts "Formatters:"
|
46
|
+
@output.puts @environment.formatters.keys.map { |f| " #{f}\n" }
|
47
|
+
end
|
48
|
+
|
49
|
+
def version
|
50
|
+
version = RFormat::Version
|
51
|
+
copyright = RFormat::Copyright
|
52
|
+
@output.puts "#{version}\n#{copyright}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def write(formats)
|
56
|
+
config = {
|
57
|
+
color: true,
|
58
|
+
formats: {}
|
59
|
+
}
|
60
|
+
formats.each do |format|
|
61
|
+
config[:formats][format] = @environment.formatters[format] if @environment.formatters[format]
|
62
|
+
end
|
63
|
+
@environment.config = config
|
64
|
+
if config[:formats].empty?
|
65
|
+
@output.puts "No formatters matching #{formats.join(', ')}"
|
66
|
+
else
|
67
|
+
@environment.write_config
|
68
|
+
@output.puts "rspec now using format(s): #{config[:formats].values.join(', ')}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def parse_command
|
73
|
+
command = @args.first == 'list' ? @args.shift : @args.first
|
74
|
+
command = command.to_sym if command.respond_to? :to_sym
|
75
|
+
@command = command == :list ? :list : :write
|
76
|
+
end
|
77
|
+
|
78
|
+
def parse_options
|
79
|
+
@options = {}
|
80
|
+
OptionParser.new do |opts|
|
81
|
+
opts.on("-v", "--version", "Version info") do
|
82
|
+
@options[:version] = true
|
83
|
+
version
|
84
|
+
end
|
85
|
+
|
86
|
+
opts.on('-h', '--help', 'Display help') do
|
87
|
+
@options[:help] = true
|
88
|
+
help
|
89
|
+
end
|
90
|
+
end.parse!
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rformat'
|
2
|
+
|
3
|
+
module RFormat
|
4
|
+
class Environment
|
5
|
+
|
6
|
+
attr_accessor :config, :formatters, :custom_formatters
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@config = {
|
10
|
+
color: true,
|
11
|
+
formats: {
|
12
|
+
default: 'default'
|
13
|
+
}
|
14
|
+
}
|
15
|
+
load_custom_formatters
|
16
|
+
end
|
17
|
+
|
18
|
+
def has_custom_formats?
|
19
|
+
File.exists?(RFormat::rformat_env_file)
|
20
|
+
end
|
21
|
+
|
22
|
+
def formatters
|
23
|
+
load_formatters.merge custom_formatters
|
24
|
+
end
|
25
|
+
|
26
|
+
def load_formatters
|
27
|
+
YAML.load_file(RFormat::format_file)
|
28
|
+
end
|
29
|
+
|
30
|
+
def load_custom_formatters
|
31
|
+
@custom_formatters ||= has_custom_formats? ? YAML.load_file(RFormat::rformat_env_file) : {}
|
32
|
+
end
|
33
|
+
|
34
|
+
def rspec_config_file
|
35
|
+
File.join(ENV['HOME'], '.rspec')
|
36
|
+
end
|
37
|
+
|
38
|
+
def has_rspec_config?
|
39
|
+
File.exists?(rspec_config_file)
|
40
|
+
end
|
41
|
+
|
42
|
+
def write_config
|
43
|
+
File.open(rspec_config_file, 'w+') do |f|
|
44
|
+
f << config_string
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def config_string
|
49
|
+
color_string = @config[:color] ? '--color' : ''
|
50
|
+
formats_string = @config[:formats].values.map { |f| "--format #{f}" }.join(" ")
|
51
|
+
"#{color_string} #{formats_string}"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
data/lib/rformat.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module RFormat
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def root_dir
|
9
|
+
File.expand_path('../', File.dirname(__FILE__))
|
10
|
+
end
|
11
|
+
|
12
|
+
def lib_dir
|
13
|
+
File.join(root_dir, 'lib')
|
14
|
+
end
|
15
|
+
|
16
|
+
def format_file
|
17
|
+
File.join(lib_dir, 'rformat', 'formatters.yml')
|
18
|
+
end
|
19
|
+
|
20
|
+
def rformat_env_file
|
21
|
+
File.join(ENV['HOME'], ".rformat")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Version = File.read(File.join(self.root_dir, 'VERSION'))
|
26
|
+
Copyright = File.readlines(File.join(self.root_dir, 'LICENSE.txt')).first
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rformat/application'
|
3
|
+
|
4
|
+
describe RFormat::Application do
|
5
|
+
|
6
|
+
let(:output) { StringIO.new }
|
7
|
+
let(:env) { RFormat::Environment.new }
|
8
|
+
let(:app) { RFormat::Application.new(output) }
|
9
|
+
|
10
|
+
it "creates a default RFormat::Environment" do
|
11
|
+
expect(app.environment).to be_an_instance_of(RFormat::Environment)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "outputs a help menu" do
|
15
|
+
output.should_receive(:puts).with(File.read(File.join(ROOT, 'HELP.txt')))
|
16
|
+
app.help
|
17
|
+
end
|
18
|
+
|
19
|
+
it "outputs a list of the available formatters" do
|
20
|
+
output.should_receive(:puts).with("Formatters:")
|
21
|
+
output.should_receive(:puts).with(env.formatters.keys.map { |f| " #{f}\n" })
|
22
|
+
app.list []
|
23
|
+
end
|
24
|
+
|
25
|
+
it "outputs the version with copyright information" do
|
26
|
+
version = File.read(File.join(RFormat::root_dir, 'VERSION'))
|
27
|
+
copyright = "Copyright (c) 2012 Dayton Nolan\n"
|
28
|
+
|
29
|
+
output.should_receive(:puts).with("#{version}\n#{copyright}")
|
30
|
+
app.version
|
31
|
+
end
|
32
|
+
|
33
|
+
it "can parse the command from an args array" do
|
34
|
+
ARGV = ['list']
|
35
|
+
expect(app.parse_command).to eq(:list)
|
36
|
+
ARGV = ['nyan', 'unicorn']
|
37
|
+
expect(app.parse_command).to eq(:write)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "doesn't count subcommands as arguments" do
|
41
|
+
ARGV = ['list']
|
42
|
+
list_example = RFormat::Application.new(StringIO.new, RFormat::Environment.new)
|
43
|
+
list_example.parse_command
|
44
|
+
expect(list_example.args).to eq([])
|
45
|
+
|
46
|
+
ARGV = ['nyan', 'unicorn']
|
47
|
+
format_example = RFormat::Application.new(StringIO.new, RFormat::Environment.new)
|
48
|
+
format_example.parse_command
|
49
|
+
expect(format_example.args).to eq(['nyan', 'unicorn'])
|
50
|
+
end
|
51
|
+
|
52
|
+
it "can parse the options from an args array" do
|
53
|
+
ARGV = ['-v']
|
54
|
+
app.parse_options
|
55
|
+
expect(app.options[:version]).to be true
|
56
|
+
|
57
|
+
ARGV = ['-h']
|
58
|
+
app.parse_options
|
59
|
+
expect(app.options[:help]).to be true
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'creating a .rspec file' do
|
63
|
+
before :each do
|
64
|
+
FileUtils.mv(env.rspec_config_file, SPECS) if File.exists? env.rspec_config_file
|
65
|
+
end
|
66
|
+
|
67
|
+
after :each do
|
68
|
+
FileUtils.mv("#{SPECS}/.rspec", env.rspec_config_file) if File.exists? "#{SPECS}/.rspec"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should write the formatters to the .rspec file" do
|
72
|
+
output.should_receive(:puts).with('rspec now using format(s): NyanCatFormatter, UnicornFormatter')
|
73
|
+
app.write(['nyan', 'unicorn'])
|
74
|
+
expect(File.read(env.rspec_config_file)).to eq('--color --format NyanCatFormatter --format UnicornFormatter')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should run the write command" do
|
79
|
+
ARGV = ['nyan', 'unicorn']
|
80
|
+
app.should_receive(:write).with(['nyan', 'unicorn'])
|
81
|
+
app.run
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should run the list command" do
|
85
|
+
ARGV = ['list']
|
86
|
+
app.should_receive(:list).with([])
|
87
|
+
app.run
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rformat/environment'
|
3
|
+
|
4
|
+
describe RFormat::Environment do
|
5
|
+
|
6
|
+
let(:env) { RFormat::Environment.new }
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
File.open(RFormat::rformat_env_file, "w+") do |f|
|
10
|
+
f << "test_custom: TestCustom"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
after :each do
|
15
|
+
FileUtils.rm_rf RFormat::rformat_env_file if File.exists? RFormat::rformat_env_file
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has a rspec_config_file" do
|
19
|
+
expect(env.rspec_config_file).to eq(File.join(ENV['HOME'], '.rspec'))
|
20
|
+
end
|
21
|
+
|
22
|
+
it "determines the existence of custom formats" do
|
23
|
+
expect(env.has_custom_formats?).to be true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "can load formatters" do
|
27
|
+
expect(env.load_formatters).to eq({
|
28
|
+
"default" => "progress",
|
29
|
+
"doc" => "documentation",
|
30
|
+
"fuubar" => "Fuubar",
|
31
|
+
"nc" => "Nc",
|
32
|
+
"nyan" => "NyanCatFormatter",
|
33
|
+
"progress" => "progress",
|
34
|
+
"unicorn" => "UnicornFormatter",
|
35
|
+
"webkit" => "RSpec::Core::Formatters::WebKit"
|
36
|
+
})
|
37
|
+
end
|
38
|
+
|
39
|
+
it "can load custom formatters" do
|
40
|
+
expect(env.load_custom_formatters).to eq ({ "test_custom" => "TestCustom" })
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has custom_formatters" do
|
44
|
+
expect(env.custom_formatters).to eq({ "test_custom" => "TestCustom" })
|
45
|
+
end
|
46
|
+
|
47
|
+
it "has formatters" do
|
48
|
+
expect(env.formatters.empty?).to be false
|
49
|
+
end
|
50
|
+
|
51
|
+
it "has default and custom formatters" do
|
52
|
+
expect(env.formatters).to include("default")
|
53
|
+
expect(env.formatters).to include("test_custom")
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '~/.rspec file' do
|
57
|
+
it "can determine if a ~/.rspec config file exists" do
|
58
|
+
expect(env.has_rspec_config?).to be true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'non-existent ~/.rspec file' do
|
63
|
+
|
64
|
+
before :each do
|
65
|
+
FileUtils.mv(env.rspec_config_file, SPECS) if File.exists? env.rspec_config_file
|
66
|
+
end
|
67
|
+
|
68
|
+
after :each do
|
69
|
+
FileUtils.mv("#{SPECS}/.rspec", env.rspec_config_file) if File.exists? "#{SPECS}/.rspec"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "can determine if a ~/.rspec file does not exist" do
|
73
|
+
expect(env.has_rspec_config?).to be false
|
74
|
+
end
|
75
|
+
|
76
|
+
it "creates a configuration string" do
|
77
|
+
env.config = { color: true, formats: { default: 'default' } }
|
78
|
+
expect(env.config_string).to eq("--color --format default")
|
79
|
+
end
|
80
|
+
|
81
|
+
it "can write an ~/.rspec file" do
|
82
|
+
env.write_config
|
83
|
+
expect(env.has_rspec_config?).to be true
|
84
|
+
end
|
85
|
+
|
86
|
+
it "creates a default configuration" do
|
87
|
+
env.write_config
|
88
|
+
expect(File.read(env.rspec_config_file)).to eq("--color --format default")
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe RFormat do
|
4
|
+
|
5
|
+
it "has a root_dir directory" do
|
6
|
+
expect(RFormat::root_dir).to eq(File.expand_path('../', File.dirname(__FILE__)))
|
7
|
+
end
|
8
|
+
|
9
|
+
it "has a lib_dir directory" do
|
10
|
+
expect(RFormat::lib_dir).to eq(File.expand_path('../lib', File.dirname(__FILE__)))
|
11
|
+
end
|
12
|
+
|
13
|
+
it "has a format file" do
|
14
|
+
expect(RFormat::format_file).to eq(File.expand_path('../lib/rformat/formatters.yml', File.dirname(__FILE__)))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "has an RFORMAT_ENV" do
|
18
|
+
expect(RFormat::rformat_env_file).to eq(File.join(ENV['HOME'], ".rformat"))
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has a version" do
|
22
|
+
expect(RFormat::Version).to eq(File.read(File.join(RFormat::root_dir, 'VERSION')))
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has a copyright" do
|
26
|
+
expect(RFormat::Copyright).to eq("Copyright (c) 2012 Dayton Nolan\n")
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'pry'
|
6
|
+
require 'rformat'
|
7
|
+
|
8
|
+
# Requires supporting files with custom matchers and macros, etc,
|
9
|
+
# in ./support/ and its subdirectories.
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
SPECS = File.expand_path(File.dirname(__FILE__))
|
17
|
+
ROOT = File.expand_path('../', SPECS)
|
metadata
ADDED
@@ -0,0 +1,295 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rformat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dayton Nolan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fuubar
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: nyan-cat-formatter
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec-formatter-webkit
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec-nc
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: unicorn-formatter
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: bundler
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: jeweler
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rspec
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: terminal-notifier
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: guard-rspec
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: pry
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: pry-nav
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
type: :development
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ! '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
- !ruby/object:Gem::Dependency
|
207
|
+
name: rb-fsevent
|
208
|
+
requirement: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ! '>='
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
type: :development
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ! '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
- !ruby/object:Gem::Dependency
|
223
|
+
name: terminal-notifier-guard
|
224
|
+
requirement: !ruby/object:Gem::Requirement
|
225
|
+
none: false
|
226
|
+
requirements:
|
227
|
+
- - ! '>='
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
none: false
|
234
|
+
requirements:
|
235
|
+
- - ! '>='
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0'
|
238
|
+
description: rformat will swap out the formatter contents of your ~/.rspec file so
|
239
|
+
you can switch rspec formatters on the fly.
|
240
|
+
email: dnolan@gmail.com
|
241
|
+
executables:
|
242
|
+
- rformat
|
243
|
+
extensions: []
|
244
|
+
extra_rdoc_files:
|
245
|
+
- LICENSE.txt
|
246
|
+
- README.md
|
247
|
+
files:
|
248
|
+
- .document
|
249
|
+
- .rspec
|
250
|
+
- Gemfile
|
251
|
+
- Gemfile.lock
|
252
|
+
- Guardfile
|
253
|
+
- HELP.txt
|
254
|
+
- LICENSE.txt
|
255
|
+
- README.md
|
256
|
+
- Rakefile
|
257
|
+
- VERSION
|
258
|
+
- bin/rformat
|
259
|
+
- lib/rformat.rb
|
260
|
+
- lib/rformat/application.rb
|
261
|
+
- lib/rformat/environment.rb
|
262
|
+
- lib/rformat/formatters.yml
|
263
|
+
- spec/application_spec.rb
|
264
|
+
- spec/environment_spec.rb
|
265
|
+
- spec/rformat_spec.rb
|
266
|
+
- spec/spec_helper.rb
|
267
|
+
homepage: http://github.com/daytonn/rformat
|
268
|
+
licenses:
|
269
|
+
- MIT
|
270
|
+
post_install_message:
|
271
|
+
rdoc_options: []
|
272
|
+
require_paths:
|
273
|
+
- lib
|
274
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
275
|
+
none: false
|
276
|
+
requirements:
|
277
|
+
- - ! '>='
|
278
|
+
- !ruby/object:Gem::Version
|
279
|
+
version: '0'
|
280
|
+
segments:
|
281
|
+
- 0
|
282
|
+
hash: -135377835534220607
|
283
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
284
|
+
none: false
|
285
|
+
requirements:
|
286
|
+
- - ! '>='
|
287
|
+
- !ruby/object:Gem::Version
|
288
|
+
version: '0'
|
289
|
+
requirements: []
|
290
|
+
rubyforge_project:
|
291
|
+
rubygems_version: 1.8.23
|
292
|
+
signing_key:
|
293
|
+
specification_version: 3
|
294
|
+
summary: rformat is a command line utility to manage rspec formatters
|
295
|
+
test_files: []
|