Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSpec helpers #11

Open
zeevallin opened this issue Mar 17, 2015 · 1 comment
Open

RSpec helpers #11

zeevallin opened this issue Mar 17, 2015 · 1 comment

Comments

@zeevallin
Copy link
Owner

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
Copy link

ngw commented Mar 17, 2015

Seems fine to me.

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

No branches or pull requests

2 participants