Skip to content

Instantly share code, notes, and snippets.

@adamstrickland
Last active December 15, 2015 11:49
Show Gist options
  • Save adamstrickland/5256337 to your computer and use it in GitHub Desktop.
Save adamstrickland/5256337 to your computer and use it in GitHub Desktop.
A shared context for RSpec'ing Apotomo Widgets with Devise mixed in
shared_context "widget" do
let(:widget_klass) { self.described_class }
let(:widget_name) { widget_klass.to_s.underscore.gsub(/_widget/, '') }
let(:widget_instance) { root.find_widget(widget_name) }
let(:current_user) { create(:user) }
before {
self.class.has_widgets do |r|
r << widget(widget_name)
end
widget_instance.instance_variable_set(:@current_user, current_user)
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment