File: trait.rb

package info (click to toggle)
ruby-factory-bot 6.5.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,492 kB
  • sloc: ruby: 9,242; makefile: 6; sh: 4
file content (11 lines) | stat: -rw-r--r-- 260 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
RSpec::Matchers.define :have_trait do |trait_name|
  match do |instance|
    instance.defined_traits.any? do |trait|
      trait.name == trait_name.to_s && trait.send(:block) == @block
    end
  end

  chain :with_block do |block|
    @block = block
  end
end