Skip to content

Instantly share code, notes, and snippets.

@joegiralt
Created July 8, 2013 19:40
Show Gist options
  • Save joegiralt/5951858 to your computer and use it in GitHub Desktop.
Save joegiralt/5951858 to your computer and use it in GitHub Desktop.
quick assignment
require 'fis/test'
class Dog
attr_accessor :name, :species, :colors, :fur_length
def initialize(attributes_hash)
attributes_hash.each do |key, value|
self.send("#{key}=", value)
end
end
end
class MassTest
extend Fis::Test
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
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment