Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benjaminpjacobs:bjacobs/replace-ansicolor-gem #95

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/pact/matchers/embedded_diff_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
require 'pact/shared/active_support_support'
require 'term/ansicolor'
require 'rainbow'

module Pact
module Matchers
class EmbeddedDiffFormatter

include Pact::ActiveSupportSupport
C = ::Term::ANSIColor


EXPECTED = /"EXPECTED([A-Z_]*)":/

Expand Down Expand Up @@ -53,7 +51,7 @@ def colourise line
end

def coloured_key match, colour
'"' + C.color(colour, match.downcase.gsub(/^"|":$/,'')) + '":'
'"' + Rainbow(match.downcase.gsub(/^"|":$/,'')).send(colour) + '":'
end

end
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/pact.rake
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ namespace :pact do

desc "Verifies the pact at the given URI against this service provider."
task 'verify:at', :pact_uri do | t, args |
require 'term/ansicolor'
require 'rainbow'
require 'pact/tasks/task_helper'

include Pact::TaskHelper

abort(::Term::ANSIColor.red("Please provide a pact URI. eg. rake pact:verify:at[../my-consumer/spec/pacts/my_consumer-my_provider.json]")) unless args[:pact_uri]
abort(Rainbow("Please provide a pact URI. eg. rake pact:verify:at[../my-consumer/spec/pacts/my_consumer-my_provider.json]").red) unless args[:pact_uri]
handle_verification_failure do
execute_pact_verify args[:pact_uri]
end
Expand Down
2 changes: 1 addition & 1 deletion pact-support.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
spec.files = `git ls-files lib CHANGELOG.md LICENSE.txt README.md`.split($RS)
spec.require_paths = ["lib"]

spec.add_runtime_dependency "term-ansicolor", "~> 1.0"
spec.add_runtime_dependency "rainbow", "~> 3.1.1"
spec.add_runtime_dependency "awesome_print", "~> 1.9"
spec.add_runtime_dependency "diff-lcs", "~> 1.4"
spec.add_runtime_dependency "expgen", "~> 0.1"
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/pact/matchers/embedded_diff_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ module Matchers
subject { EmbeddedDiffFormatter.call(diff, options) }

let(:options) { { colour: colour }}
let(:expected_coloured) { '"' + ::Term::ANSIColor.red("expected_type") + '":'}
let(:actual_coloured) { '"' + ::Term::ANSIColor.green("actual_type") + '":'}
let(:expected_coloured) { '"' + Rainbow("expected_type").red + '":'}
let(:actual_coloured) { '"' + Rainbow("actual_type").green + '":'}

describe ".call" do

Expand Down