Skip to content

Instantly share code, notes, and snippets.

View diegorv's full-sized avatar

Diego Rossini diegorv

View GitHub Profile
#require 'simplecov'
#SimpleCov.start 'rails'
require 'rubygems'
#require 'spork'
#Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
class Client < ActiveRecord::Base
has_many :client_companies, :dependent => :destroy
has_many :contracts , :dependent => :destroy
accepts_nested_attributes_for :client_companies , :allow_destroy => true
end
class ClientCompany < ActiveRecord::Base
belongs_to :client
@diegorv
diegorv / have_named_scope.rb
Created August 24, 2011 19:37 — forked from bcardarella/have_named_scope.rb
Should Have Named Scope matcher for Rspec
module Shoulda # :nodoc:
module ActiveRecord # :nodoc:
# Examples:
# class Book < ActiveRecord::Base
# named_scope :test, :conditions => { :name => "test" }
# named_scope :by_name, lambda { |n| { :conditions => { :name => n} } }
# end
#
# RSpec:
@diegorv
diegorv / allow.rb
Created July 14, 2011 02:09 — forked from fnando/allow.rb
RSpec matcher
RSpec::Matchers.define :allow do |*values|
match do |record|
values.collect {|value|
record.send("#{@attribute}=", value)
record.valid?
record.errors[@attribute].empty?
}.all?
end
chain :as do |attribute|
# bash_completion - programmable completion functions for bash 3.x
# (backwards compatible with bash 2.05b)
#
# $Id: bash_completion,v 1.872 2006/03/01 16:20:18 ianmacd Exp $
#
# Copyright (C) Ian Macdonald <ian@caliban.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
$ cucumber --backtrace --verbose --tags @bank_account
Using the default profile...
Code:
* features/support/env.rb
* features/support/paths.rb
* features/step_definitions/base_steps.rb
* features/step_definitions/web_steps.rb
* features/step_definitions/web_steps_pt-br.rb
Features:
$ cucumber --backtrace --verbose --tags @bank_accountUsing the default profile...
Code:
* features/support/env.rb
* features/support/paths.rb
* features/step_definitions/base_steps.rb
* features/step_definitions/web_steps.rb
* features/step_definitions/web_steps_pt-br.rb
Features:
* features/admin/admin_bank_accounts.feature
source 'http://rubygems.org'
gem 'rails', '3.0.0.rc'
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# ----------------------------------------------------------------------- #
# Default
gem 'inherited_resources', '1.1.2'
gem 'will_paginate', "~> 3.0.pre2"
class RoleSets
role :admin do
can :manage, :all
end
role :diretoria do
can [:read, :edit], [Post]
end
role :maluco do
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'shoulda'
require 'webrat'
require 'factory_girl'
require 'test/factories/clearance'
require 'clearance/../../shoulda_macros/clearance'
require 'cucumber/rails/world'
Cucumber::Rails.use_transactional_fixtures