zeevallin / arcane

Rails strong parameters, made object oriented.
MIT License
50 stars 4 forks source link

RSpec helpers #11

Open zeevallin opened 9 years ago

zeevallin commented 9 years ago

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?

ngw commented 9 years ago

Seems fine to me.