first of all, thank you very much for this gem. It already helped me a lot on past projects, and it's helping me again :)
On a current project, I noticed that I wanted to do a quick check on classes and instances of those classes to see if they were acting as/actables of a certain class or symbol, so I dig up your specs and saw that you have some nice boolean methods (#acting_as? + .acting_as? + .actable?) to verify that. Do you think it's interesting adding some custom matchers to the library to help people out writing specs?
Example:
# Sample rails_helper.rb
require 'rspec/acts_as_matchers'
# acts_as_matchers.rb
RSpec::Matchers.define :acts_as do |actable|
match { |actor| actor.acting_as?(actable) }
end
RSpec::Matchers.define :be_actable do
match { |instance| instance.class.actable? }
end
And then on specs, people would have available the following interfaces:
it { is_expected.to acts_as(:account) }
it { expect(Person).to acts_as(:account) }
it { is_expected.to acts_as(Account) }
it { expect(Person).to acts_as(Account) }
it { expect(described_class).to be_actable }
What do you think? :)
If you like the idea, I can open a PR with those changes right away. If not, I'll just close the issue.
Hey @hzamani,
first of all, thank you very much for this gem. It already helped me a lot on past projects, and it's helping me again :)
On a current project, I noticed that I wanted to do a quick check on classes and instances of those classes to see if they were acting as/actables of a certain class or symbol, so I dig up your specs and saw that you have some nice boolean methods (
#acting_as?
+.acting_as?
+.actable?
) to verify that. Do you think it's interesting adding some custom matchers to the library to help people out writing specs?Example:
And then on specs, people would have available the following interfaces:
What do you think? :)
If you like the idea, I can open a PR with those changes right away. If not, I'll just close the issue.