hamcrest / ramcrest

Hamcrest in Ruby
56 stars 8 forks source link

RSpec integration #6

Open zaphod42 opened 12 years ago

zaphod42 commented 12 years ago

The matchers need to be used with RSpec. This will somehow involve getting RSpec to be able to call the matchers and report the results.

There is also the question about how the matchers will read with the RSpec syntax. I don't think something.should has_property(:foo) is the greatest. The problem comes from the different part of speech that RSpec puts the matcher in.

zaphod42 commented 12 years ago

Have basic integration using expect(something).that has_property(:foo). Next is to consider rspec mock integration. Since I don't use those, I'll have to figure out how they work.

zaphod42 commented 12 years ago

RSpec::Mocks::ArgumentMatchers shows the interface for rspec mock matchers. It comes down to having a

def ==(value)
end

Once way of doing this is creating a that(matcher) which gets mixed in with the other rspec mock matchers. This that method would then wrap the matcher in another matcher that just implements the == method.

Doing it this way would also provide a place for integrating with mocha if the returned object also implemented a matches? method.