arcane icon indicating copy to clipboard operation
arcane copied to clipboard

RSpec helpers

Open zeevallin opened this issue 10 years ago • 1 comments

I've been thinking about how the RSpec helpers would look. I think it would be wise setting an explicit expectation of what the #refine method returns.

RSpec.describe ArticlesController do
  it "refines article parameters" do
    get :create, { title: "Hello", body: "World", published: true, tags: ["blog"] }
    expect(subject).to refine(:article).as({ title: "Hello", body: "World", tags: ["blog"] })
  end
end
class ArticleRefinery < Struct.new(:object,:user)
  def create
    [:title, :content, tags: []]
  end
end
class ArticlesController < ActionController::Base
  include Arcane
  def create
    @article = Article.create params.for(Article).refine
  end
end

Thoughts @ngw?

zeevallin avatar Mar 17 '15 01:03 zeevallin

Seems fine to me.

ngw avatar Mar 17 '15 10:03 ngw