Skip to content

Instantly share code, notes, and snippets.

@shotty01
shotty01 / application_helper.rb
Last active December 15, 2015 20:19
my try for a working helper spec with devise and cancan. all tests pass but I'm still not happy about it. My worries are in the comments! --> changed from revision 3 to 7 to a shared_example and matcher usage. Revision 8 groups the shared examples together. Wording now better.
module ApplicationHelper
def link_to_sprite(sprite_class, url_or_object, options={})
link_to url_or_object, options do
content_tag :i, :class => sprite_class do end
end
end
def render_button(obj, right, display, url_or_object, options={})
if can? right, obj
@shotty01
shotty01 / new.html.erb_spec.rb
Last active December 15, 2015 20:29
view spec for the create form of a user. it's passing. not using factory_girl and devise. Maybe that's wrong? previous version was webrat syntax. this version is capybara syntax. refactored a bit
require 'spec_helper'
require 'shared_examples_for_views'
describe "users/new" do
#generalized method to check a field
def check_field(form, id, options={})
field = form.find_field(id)
options.keys.each do |key|
field[key].should eq options[key].to_s
@shotty01
shotty01 / factories.rb
Last active December 15, 2015 20:29
view template rspec file - working. Switched to factory girl for data
FactoryGirl.define do
factory :user do
login "login"
firstname Faker::Name.first_name
lastname Faker::Name.last_name
end
end