spec/style_spec.rb in teacup-1.0.4 vs spec/style_spec.rb in teacup-1.2.2
- old
+ new
@@ -134,21 +134,26 @@
end
it 'should respect precedence rules' do
sheet = Teacup::Stylesheet.new do
style :style1,
+ landscape: { tag: 1 },
portrait: { text: "extended", tag: 1 }
end
style2 = Teacup::Style.new
style2.stylesheet = sheet
style2[:text] = "text"
style2[:extends] = :style1
+ built = style2.build(nil)
+ built[:tag].should == 1
+ built[:text].should == 'text'
+
built = style2.build(nil, UIInterfaceOrientationPortrait)
built[:tag].should == 1
- built[:text].should == "text"
+ built[:text].should == nil
end
it 'should respect merge based on class inheritance' do
class Foo
attr_accessor :bar
@@ -168,8 +173,31 @@
style[:baz] = 'baz'
built = style.build(Bar.new)
built[:bar].should == 'bar'
built[:baz].should == 'baz'
+ end
+
+ it 'should not apply default styles when orientation is specified ' do
+ sheet = Teacup::Stylesheet.new do
+ style :style1,
+ top: 10,
+ left: 8,
+ landscape: { width: 100 },
+ portrait: { width: 100 }
+ style :style2,
+ top: 10,
+ left: 8,
+ landscape: { width: 100 },
+ portrait: { width: 100 }
+ end
+
+ style3 = Teacup::Style.new
+ style3.stylesheet = sheet
+
+ built = style3.build(UIInterfaceOrientationPortrait)
+ built[:top].should == nil
+ built[:left].should == nil
+ built[:width].should == nil
end
end