Module: SimplyTestable::ActsAsList::ClassMethods

Defined in:
lib/simply_testable/acts_as_list.rb

Instance Method Summary collapse

Instance Method Details

#assert_should_act_as_list(*args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/simply_testable/acts_as_list.rb', line 10

def assert_should_act_as_list(*args)
	options = args.extract_options!
	scope = options[:scope]

	test "#{brand}should act as list" do
		model = create_object.class.name
		model.constantize.destroy_all
		object = create_object
		assert_equal 1, object.position
		attrs = {}
		Array(scope).each do |attr|
			attrs[attr.to_sym] = object.send(attr)
		end if scope
		object = create_object(attrs)
		assert_equal 2, object.position

		# gotta be a relative test as there may already
		# by existing objects (unless I destroy them)
		assert_difference("#{model}.last.position",1) do
			create_object(attrs)
		end
	end

end