levaleureux / dr_spec

rspec like for dragonruby
The Unlicense
0 stars 2 forks source link

Initial implementation of shared examples #40

Closed ekiru closed 1 year ago

ekiru commented 1 year ago

Currently it only implements shared_examples, include_examples, and it_behaves_like. Shared example groups are also currently not scoped to a context and can be included from other contexts; I took this approach because iiuc there's not a good way to e.g. define them in a module and include the module where you need them in dr_spec yet (which I think is an approach sometimes used in RSpec).

My implementation approach is to essentially create a parent-less context that gets stored in the @shared_examples hash. When including them, that context gets copied in as a subcontext (prepending parent befores/afters to its own) or has its tests/etc. added to the current context.

It's currently in the core.rb file since I hadn't initially pulled the commit that split that file up, but I can pull it into a separate file if you'd like.

levaleureux commented 1 year ago

My first PR in an open-source project !! :heart_eyes: Thank you so much :)

The code look good to me. I will test it on my local before merge today. The only point I saw missing it that there no test about instance variable or test with args. But that something that we can add on future PR.

levaleureux commented 1 year ago

Test work on my local. PR aprove. Thank to be my first contributor as feature write, I really appreciate.