Skip to content

Instantly share code, notes, and snippets.

@stevenabrooks
Created July 8, 2013 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenabrooks/5951815 to your computer and use it in GitHub Desktop.
Save stevenabrooks/5951815 to your computer and use it in GitHub Desktop.
require 'fis/test'
include Fis::Test
class Dog
attr_accessor :name, :species, :colors, :fur_length
def initialize(attributes_hash)
attributes_hash.each { |k,v| self.send ("#{k}=").to_sym, v }
end
end
#############
# Testbench #
#############
test 'can mass assign' do
d = Dog.new(:name => "Avi")
assert_equal d.name, "Avi"
end
test 'can mass assign more' do
d = Dog.new(:name => "Avi", :species => "whatever", :colors => "whatever")
assert_equal d.name, "Avi"
assert_equal d.species, "whatever"
assert_equal d.colors, "whatever"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment