rspec-parts 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f788f7a01f3ab81928b220c846faba04d6eef22d
4
+ data.tar.gz: d199f980e88d5947b5b16225b3d33d64bcc8199d
5
+ SHA512:
6
+ metadata.gz: 59e039e8615126551bd499a7b7f5596676fe3369c38ffb73dfde9a9ea41707dd21a7a1127329b3fa82c356f489a680d04177dbb50c6679b528048accad041260
7
+ data.tar.gz: d44b75252f9098385f6954529b338cbf0c8c80a18ca7414aa87934f23d066466ff930d5f60a42053c7c27290db949e311ffe2197438bd4c023abb73519831b9c
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.4
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-parts.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 James Hart
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,68 @@
1
+ # Rspec::Parts
2
+
3
+ ### Speed up your builds, fully utilize your Travis Pro capacity!
4
+
5
+ When using Travis Pro we had five available executors, of which only two were being used, one by [Jasmine][jasmine] and one by [Rspec][rspec].
6
+ This allows you to split your spec suite into multiple, but equal **parts**. We wanted to split our rspec suite into four parts to fully utilize our remaining executors.
7
+
8
+ This sped up our Travis Pro builds from running one travis process in **70 minutes** to running four processes in **15 minutes** each.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'rspec-parts'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install rspec-parts
25
+
26
+ ## Usage
27
+
28
+ Now you can run the following:
29
+
30
+ ```shell
31
+ rake spec:part[1,4]
32
+ ```
33
+
34
+ This will divide your specs into four equal parts, then run the first part of the four. `rake spec:part[2,4]` will run the second part, and so on.
35
+
36
+ ## Configuration
37
+
38
+ The following are available for configuration:
39
+
40
+ Rspec::Parts.configure do |config|
41
+ config.file_list_exclusions = ['spec_helper.rb', 'spec/controllers/jasmine_fixture_generation/*.rb']
42
+ config.spec_directory_glob = 'test/*'
43
+ config.rspec_opts = '--profile --tag ~nginx --format progress'
44
+ end
45
+
46
+ * `file_list_exclusions` will exclude the following files or directories from running.
47
+ * `spec_directory_glob` allows you to choose which directories to include
48
+ * `rspec_opts` allows you to tack on rspec options to the `rspec` command.
49
+
50
+ See the `rspec_parts.rake` file for the usage of configuration variables.
51
+
52
+ ## Development
53
+
54
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
55
+
56
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+
58
+ ## Contributing
59
+
60
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hjhart/rspec-parts. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
61
+
62
+ ## License
63
+
64
+ The gem is available as open source under the terms of the [MIT License][mit-license].
65
+
66
+ [mit-license]: http://opensource.org/licenses/MIT
67
+ [jasmine]: https://github.com/jasmine/jasmine-gem
68
+ [rspec]: https://github.com/rspec/rspec
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ import "./lib/tasks/rspec_parts.rake"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rspec/parts"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ require "rspec/parts/version"
2
+ require "rspec/parts/configuration"
3
+ require "rspec/parts/file_list"
4
+
5
+ module Rspec
6
+ module Parts
7
+ class << self
8
+ attr_writer :config
9
+ end
10
+
11
+ def self.config
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ def self.configure
16
+ yield(config)
17
+ end
18
+ end
19
+ end
20
+
21
+ if defined?(Rails) && Rails.respond_to?(:version)
22
+ require File.join('rspec', 'parts', 'railtie')
23
+ end
@@ -0,0 +1,17 @@
1
+ module Rspec
2
+ module Parts
3
+ class Configuration
4
+ attr_accessor :spec_directory_glob
5
+ attr_accessor :rspec_opts
6
+ attr_accessor :file_list_exclusions
7
+ attr_accessor :default_number_of_parts
8
+
9
+ def initialize
10
+ @spec_directory_glob = 'spec/*'
11
+ @rspec_opts = ''
12
+ @file_list_exclusions = []
13
+ @default_number_of_parts = 4
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,51 @@
1
+ require 'rake/file_list'
2
+
3
+ # Grabbed from ActiveSupport
4
+ # activesupport/lib/active_support/core_ext/array/grouping.rb, line 60
5
+ class Array
6
+ def in_groups(number, fill_with = nil)
7
+ # size.div number gives minor group size;
8
+ # size % number gives how many objects need extra accommodation;
9
+ # each group hold either division or division + 1 items.
10
+ division = size.div number
11
+ modulo = size % number
12
+
13
+ # create a new array avoiding dup
14
+ groups = []
15
+ start = 0
16
+
17
+ number.times do |index|
18
+ length = division + (modulo > 0 && modulo > index ? 1 : 0)
19
+ groups << last_group = slice(start, length)
20
+ last_group << fill_with if fill_with != false &&
21
+ modulo > 0 && length == division
22
+ start += length
23
+ end
24
+
25
+ if block_given?
26
+ groups.each { |g| yield(g) }
27
+ else
28
+ groups
29
+ end
30
+ end
31
+ end
32
+
33
+ module Rspec
34
+ module Parts
35
+ class FileList
36
+ def self.from(glob: glob, groups: groups, part: part)
37
+ total_file_list = Rake::FileList.new
38
+
39
+ Dir.glob(glob).each do |spec_directory|
40
+ directory_file_list = Rake::FileList.new
41
+ directory_file_list.add("#{spec_directory}/**/*_spec.rb")
42
+ subset_of_directory_file_list = directory_file_list.to_a.in_groups(groups, false).at(part)
43
+ total_file_list.add(subset_of_directory_file_list)
44
+ end
45
+
46
+ total_file_list
47
+ end
48
+ end
49
+ end
50
+ end
51
+
@@ -0,0 +1,11 @@
1
+ require 'rails/railtie'
2
+
3
+ module Rspec
4
+ module Parts
5
+ class Railtie < Rails::Railtie
6
+ rake_tasks do
7
+ load 'tasks/rspec_parts.rake'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module Rspec
2
+ module Parts
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ require 'rspec/parts'
2
+
3
+ if defined?(RSpec)
4
+ namespace :spec do
5
+ desc 'Run part M of N specs'
6
+ RSpec::Core::RakeTask.new(:part, :part, :groups) do |task, task_args|
7
+ config = Rspec::Parts.config
8
+
9
+ groups = task_args[:groups].to_i == 0 ? config.default_number_of_parts : task_args[:groups].to_i
10
+ part = (task_args[:part].to_i == 0 ? 1 : task_args[:part].to_i)
11
+ part_index = part - 1
12
+
13
+ puts "Running part #{part} of #{groups} groups"
14
+
15
+ file_list = Rspec::Parts::FileList.from(glob: config.spec_directory_glob, groups: groups, part: part_index)
16
+ config.file_list_exclusions.each do |exclusion|
17
+ file_list.exclude(exclusion)
18
+ end
19
+
20
+ task.rspec_opts = config.rspec_opts
21
+ task.pattern = file_list
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec/parts/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'rspec-parts'
8
+ spec.version = Rspec::Parts::VERSION
9
+ spec.authors = ['James Hart']
10
+ spec.email = ['james@wanelo.com']
11
+
12
+ spec.summary = %q{Split your rspec suite into equal parts}
13
+ spec.description = %q{Split your rspec suite into equal parts}
14
+ spec.homepage = 'http://github.com/hjhart/rspec-parts'
15
+ spec.license = 'MIT'
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+ else
22
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_development_dependency 'bundler', '~> 1.10'
31
+ spec.add_development_dependency 'pry-nav'
32
+ spec.add_development_dependency 'rspec'
33
+ spec.add_dependency 'rake'
34
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-parts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Hart
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-07 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry-nav
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: rspec
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: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Split your rspec suite into equal parts
70
+ email:
71
+ - james@wanelo.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - lib/rspec/parts.rb
87
+ - lib/rspec/parts/configuration.rb
88
+ - lib/rspec/parts/file_list.rb
89
+ - lib/rspec/parts/railtie.rb
90
+ - lib/rspec/parts/version.rb
91
+ - lib/tasks/rspec_parts.rake
92
+ - rspec-parts.gemspec
93
+ homepage: http://github.com/hjhart/rspec-parts
94
+ licenses:
95
+ - MIT
96
+ metadata:
97
+ allowed_push_host: https://rubygems.org
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.2.2
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Split your rspec suite into equal parts
118
+ test_files: []