rspec-rails-uncommitted 2.0.0

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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rspec-rails-uncommitted.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # rspec-rails-uncommitted
2
+
3
+ rake tasks for rails-3 which selectively run specs based on your SCM status.
4
+
5
+ ## Install
6
+ ```
7
+ gem install rspec-rails-uncommitted
8
+ ```
9
+
10
+ ## Configure
11
+
12
+ Add `rspec-rails-uncommitted` to the `:test` and `:development` groups in the Gemfile:
13
+
14
+ ```ruby
15
+ group :test, :development do
16
+ gem "rspec-rails-uncommitted", "~> 2.0"
17
+ end
18
+ ```
19
+
20
+ It needs to be in the `:development` group to expose generators and rake
21
+ tasks without having to type `RAILS_ENV=test`.
22
+
23
+ ## Behavior
24
+
25
+ ### `rake rspec:uncommitted`
26
+
27
+ This task will execute specs associated with files you have changed and not yet committed.
28
+
29
+ ### `rake rspec:unpushed`
30
+
31
+ This task will execute specs for files you have committed locally, but haven't pushed up to origin.
32
+
33
+ ### `rake rspec:unmerged`
34
+
35
+ This task will execute specs for files you have not yet merged back into the master branch.
36
+
37
+ # Contribute
38
+
39
+ See [http://github.com/rspec/rspec-dev](http://github.com/rspec/rspec-dev)
40
+
41
+ # Also see
42
+
43
+ * [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
44
+ * [http://github.com/rspec/rspec-core](http://github.com/rspec/rspec-core)
45
+ * [http://github.com/rspec/rspec-rails](http://github.com/rspec/rspec-rails)
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,76 @@
1
+ require 'rspec/core'
2
+ require 'rspec/core/rake_task'
3
+
4
+ # FIXME: these two settings are duplicated from rspec-rails
5
+ orm_setting = Rails.configuration.generators.options[:rails][:orm]
6
+ spec_prereq = if(orm_setting == :active_record)
7
+ Rails.configuration.active_record[:schema_format] == :sql ? "db:test:clone_structure" : "db:test:prepare"
8
+ else
9
+ :noop
10
+ end
11
+
12
+ def uncommitted
13
+ # cribbed from rails/railties/lib/rails/test_unit/testing.rake
14
+ if File.directory?(".svn")
15
+ changed_since_checkin = silence_stderr { `svn status` }.split.map { |path| path.chomp[7 .. -1] }
16
+ elsif File.directory?(".git")
17
+ changed_since_checkin = silence_stderr { `git ls-files --modified --others` }.split.map { |path| path.chomp }
18
+ else
19
+ abort "Not a Subversion or Git checkout."
20
+ end
21
+ end
22
+
23
+ def unpushed
24
+ if File.directory?(".git")
25
+ `git diff origin/#{current_branch} --stat`.split("\n")[0..-2].map{|path| path.chomp.split("\s").first}
26
+ else
27
+ abort "Not a Git checkout. (unpushed does not work with Subversion)"
28
+ end
29
+ end
30
+
31
+ def unmerged(branch="master")
32
+ if File.directory?(".git")
33
+ `git diff #{branch} --stat`.split("\n")[0..-2].map{|path| path.chomp.split("\s").first}
34
+ else
35
+ abort "Not a Git checkout. (unmerged does not work with Subversion)"
36
+ end
37
+ end
38
+
39
+ def current_branch
40
+ git_status[/On branch ([^\s]+)/, 1]
41
+ end
42
+
43
+ def git_status
44
+ @git_status ||= `git status`
45
+ end
46
+
47
+ def specs_to_run(changed)
48
+ # cribbed from rails/railties/lib/rails/test_unit/testing.rake
49
+ models = changed.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ }
50
+ controllers = changed.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ }
51
+
52
+ unit_tests = models.map { |model| "spec/models/#{File.basename(model, '.rb')}_spec.rb" }
53
+ functional_tests = controllers.map { |controller| "spec/controllers/#{File.basename(controller, '.rb')}_spec.rb" }
54
+ routing_tests = controllers.map { |controller| "spec/routing/#{File.basename(controller, '.rb').gsub("controller", "routing")}_spec.rb" }
55
+ # Someone who thinks that view testing is awesome should probably write code for handling view specs.
56
+
57
+ (unit_tests + functional_tests).uniq.select { |file| File.exist?(file) }
58
+ end
59
+
60
+ namespace :spec do
61
+ desc "Run uncommitted specs"
62
+ RSpec::Core::RakeTask.new(:uncommitted => spec_prereq) do |t|
63
+ t.pattern = specs_to_run uncommitted
64
+ end
65
+
66
+ desc "Run unmerged specs"
67
+ RSpec::Core::RakeTask.new(:unmerged => spec_prereq) do |t|
68
+ t.pattern = specs_to_run unmerged
69
+ end
70
+
71
+ desc "Run unpushed specs"
72
+ RSpec::Core::RakeTask.new(:unpushed => spec_prereq) do |t|
73
+ t.pattern = specs_to_run unpushed
74
+ end
75
+ end
76
+
@@ -0,0 +1,9 @@
1
+ module Rspec
2
+ module Rails
3
+ module Uncommitted
4
+ module Version
5
+ STRING = '2.0.0'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Rspec
2
+ module Rails
3
+ module Uncommitted
4
+ class Railtie < ::Rails::Railtie
5
+ rake_tasks do
6
+ load "rspec/rails/uncommitted/tasks/rspec.rake"
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rspec-rails-uncommitted/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rspec-rails-uncommitted"
7
+ s.version = Rspec::Rails::Uncommitted::Version::STRING
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Marshall Yount"]
10
+ s.email = ["marshall@yountlabs.com"]
11
+ s.homepage = "https://github.com/marshally/rspec-rails-uncommitted"
12
+ s.summary = %q{adds rake tasks which selectively run rspec tests based on git status.}
13
+ s.description = %q{adds rake tasks which selectively run rspec tests based on git status.}
14
+
15
+ s.rubyforge_project = "rspec-rails-uncommitted"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.require_paths = ["lib"]
19
+
20
+ if Rspec::Rails::Uncommitted::Version::STRING =~ /[a-zA-Z]+/ # prerelease builds
21
+ s.add_runtime_dependency "rspec-rails", "= #{Rspec::Rails::Uncommitted::Version::STRING}"
22
+ else
23
+ s.add_runtime_dependency "rspec-rails", "~> 2.0"
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-rails-uncommitted
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 0
10
+ version: 2.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Marshall Yount
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-05-16 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec-rails
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 2
32
+ - 0
33
+ version: "2.0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: adds rake tasks which selectively run rspec tests based on git status.
37
+ email:
38
+ - marshall@yountlabs.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - .gitignore
47
+ - Gemfile
48
+ - README.md
49
+ - Rakefile
50
+ - lib/rspec-rails-uncommitted.rb
51
+ - lib/rspec-rails-uncommitted/version.rb
52
+ - lib/rspec/rails/uncommitted/tasks/rspec.rake
53
+ - rspec-rails-uncommitted.gemspec
54
+ has_rdoc: true
55
+ homepage: https://github.com/marshally/rspec-rails-uncommitted
56
+ licenses: []
57
+
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirements: []
82
+
83
+ rubyforge_project: rspec-rails-uncommitted
84
+ rubygems_version: 1.6.2
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: adds rake tasks which selectively run rspec tests based on git status.
88
+ test_files: []
89
+