Skip to content

Instantly share code, notes, and snippets.

@avdi
Created May 15, 2012 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save avdi/2705101 to your computer and use it in GitHub Desktop.
Save avdi/2705101 to your computer and use it in GitHub Desktop.
describe Article do
subject
def article; Article.new; end
it "validates presence of :title" do
article.should validate_presence_of(:title)
end
end
@myronmarston
Copy link

FWIW, you can already do this:

describe Article do
  let(:article) { Article.new }
  subject { article }
end

This gives you the subject/named-thing duality you're looking for, and requires less "magic" than the above (which would need a method_added hook, right?). And it already works!

@dchelimsky
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment