test/style_test.rb in osheet-0.4.0 vs test/style_test.rb in osheet-0.5.0
- old
+ new
@@ -29,11 +29,11 @@
assert_equal 1, subject.selectors.size
assert_equal '.test', subject.selectors.first
[ :align, :font, :bg,
:border_left, :border_top, :border_right, :border_bottom
].each do |a|
- assert_equal [], subject.send(:instance_variable_get, "@#{a}")
+ assert_equal [], subject.send(:get_ivar, a)
end
end
should "know it's attribute(s)" do
[ :align, :font, :bg,
@@ -49,19 +49,19 @@
:border_left, :border_top, :border_right, :border_bottom
].each do |a|
should "collect styles for #{a}" do
args = [1, "#FF0000", "Verdana", :love, 1.2]
subject.send(a, *args)
- assert_equal args, subject.send(:instance_variable_get, "@#{a}")
+ assert_equal args, subject.send(:get_ivar, a)
end
end
should "set all border positions to the same styles using 'border' macro" do
args = [:thick, '#FF00FF', :dot]
subject.border *args
[ :border_left, :border_top, :border_right, :border_bottom].each do |a|
- assert_equal args, subject.send(:instance_variable_get, "@#{a}")
+ assert_equal args, subject.send(:get_ivar, a)
end
end
should "match on style class strings" do
a = Style.new('.awesome') {}
@@ -87,6 +87,22 @@
end
end
end
+
+ class StyleBindingTest < Test::Unit::TestCase
+ context "a style defined w/ a block" do
+ should "access instance vars from that block's binding" do
+ @test = 20
+ @style = Style.new('.test') { font @test }
+
+ assert !@style.send(:instance_variable_get, "@test").nil?
+ assert_equal @test, @style.send(:instance_variable_get, "@test")
+ assert_equal @test.object_id, @style.send(:instance_variable_get, "@test").object_id
+ assert_equal @test, @style.attributes[:font].first
+ assert_equal @test.object_id, @style.attributes[:font].first.object_id
+ end
+ end
+ end
+
end