test_changes 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a999841b6f326deba13cc4be0bf981f008cc5140
4
- data.tar.gz: 8e114720be8c3ce34f4b923625b6241d746ff8fe
3
+ metadata.gz: d706999477bb9b59090625e9fe646702fc744ce7
4
+ data.tar.gz: c892a055438367a3b58936fdd33d0354bf821d18
5
5
  SHA512:
6
- metadata.gz: 6925132e8fff59a6f81998fbf9b641bcc99de788f8ee21dd67bdda53a0343cb6f6af6c71f5cd6660483ffe55280414012190dc737f5a1104ce9b435075427e10
7
- data.tar.gz: cc6b4a0ba1c303c8aedb531c4cb25dd970d35146ba87230564f2e86e2e39df84c9eb28781b01419b05c8a6e3a453809bc8e5c8367d9496f3f2ef62c69bb2797f
6
+ metadata.gz: 78a39c46163217fea3b393a96655d20cdb7a6066dfec21711e57e048529acce0ef6be15a2ce0a9f570a7e05f4075716b63c74db948799a751a465cfcb5a77bc7
7
+ data.tar.gz: 1822de2d1711f7fd48582b560df865e6eb18ee0c3055eaf6bc94a5196ae1b59d0178f8b44e4e26278991e5312805add64c0ad8f5f6746d3aa3bdc51a5de2a892
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
- language: ruby
1
+ script: bundle exec rspec
2
2
  rvm:
3
3
  - 2.0.0
