spec/ffi-tk/widget/text.rb in ffi-tk-2010.08.23 vs spec/ffi-tk/widget/text.rb in ffi-tk-2018.02.20

- old
+ new

@@ -1,5 +1,6 @@ +# frozen_string_literal: true require_relative '../../helper' describe Tk::Text do text = Tk::Text.new text.insert :end, 'Hello, World!' @@ -11,54 +12,62 @@ it 'gets text between two indices' do text.get('1.0', 'end').should == "Hello, World!\n" end - it 'gets all possible options with cget' do - text.cget(:autoseparators ).should == true - text.cget(:background ).should == "#ffffff" - text.cget(:bd ).should == 1 - text.cget(:bg ).should == "#ffffff" - text.cget(:blockcursor ).should == false - text.cget(:borderwidth ).should == 1 - text.cget(:cursor ).should == "xterm" - text.cget(:endline ).should == 0 - text.cget(:exportselection ).should == true - text.cget(:fg ).should == "#000000" - text.cget(:font ).should == "TkFixedFont" - text.cget(:foreground ).should == "#000000" - text.cget(:height ).should == 24 - text.cget(:highlightbackground ).should == "#d9d9d9" - text.cget(:highlightcolor ).should == "#000000" - text.cget(:highlightthickness ).should == 1 - text.cget(:inactiveselectbackground).should == "#c3c3c3" - text.cget(:insertbackground ).should == "#000000" - text.cget(:insertborderwidth ).should == 0 - text.cget(:insertofftime ).should == 300 - text.cget(:insertontime ).should == 600 - text.cget(:insertwidth ).should == 2 - text.cget(:maxundo ).should == 0 - text.cget(:padx ).should == 1 - text.cget(:pady ).should == 1 - text.cget(:relief ).should == :sunken - text.cget(:selectbackground ).should == "#c3c3c3" - text.cget(:selectborderwidth ).should == 0 - text.cget(:selectforeground ).should == "#000000" - text.cget(:setgrid ).should == false - text.cget(:spacing1 ).should == 0 - text.cget(:spacing2 ).should == 0 - text.cget(:spacing3 ).should == 0 - text.cget(:startline ).should == 0 - text.cget(:state ).should == ['normal'] - text.cget(:tabs ).should == nil - text.cget(:tabstyle ).should == :tabular - text.cget(:takefocus ).should == false - text.cget(:undo ).should == false - text.cget(:width ).should == 80 - text.cget(:wrap ).should == :char - text.cget(:xscrollcommand ).should == nil - text.cget(:yscrollcommand ).should == nil + cget_options = { + autoseparators: [true], + background: %w(systemWindowBody #282828), + bd: [0, 1], + bg: %w(systemWindowBody #ffffff #282828), + blockcursor: [false], + borderwidth: [0, 1], + cursor: ['xterm'], + endline: ['', 0], + exportselection: [true], + fg: %w(Black #000000 #ebdbb2), + font: %w(TkFixedFont), + foreground: %w(Black #000000 #ebdbb2), + height: [24], + highlightbackground: %w(systemWindowBody #d9d9d9), + highlightcolor: %w(Black #000000), + highlightthickness: [3, 1], + inactiveselectbackground: %w(systemHighlightSecondary #c3c3c3), + insertbackground: %w(Black #000000), + insertborderwidth: [0], + insertofftime: [300], + insertontime: [600], + insertwidth: [1, 2], + maxundo: [0], + padx: [1], + pady: [1], + relief: [:flat, :sunken], + selectbackground: %w(systemHighlight #c3c3c3), + selectborderwidth: [1, 0], + selectforeground: [nil, '#000000'], + setgrid: [false], + spacing1: [0], + spacing2: [0], + spacing3: [0], + startline: [0, ''], + state: [['normal']], + tabs: [nil], + tabstyle: [:tabular], + takefocus: [false], + undo: [false, true], + width: [80], + wrap: [:char], + xscrollcommand: [nil], + yscrollcommand: [nil] + } + + describe 'getting options via cget' do + cget_options.each do |key, values| + it "returns a member of #{values.inspect} for -#{key}" do + values.should.include text.cget(key) + end + end end it 'configures a single option' do text.cget(:wrap).should == :char text.configure(wrap: :word) @@ -109,11 +118,11 @@ it 'counts xpixels' do text.count(1.0, :end, :xpixels).should == 0 end it 'counts ypixels' do - text.count(1.0, :end, :ypixels).should == 195 + text.count(1.0, :end, :ypixels).should == 182 end should 'not be in debug mode' do text.debug?.should == false end @@ -129,11 +138,11 @@ end it 'gives line info' do info = text.dlineinfo(1.0) info.size.should == 5 - info.all?{|i| i.kind_of?(Fixnum) } + info.all? { |i| i.is_a?(Integer) } end it 'inserts string with taglist' do text.insert(1.0, 'H', 'start') text.get(1.0, :end).should == "Hel World!\n" @@ -187,16 +196,16 @@ it 'destroys the peer' do @peer.destroy text.peer_names.should == [] end - it 'searches for {}' do - text.insert :end, '{ now some text in here}' - text.search(/\{/, '1.0', 'end', :all).should == ['1.10'] - text.search(/\}/, '1.0', 'end', :all).should == ['1.33'] - text.search(/[{}]/, '1.0', 'end', :all).should == ['1.10', '1.33'] - end + it 'searches for {}' do + text.insert :end, '{ now some text in here}' + text.search(/\{/, '1.0', 'end', :all).should == ['1.10'] + text.search(/\}/, '1.0', 'end', :all).should == ['1.33'] + text.search(/[{}]/, '1.0', 'end', :all).should == ['1.10', '1.33'] + end text.delete '1.0', 'end' text.insert(:end, <<-TEXT) Est magni ex et voluptatem possimus deserunt qui. Ex necessitatibus molestiae aperiam illo. Voluptatem omnis eum illum tenetur inventore. Exercitationem non voluptatem et. Aut molestiae exercitationem veritatis voluptates unde nam possimus dolore. Ea dolores qui et odit officia quibusdam autem. Optio quia inventore aspernatur. Eos ipsam maxime sed dignissimos minus. Mollitia fugiat voluptate sunt non illum nam adipisci. @@ -220,11 +229,11 @@ Voluptates dicta labore impedit deserunt quod. Vero sint rerum at asperiores eos. Saepe nam sint sint. Non et assumenda molestiae et sunt perferendis qui corrupti. Est velit qui quam. TEXT describe 'Text#search' do it 'searches by exact match' do - text.search("et", '1.0', :end).should == ['1.13'] - text.search("labore", '1.0', :end).should == ['20.17'] + text.search('et', '1.0', :end).should == ['1.13'] + text.search('labore', '1.0', :end).should == ['20.17'] end it 'searches by regular expression' do text.search(/e[t]/, '1.0', :end).should == ['1.13'] text.search(/E[T]/i, '1.0', :end).should == ['1.13']