From c2e6f1b3aa94a0e9113a4fbd7fa37643d534ce33 Mon Sep 17 00:00:00 2001 From: David Larrabee Date: Sun, 28 Sep 2014 16:16:56 -0400 Subject: [PATCH 1/2] Adds test coverage for existing styler --- spec/stylers/ui_text_view_styler_spec.rb | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 spec/stylers/ui_text_view_styler_spec.rb 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..c66f179 --- /dev/null +++ b/spec/stylers/ui_text_view_styler_spec.rb @@ -0,0 +1,39 @@ +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 +end From 4ab07ff9560f721158ec4646799a9544931dcc5b Mon Sep 17 00:00:00 2001 From: David Larrabee Date: Sun, 28 Sep 2014 16:17:48 -0400 Subject: [PATCH 2/2] Adds 'color=` alias to ui_text_view styler --- .../ruby_motion_query/stylers/ui_text_view_styler.rb | 1 + spec/stylers/ui_text_view_styler_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+) 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 index c66f179..062880e 100644 --- a/spec/stylers/ui_text_view_styler_spec.rb +++ b/spec/stylers/ui_text_view_styler_spec.rb @@ -36,4 +36,16 @@ describe 'stylers/ui_text_view' do 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