rspec-git_specifier 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 784659381c35016bb87ad45e59f67da53c7222ab
4
+ data.tar.gz: 2bb7efa3db3a7897ec729b80c29d2ba94af0b19a
5
+ SHA512:
6
+ metadata.gz: 7f4d96a091ea5e4799fb0a830b21d42614c0ba2c00a4b59ed23955b7ad5acc4cbbca575c4a59bb5af25c104f1f293ef37855ce015817feb78c75f27346182f79
7
+ data.tar.gz: b497509d85e3d12b098cc9da7ab9cbe1c3fb642c4531ab5135c9917c6dedd79a7c3dc488b90f4d1a03e27c0ab32e8e401381979ca7ec0236d4dfd9609ec5d081
data/.gitignore ADDED
@@ -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
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.4
5
+ - 2.2
6
+ before_install:
7
+ - git fetch origin +refs/heads/*:refs/remotes/origin/*
8
+ - git branch --verbose --all
9
+ - git remote --verbose
10
+ - gem install bundler
11
+ - bundle version
12
+ script: bundle exec rake ci
13
+ sudo: false
14
+ cache: bundler
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-git_specifier.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,78 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ ## Guard internally checks for changes in the Guardfile and exits.
11
+ ## If you want Guard to automatically start up again, run guard in a
12
+ ## shell loop, e.g.:
13
+ ##
14
+ ## $ while bundle exec guard; do echo "Restarting Guard..."; done
15
+ ##
16
+ ## Note: if you are using the `directories` clause above and you are not
17
+ ## watching the project directory ('.'), then you will want to move
18
+ ## the Guardfile to a watched dir and symlink it back, e.g.
19
+ #
20
+ # $ mkdir config
21
+ # $ mv Guardfile config/
22
+ # $ ln -s config/Guardfile .
23
+ #
24
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
+
26
+ # Note: The cmd option is now required due to the increasing number of ways
27
+ # rspec may be run, below are examples of the most common uses.
28
+ # * bundler: 'bundle exec rspec'
29
+ # * bundler binstubs: 'bin/rspec'
30
+ # * spring: 'bin/rspec' (This will use spring if running and you have
31
+ # installed the spring binstubs per the docs)
32
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
33
+ # * 'just' rspec: 'rspec'
34
+
35
+ guard :rspec, cmd: "bundle exec rspec" do
36
+ require "guard/rspec/dsl"
37
+ dsl = Guard::RSpec::Dsl.new(self)
38
+
39
+ # Feel free to open issues for suggestions and improvements
40
+
41
+ # RSpec files
42
+ rspec = dsl.rspec
43
+ watch(rspec.spec_helper) { rspec.spec_dir }
44
+ watch(rspec.spec_support) { rspec.spec_dir }
45
+ watch(rspec.spec_files)
46
+
47
+ # Ruby files
48
+ ruby = dsl.ruby
49
+ dsl.watch_spec_files_for(ruby.lib_files)
50
+
51
+ # Rails files
52
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
53
+ dsl.watch_spec_files_for(rails.app_files)
54
+ dsl.watch_spec_files_for(rails.views)
55
+
56
+ watch(rails.controllers) do |m|
57
+ [
58
+ rspec.spec.("routing/#{m[1]}_routing"),
59
+ rspec.spec.("controllers/#{m[1]}_controller"),
60
+ rspec.spec.("acceptance/#{m[1]}")
61
+ ]
62
+ end
63
+
64
+ # Rails config changes
65
+ watch(rails.spec_helper) { rspec.spec_dir }
66
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
67
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
68
+
69
+ # Capybara features specs
70
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
71
+ watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
72
+
73
+ # Turnip features and steps
74
+ watch(%r{^spec/acceptance/(.+)\.feature$})
75
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
76
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
77
+ end
78
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 meganemura
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.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # RSpec::GitSpecifier
2
+ [![Build Status](https://travis-ci.org/meganemura/rspec-git_specifier.svg?branch=master)](https://travis-ci.org/meganemura/rspec-git_specifier)
3
+ [![Circle CI](https://circleci.com/gh/meganemura/rspec-git_specifier/tree/master.svg?style=svg)](https://circleci.com/gh/meganemura/rspec-git_specifier/tree/master)
4
+
5
+ The collection of helper methods to test git something.
6
+
7
+ ## Usage
8
+
9
+ ```ruby
10
+ # spec_helper.rb
11
+ require 'rspec/commit_specifier'
12
+ ```
13
+
14
+ ```ruby
15
+ # repository_spec.rb
16
+ describe 'Repository' do
17
+
18
+ include RSpec::GitSpecifier # or RSpec.configuration.include RSpec::GitSpecifier
19
+ # it defines `commits` and other helper methods to test repository
20
+
21
+ describe 'commit messages' do
22
+ subject { commits.map(&:message) }
23
+
24
+ it { is_expected.to all(be) }
25
+ it { is_expected.to all(match(/\A.*(?:\n\Z|\n\n)/)) } # force second line to be blank
26
+ it { is_expected.to all(match(/\A.*[^.]\n/)) } # force first line to end with [^.]
27
+
28
+ # start with uppercase character or command
29
+ commands = %w(bundle rake rails guard sed)
30
+ it { is_expected.to all(match(/\A(?:[A-Z0-9]|#{commands.join('|')})/)) }
31
+ end
32
+
33
+ describe 'current branch name' do
34
+ subject { current_branch.name }
35
+
36
+ it { is_expected.to match(/[a-z0-9-]+/) }
37
+ end
38
+ end
39
+ ```
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |task|
5
+ task.verbose = false
6
+ end
7
+
8
+ task :ci => :spec
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rspec/git_specifier"
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
+ require "pry"
10
+ Pry.start
data/bin/setup ADDED
@@ -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
data/circle.yml ADDED
@@ -0,0 +1,11 @@
1
+ dependencies:
2
+ pre:
3
+ - git fetch --unshallow origin master || true
4
+ - git fetch origin +refs/heads/*:refs/remotes/origin/*
5
+ - git branch --verbose --all
6
+ - git remote --verbose
7
+ - gem install bundler
8
+ - bundle version
9
+ test:
10
+ override:
11
+ - bundle exec rake ci
@@ -0,0 +1,43 @@
1
+ require "rspec/git_specifier/version"
2
+ require "rugged"
3
+
4
+ module RSpec
5
+ module GitSpecifier
6
+ def repository
7
+ Rugged::Repository.discover(current_directory)
8
+ end
9
+
10
+ def current_directory
11
+ Dir.pwd
12
+ end
13
+
14
+ def commits
15
+ walker.walk
16
+ end
17
+
18
+ def walker
19
+ walker = Rugged::Walker.new(repository)
20
+ walker.sorting(Rugged::SORT_DATE | Rugged::SORT_REVERSE)
21
+ walker.push('HEAD')
22
+ walker.hide(master_object_id)
23
+ walker
24
+ end
25
+
26
+ def master_object_id
27
+ repository.ref('refs/remotes/origin/master').target_id
28
+ end
29
+
30
+ def current_branch
31
+ travis_branch || repository.branches.detect(&:head?)
32
+ end
33
+
34
+ def travis_branch
35
+ name = ENV['TRAVIS_BRANCH']
36
+ return unless name
37
+
38
+ repository.branches.detect do |branch|
39
+ branch.name == name
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ module RSpec
2
+ module GitSpecifier
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec/git_specifier/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rspec-git_specifier"
8
+ spec.version = RSpec::GitSpecifier::VERSION
9
+ spec.authors = ["meganemura"]
10
+ spec.email = ["meganemura@users.noreply.github.com"]
11
+
12
+ spec.summary = "Define RSpec helper methods to test against git repository (commits, branches, etc)."
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/meganemura/rspec-git_specifier"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_runtime_dependency "rugged"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.9"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency "guard-rspec"
29
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-git_specifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - meganemura
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rugged
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
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: rspec
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: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Define RSpec helper methods to test against git repository (commits,
98
+ branches, etc).
99
+ email:
100
+ - meganemura@users.noreply.github.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - Guardfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - circle.yml
116
+ - lib/rspec/git_specifier.rb
117
+ - lib/rspec/git_specifier/version.rb
118
+ - rspec-git_specifier.gemspec
119
+ homepage: https://github.com/meganemura/rspec-git_specifier
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.2.2
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Define RSpec helper methods to test against git repository (commits, branches,
143
+ etc).
144
+ test_files: []