pretty-diffs 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c2aafe36b6f7cbb663cb2107ad6e1aad190e6e57
4
+ data.tar.gz: 2ab5034192960b730f7ed94a199c6f01d09918be
5
+ SHA512:
6
+ metadata.gz: c37877e9026a4a73d54d6d38a8381b15e2c77afb43534be2adfa07306dab9ee766c3db69664f31ed97900fad01b1a9d3f1b7f5ea5e4c442389ed2ba8f30a0d70
7
+ data.tar.gz: 62a8326fd86410031579fd090fb5c827ab14cfe84b22f96362b63d55a7792d0dc170432dd9a05adccfef825b400536186eafd4d17bd6882197b24c552ad9a184
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ # Created by .ignore support plugin (hsz.mobi)
2
+ .idea
3
+
4
+ .idea/workspace.xml
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at angelkar@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in minitest-colored-diffs.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pretty-diffs (1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ minitest (5.9.0)
10
+ rake (10.5.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ bundler (~> 1.11)
17
+ minitest (~> 5.0)
18
+ pretty-diffs!
19
+ rake (~> 10.0)
20
+
21
+ BUNDLED WITH
22
+ 1.11.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Angelos Karagkiozidis
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,77 @@
1
+ # PrettyDiffs
2
+
3
+ When you make assertions between large strings with minitest, for example JSON responses, it is laborious to identify what has changed. The usual workflow involves copy-pasting the output into a diff tool; a rather boring and time-consuming process.
4
+
5
+ Minitest chooses to compare strings using `diff`, which is line-oriented. However, 99% of the time, we do not intend to compare lines, we want just the words.
6
+
7
+ PrettyDiffs is a tool that supports this desire by overriding the default minitest method, and relieves our workflow.
8
+ ### Default Diff output
9
+ ![before](./images/before.png)
10
+
11
+ ### Diff output using PrettyDiffs
12
+ ![after](./images/after.png)
13
+
14
+ ## Installation
15
+
16
+ ### Install [wdiff](https://www.gnu.org/software/wdiff/) on your system:
17
+ Wdiff is a wrapper around diff, it works by creating two temporary files, one word per line, and then executes diff on these files. It collects the diff output and uses it to produce a nicer display of word differences between the original files.
18
+
19
+ ```
20
+ # mac
21
+ $ brew install wdiff 
22
+
23
+ # linux
24
+ $ apt get-install wdiff 
25
+ ```
26
+
27
+ ### Install the PrettyDiffs module:
28
+
29
+ Add this line to your application's Gemfile:
30
+
31
+ ```ruby
32
+ group :test do
33
+ gem 'pretty_diffs'
34
+ end
35
+ ```
36
+
37
+ And then execute:
38
+
39
+ ```
40
+ $ bundle
41
+ ```
42
+
43
+ Or install it yourself as:
44
+
45
+ ```
46
+ $ gem install pretty_diffs
47
+ ```
48
+
49
+ ## Usage
50
+ Include the module in the Minitest classes to trigger the pretty diffs:
51
+
52
+ ```ruby
53
+ require 'pretty_diffs'
54
+
55
+ module ActiveSupport
56
+ 
 class TestCase
57
+ include PrettyDiffs
58
+
59
+ end
60
+ end
61
+ ```
62
+
63
+ ### Get the previous output back!
64
+ In this rare case, set the following ENV variable:
65
+
66
+ ```
67
+ MINITEST_PLAIN_BORING_DIFF='yes'
68
+ ```
69
+
70
+
71
+ ## Contributing
72
+
73
+ 1. Fork it
74
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
75
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
76
+ 4. Push to the branch (`git push origin my-new-feature`)
77
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "minitest/colored/diffs"
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
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/images/after.png ADDED
Binary file
data/images/before.png ADDED
Binary file
@@ -0,0 +1,3 @@
1
+ module PrettyDiffs
2
+ VERSION = "1.0.1"
3
+ end
@@ -0,0 +1,34 @@
1
+ require "pretty_diffs/version"
2
+
3
+ module PrettyDiffs
4
+ # RED = '\033[0;31m'
5
+ # GREEN = '\033[0;32m'
6
+ # NO_COLOR = '\033[0m'
7
+
8
+ def self.included(base)
9
+ base.class_eval do
10
+ base.extend ClassMethods
11
+ base.enforce_pretty_diffs
12
+ end
13
+ end
14
+
15
+ module ClassMethods
16
+ def enforce_pretty_diffs
17
+ if verify_wdiff_in_path && !boring_diffs?
18
+ enforce_color_diffs
19
+ end
20
+ end
21
+
22
+ def enforce_color_diffs
23
+ Minitest::Assertions.diff = "wdiff -n -w '\033[0;31m' -x '\033[0m' -y '\033[0;32m' -z '\033[0m'"
24
+ end
25
+
26
+ def verify_wdiff_in_path
27
+ %x{which wdiff}.present?
28
+ end
29
+
30
+ def boring_diffs?
31
+ ENV['MINITEST_PLAIN_BORING_DIFF'] == 'yes'
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pretty_diffs/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pretty-diffs"
8
+ spec.version = PrettyDiffs::VERSION
9
+ spec.authors = ["Angelos Karagkiozidis"]
10
+ spec.email = ["angelkar@gmail.com"]
11
+
12
+ spec.summary = %q{Enable colored diffs in minitest.}
13
+ spec.description = %q{A simple ruby module to enable conventiently colored diffs in your minitest suite.}
14
+ spec.homepage = "https://github.com/angelkar/pretty-diffs"
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_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "minitest", "~> 5.0"
25
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pretty-diffs
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Angelos Karagkiozidis
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-12 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: A simple ruby module to enable conventiently colored diffs in your minitest
56
+ suite.
57
+ email:
58
+ - angelkar@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - CODE_OF_CONDUCT.md
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - images/after.png
73
+ - images/before.png
74
+ - lib/pretty_diffs.rb
75
+ - lib/pretty_diffs/version.rb
76
+ - pretty-diffs.gemspec
77
+ homepage: https://github.com/angelkar/pretty-diffs
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.6.7
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Enable colored diffs in minitest.
101
+ test_files: []
102
+ has_rdoc: