kan icon indicating copy to clipboard operation
kan copied to clipboard

Question: rspec matchers for testing?

Open davydovanton opened this issue 8 years ago • 7 comments

davydovanton avatar Jan 27 '18 00:01 davydovanton

I would like to work on this, any suggestion at first?

berniechiu avatar Feb 02 '18 02:02 berniechiu

thanks for help! About suggestions: no idea. We can create some matchers for abilities and roles, WDYT? Also, we can check pundit or cancancan projects for inspiration 🤔

davydovanton avatar Feb 06 '18 08:02 davydovanton

Here's the first phase of PR i've done, lack of some functionalities but I think it's quite useful https://github.com/davydovanton/kan/pull/15

berniechiu avatar Feb 09 '18 16:02 berniechiu

After #15:

  • [x] allow #permit to take ability name + payload for testing. Something like this:
expect(subject).not_to permit('post.edit', user, post)
  • [x] Update README file and add information how to inject matchers and use it.

davydovanton avatar Feb 10 '18 12:02 davydovanton

Just added here https://github.com/davydovanton/kan/pull/16 ❤️

After finished it, I bumped into some issues, I think can change it

  • The abilities classes used in different files are actually shared, even though it looks like just defining a new one, which might cause different spec tests failing if changed unintentionally, maybe can use Struct to init them ?

berniechiu avatar Feb 12 '18 00:02 berniechiu

@berniechiu not sure that I understand correct, could you explain little bit more why you want to use Struct?

davydovanton avatar Mar 10 '18 10:03 davydovanton

Oh! Other solutions are ok, just that the classes are re-opened in each spec file, which looks weird since each spec file supposedly is using the test class individually.

berniechiu avatar Mar 19 '18 05:03 berniechiu