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
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.Thoughts @ngw?