Skip to content

Instantly share code, notes, and snippets.

@michaelrkn
Last active December 15, 2015 03:59
Show Gist options
  • Select an option

  • Save michaelrkn/5198450 to your computer and use it in GitHub Desktop.

Select an option

Save michaelrkn/5198450 to your computer and use it in GitHub Desktop.
active model validations
require 'active_model'
class Foo
include ActiveModel::Validations
attr_accessor :name
validates :name, :presence => true
def initialize(options={})
@name = options[:name]
end
end
require './foo'
require 'rspec'
require 'shoulda-matchers'
describe Foo do
it {should validate_presence_of :name}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment