matchers

Hamcrest's hasItems

Why does this not compile, oh, what to do? import static org.junit.Assert.assertThat; import static org.junit.matchers.JUnitMatchers.hasItems; ArrayList<Integer> actual = new ArrayList<Integer>(); ArrayList<Integer> expected = new ArrayList<Integer>(); actual.add(1); expected.add(2); assertThat(actual, hasItems(expected)); error copi...

Using pickle with cucumber and factory_girl to create associated models and pass parameters through to the nested model

I have the following models: class User < ActiveRecord::Base has_one :profile, :dependent => :destroy def before_create self.profile ||= Profile.new end end class Profile < ActiveRecord::Base belongs_to :user validates_uniqueness_of :name end And I have the following factories: Factory.define :user do |user| ...

How to compose a Matcher[Iterable[A]] from a Matcher[A] with specs testing framework

If I have a Matcher[A] how do create a Matcher[Iterable[A]] that is satisfied only if each element of the Iterable satisfies the original Matcher. class ExampleSpec extends Specification { def allSatisfy[A](m: => Matcher[A]): Matcher[Iterable[A]] = error("TODO") def notAllSatisfy[A](m: => Matcher[A]): Matcher[Iterable[A]] = allSati...