zenspider / minitest-matchers

33 stars 7 forks source link

Refactoring - 1.1.0 #3

Closed wojtekmach closed 12 years ago

wojtekmach commented 12 years ago

Hi,

@zenspider, @bcardarella: since you are of few people who actually used this thing I'll love your feedback

I made some important changes:

At the end of the day you can use it just like in RSpec (which is kinda cool thing to accomplish):

describe Post do
  it { must have_valid(:title).when("Good") }
end
dstrelau commented 12 years ago

Can I ask why the class level must and wont went away? I just ended up adding something like this to a project to avoid having to always nest inside it { … }.

def it_must(matcher)
  it { must(matcher) }
end
wojtekmach commented 12 years ago

I figured it would be better to have only one way to specify matchers, on the instance level. Maybe I didn't think that through, or at least I should have provide compatibility with older release. You propably want this:

  def self.it_must(&block) # or just self.must
    it { subject.must instance_eval(&block) }
  end

Also, it's already released so I'm closing this.