Skip to content

Instantly share code, notes, and snippets.

@croaky
Forked from jferris/shoulda_goals.textile
Created February 11, 2010 15:48
Show Gist options
  • Save croaky/301635 to your computer and use it in GitHub Desktop.
Save croaky/301635 to your computer and use it in GitHub Desktop.

The problem is that it's hard to achieve the same result as Shoulda/Remarkable matchers using only RSpec:

it {
  user = User.new
  user.should be_invalid
  user.errors[:email].should include("can't be blank")
}

It would be nice however, if we provide something like this:

it { User.new.should be_invalid.with(:email => "can't be blank") }

That, as we know, in this simple case, can be just:

it { should be_invalid.with(:email => "can't be blank") }

For the other examples, it requires that you actually input some values:

it { User.new(:email => "a@a").should be_invalid.with(:email => "a@a") }

In the example above, we repeat :email twice, so there is room for improvement.

Goals:

  • Unify syntax (no more should_* methods if possible)
  • Make matchers less tied to the framework
  • Move towards rspec
  • Remain fully backwards-compatible for now (with deprecation warnings)
  • Remain compatible with Test::Unit for now (no deprecation warnings)
  • Look into deprecating context framework (create separate project)
  • Remove remaining string evals
  • Try and come up with a (hopefully non-invasive) Test::Unit syntax for using matchers
  • Look towards Rails 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment