Comments (7)
Just to note, I suggested .set_color_scheme
method name as it (for my taste, at least) is a bit more aligned with . add_extra_differ_class
and other already used configuration methods.
Regarding passing hashes and encouraging users to merge values into them: it's nice and simple solution. A downside: users could rely on the fact that it's a hash, making major changes to color scheme functionalities more difficult.
from super_diff.
Not sure why I got confused here. It already works like I thought it did.
from super_diff.
Reopening this. It feels like more often than not, the actual value is more important than the expected value, so it should jump out more when looking at the output. This will cause the diff to look weird, though, so maybe not?
from super_diff.
This is what Jest does, for reference:
from super_diff.
Maybe worth looking at Ava too: https://github.com/avajs/ava#magic-assert
from super_diff.
Would it make sense to make this configurable? Thus, the cost of the decision for the question in the title wouldn't be that high, because end users would be able to adjust color scheme to their preference if they'd like to.
For example, something like this:
SuperDiff.configure do |config|
config.set_color_scheme(SuperDiff::ColorSchemes::RedGreen)
# or MagentaYellow, or YellowMagenta
end
With schemes defined either similar to as they do now:
module MagentaYellow
COLORS = {
alpha: :magenta,
beta: :yellow,
border: :blue,
header: :white,
}.freeze
end
or without relying on hashes:
module MagentaYellow
def self.alpha
:magenta
end
def self.beta
:yellow
end
def self.border
:blue
end
def self.header
:white
end
end
As another option, set_color_scheme
could accept symbol instead of a module as an argument. That approach would be less verbose, but less extensible.
from super_diff.
Yeah, that's a good point, perhaps the user is the best judge here. I like the idea of passing a module. Or perhaps just a hash?
SuperDiff.configure do |config|
config.color_scheme = SuperDiff::ColorSchemes.red_green
# or magenta_yellow, or yellow_magenta... or supply your own
end
or if you wanted to change a couple of settings on the fly, you could even do:
SuperDiff.configure do |config|
# color_scheme is set to red_green by default
config.color_scheme.merge!(alpha: :magenta, beta: :yellow)
end
from super_diff.
Related Issues (20)
- Make a video walkthrough of the internals (with perhaps a better diagram)
- Add a disclaimer about `include`, `contain_exactly`, and `match_array`
- Don't show diff if comparing with an empty collection
- CI takes a very long time to run HOT 1
- Make it easier to run all tests across all appraisals locally
- Failed Assertions on Date Instances Do Not Output a Diff HOT 4
- Rails 7 Assertion on ActionDispatch::TestResponse: undefined method `keys' for nil:NilClass HOT 4
- If a trailing newline is missing from actual vs. expected, it is not shown in the diff
- Take a look at Concordance
- How to Enable the Diff Based on a Tag
- NoMethodError when matcher is passed to `raise_error`
- controller test broken: eval error: undefined method `keys' for nil:NilClass HOT 3
- super_diff removes most rspec color output when run with parallel_tests HOT 2
- Premature calculation of `actual` description when generating matcher description
- Support for diffing message expectations? HOT 1
- wrong number of arguments HOT 2
- Less color output + no diff when using super_diff
- Add literate documentation
- undefined method error in previously working rspecs HOT 3
- Use difftastic internally?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from super_diff.