diff --git a/motion/ruby_motion_query/stylers/ui_text_view_styler.rb b/motion/ruby_motion_query/stylers/ui_text_view_styler.rb index f44dba4..e291018 100644 --- a/motion/ruby_motion_query/stylers/ui_text_view_styler.rb +++ b/motion/ruby_motion_query/stylers/ui_text_view_styler.rb @@ -14,6 +14,7 @@ module RubyMotionQuery def text_color ; view.textColor ; end def text_color=(v) ; view.textColor = v ; end alias :color :text_color + alias :color= :text_color= end end diff --git a/spec/stylers/ui_text_view_styler_spec.rb b/spec/stylers/ui_text_view_styler_spec.rb new file mode 100644 index 0000000..062880e --- /dev/null +++ b/spec/stylers/ui_text_view_styler_spec.rb @@ -0,0 +1,51 @@ +describe 'stylers/ui_text_view' do + class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet + def ui_text_view_kitchen_sink(st) + st.text = 'foo' + st.font = font.system(12) + st.text_color= color.red + end + + def ui_text_view_attributed_string(st) + st.attributed_text = NSAttributedString.alloc.initWithString("RMQ") + end + end + + before do + @vc = UIViewController.alloc.init + @vc.rmq.stylesheet = SyleSheetForUIViewStylerTests + @view_klass = UITextView + end + + behaves_like "styler" + + it 'should apply a style with every UITextViewStyler wrapper method' do + view = @vc.rmq.append(@view_klass, :ui_text_view_kitchen_sink).get + + view.tap do |v| + view.text.should == "foo" + view.font.should == UIFont.systemFontOfSize(12) + view.textColor.should == UIColor.redColor + end + end + + it "applies an attributed string" do + view = @vc.rmq.append(@view_klass, :ui_text_view_attributed_string).get + + view.tap do |v| + v.text.should == 'RMQ' + end + end + + it "can also set the color using the 'color' alias" do + view = @vc.rmq.append(@view_klass, :ui_text_view_kitchen_sink).get + + rmq(view).style do |st| + st.color = rmq.color.green + end + + view.tap do |v| + view.textColor.should == UIColor.greenColor + end + end +end