4
+ cache: bundler
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ ## master
2
+
3
+ ## 0.1.1
4
+
5
+ * Infer configuration automatically (#2 @rstacruz).
6
+
7
+ ## 0.1.0
8
+
9
+ * First release.
data/README.md CHANGED
@@ -84,6 +84,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
84
84
 
85
85
  ## Contributing
86
86
 
87
+ IMPORTANT: Please use [RuboCop](https://github.com/bbatsov/rubocop) and [Overcommit](https://github.com/brigade/overcommit) when submitting pull requests.
88
+
87
89
  1. Fork it ( https://github.com/gsmendoza/test_changes/fork )
88
90
  2. Create your feature branch (`git checkout -b my-new-feature`)
89
91
  3. Commit your changes (`git commit -am 'Add some feature'`)
data/exe/test_changes CHANGED
@@ -3,9 +3,12 @@
3
3
  require 'test_changes/argv_wrapper'
4
4
  require 'test_changes/client'
5
5
  require 'test_changes/config'
6
+ require 'test_changes/inferred_config'
7
+ require 'test_changes/config_setup_service'
6
8
 
7
9
  argv_wrapper = TestChanges::ARGVWrapper.new(ARGV)
8
- config = TestChanges::Config.new('.test_changes.yaml')
10
+
11
+ config = TestChanges::ConfigSetupService.call
9
12
 
10
13
  client = TestChanges::Client.new(
11
14
  test_tool_command: config.test_tool_command,
@@ -1,3 +1,4 @@
1
+ require 'test_changes/finding_pattern'
1
2
  require 'yaml'
2
3
 
3
4
  module TestChanges
@@ -6,13 +7,12 @@ module TestChanges
6
7
  @config_path = config_path
7
8
  end
8
9
 
10
+ def exists?
11
+ File.exist?(@config_path)
12
+ end
13
+
9
14
  def finding_patterns
10
- config['finding_patterns'].map do |pattern, substitution_patterns|
11
- FindingPattern.new(
12
- matching_pattern: /#{pattern}/,
13
- substitution_patterns: [substitution_patterns].flatten
14
- )
15
- end
15
+ FindingPattern.build config['finding_patterns']
16
16
  end
17
17
 
18
18
  def test_tool_command
@@ -0,0 +1,43 @@
1
+ require 'test_changes/inferred_config'
2
+
3
+ module TestChanges
4
+ module ConfigSetupService
5
+ def self.call
6
+ config = Config.new('.test_changes.yaml')
7
+
8
+ return config if config.exists?
9
+
10
+ if File.exist?('./config/application.rb')
11
+ return use_rspec_rails('./bin/rspec') if File.exist?('./bin/rspec')
12
+ return use_rspec_rails('bundle exec rspec') if File.directory?('./spec')
13
+ return use_testunit_rails('bundle exec ruby -Itest') if File.directory?('./test')
14
+ end
15
+
16
+ fail TestChanges::Error, "No .test_changes.yaml found"
17
+ end
18
+
19
+ private
20
+
21
+ def self.use_rspec_rails(bin)
22
+ InferredConfig.new(
23
+ test_tool_command: bin,
24
+ project_type_name: 'rspec_rails',
25
+ finding_patterns_map: {
26
+ '^app/(models)/(.+).rb' => 'spec/\1/\2_spec.rb',
27
+ '^app/(controller|helper|view)s/(.+).rb' => 'spec/controllers/\2_\1_spec.rb'
28
+ }
29
+ )
30
+ end
31
+
32
+ def self.use_testunit_rails(bin)
33
+ InferredConfig.new(
34
+ test_tool_command: bin,
35
+ project_type_name: 'testunit_rails',
36
+ finding_patterns_map: {
37
+ '^app/(models)/(.+).rb' => 'test/\1/\2_test.rb',
38
+ '^app/(controller|helper|view)s/(.+).rb' => 'test/controllers/\2_\1_test.rb'
39
+ }
40
+ )
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module TestChanges
2
+ Error = Class.new(StandardError)
3
+ end
@@ -15,6 +15,15 @@ module TestChanges
15
15
  results.compact
16
16
  end
17
17
 
18
+ def self.build(patterns)
19
+ patterns.map do |pattern, substitution_patterns|
20
+ new(
21
+ matching_pattern: /#{pattern}/,
22
+ substitution_patterns: [substitution_patterns].flatten
23
+ )
24
+ end
25
+ end
26
+
18
27
  private
19
28
 
20
29
  def matches?(path)
@@ -0,0 +1,25 @@
1
+ require 'test_changes/error'
2
+
3
+ module TestChanges
4
+ class InferredConfig
5
+ attr_reader :finding_patterns_map
6
+ attr_reader :test_tool_command
7
+ attr_reader :project_type_name
8
+
9
+ def initialize(test_tool_command: nil,
10
+ project_type_name: nil, finding_patterns_map: nil)
11
+
12
+ @test_tool_command = test_tool_command
13
+ @project_type_name = project_type_name
14
+ @finding_patterns_map = finding_patterns_map
15
+ end
16
+
17
+ def finding_patterns
18
+ FindingPattern.build finding_patterns_map
19
+ end
20
+
21
+ def verbose
22
+ true
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module TestChanges
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/test_changes.gemspec CHANGED
@@ -25,7 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
27
 
28
- spec.add_development_dependency "bundler", "~> 1.8"
29
28
  spec.add_development_dependency "pry"
30
29
  spec.add_development_dependency "rake", "~> 10.0"
31
30
  spec.add_development_dependency "rspec"
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_changes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Mendoza
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-21 00:00:00.000000000 Z
11
+ date: 2015-06-22 00:00:00.000000000 Z
12
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.8'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.8'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: pry
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +66,7 @@ files:
80
66
  - ".rubocop.yml"
81
67
  - ".test_changes.yaml"
82
68
  - ".travis.yml"
69
+ - CHANGELOG.md
83
70
  - CODE_OF_CONDUCT.md
84
71
  - Gemfile
85
72
  - LICENSE.txt
@@ -92,7 +79,10 @@ files:
92
79
  - lib/test_changes/argv_wrapper.rb
93
80
  - lib/test_changes/client.rb
94
81
  - lib/test_changes/config.rb
82
+ - lib/test_changes/config_setup_service.rb
83
+ - lib/test_changes/error.rb
95
84
  - lib/test_changes/finding_pattern.rb
85
+ - lib/test_changes/inferred_config.rb
96
86
  - lib/test_changes/version.rb
97
87
  - test_changes.gemspec
98
88
  homepage: https://github.com/gsmendoza/test_changes