Comments (5)
Thinking about this some more, it would be cool if we set up a persistent Ruby instance that would start when the test suite starts and shuts down when it exits. That instance could expose some kind of API to load a file and then run that file. That could be a nice way of speeding things up without creating a Frankenstein.
from super_diff.
Take a closer look at how Spring is implemented. I'm thinking we could build something like that — a separate program that sits open on a socket, and when it receives a message it runs some Ruby code and then waits for another message. And when the main program exits it kills the other process.
from super_diff.
Probably something like this piece of code could be used to run arbitrary RSpec tests:
group = RSpec.describe('test') { it { expect(1).to eq 2 } }
runner = RSpec::Core::Runner.new({}, RSpec::Core::Configuration.new, RSpec::Core::World.new)
runner.run_specs([group])
This is based on what is actually used in RSpec:
- https://github.com/rspec/rspec-core/blob/main/lib/rspec/core/runner.rb#L75
- https://github.com/rspec/rspec-core/blob/main/lib/rspec/core/runner.rb#L113
Building new instances of RSpec's Configuration
and World
are required so that each test is executed in isolation. Without that, each launched example would be persisted and executed in subsequent runs, too.
from super_diff.
Hmm, interesting. Ideally I'd like each test to be fully sandboxed to remove the possibility of global state or, more importantly, be able to replicate specific setups (such as projects that require Rails, projects that only require ActiveRecord, projects that only require ActiveSupport, etc.). I'm worried that being able to run arbitrary tests like that wouldn't fully solve that problem.
from super_diff.
An alternative solution could be following:
- make several
spec_helper
files, likespec_helper_bare.rb
,spec_helper_rails.rb
,spec_helper_activerecord.rb
, and require (or not) corresponding things in them accordingly; - mark tests which have to be run under specific setup with RSpec tags;
- with that, you'd be able to run rspec with different setups;
- launch built-on-the-fly examples inside your examples and catch the output.
On the one hand, this goes against "fully sandboxed" approach, because those temporary examples would share the same Ruby env as outer tests of super_diff
itself (but another RSpec World). On the other, it would remove the need to spin up a separate Ruby process at all. Thus, you could use it for most of the integration tests (meaning integration with RSpec) to get faster tests; and keep several end-to-end tests with generating temporary apps to get full sandboxing and representativeness.
To clarify a bit what I mean, here's a possible resulting code:
# before
snippet = %|expect(double).to respond_to(:foo)|
program = make_plain_test_program(snippet)
expect(program).to produce_output_when_run(expected_output)
# after
rspec = build_rspec_group { expect(double).to respond_to(:foo) }
expect(rspec).to produce_output_when_executed_inline(expected_output)
RSpec has output matching functionality, it could be used in such setup.
from super_diff.
Related Issues (20)
- Diff of Range objects is less useful than default RSpec output HOT 1
- Align keys/values in objects?
- Breaks RSpec extra failure lines support HOT 2
- Unexpected error : unable to convert unpermitted parameters to hash HOT 9
- RSpec hanging when matching on http response HOT 4
- undefined method `keys' for nil:NilClass in request specs HOT 3
- A failing spec with expect(value).to eq 1.0 raises JSON::ParserError HOT 3
- raise error when using custom matcher HOT 2
- Hide color escape chars in non-TTY HOT 1
- Option to disable the key (legend) HOT 2
- Update elision logic to show number of lines omitted
- Add documentation for `attributes_for_super_diff`
- 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
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.