Skip to content

Commit

Permalink
Add #no_wordwrap! and #wordwrap! methods to DSL;
Browse files Browse the repository at this point in the history
These methods will control the :wordwrap option on the view. The behaviour will
soon be changed to wordwrap by default, meaning that #no_wordwrap! should be
used to specifically not wordwrap content in a given interface.

Work relating to #341.
  • Loading branch information
gavinlaking committed Jan 31, 2016
1 parent 0180272 commit 84dce31
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/vedeu/dsl/presentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ def colour(attrs = {})
end
alias colour= colour

# Instruct the view to not use wordwrapping. (Default)
#
# @return [Boolean]
def no_wordwrap!
wordwrap(false)
end

# Define a style or styles for an interface, line or a stream.
#
# @param value [Array<Symbol>|Array<String>|Symbol|String]
Expand Down Expand Up @@ -122,6 +129,24 @@ def style(value)
alias styles style
alias styles= style

# Specify whether the view should use wordwrapping, or not
# (default).
#
# @param value [Boolean]
# @return [Boolean]
def wordwrap(value = false)
boolean = value ? true : false

model.wordwrap = boolean
end

# Instruct the view to use wordwrapping.
#
# @return [Boolean]
def wordwrap!
wordwrap(true)
end

private

# @return [Hash<Symbol => String>]
Expand Down
44 changes: 44 additions & 0 deletions test/lib/vedeu/dsl/presentation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ module DSL
it { instance.must_respond_to(:colour=) }
end

describe '#no_wordwrap!' do
it { instance.must_respond_to(:no_wordwrap!) }

# @todo Add more tests.
end

describe '#style' do
let(:args) { :bold }

Expand All @@ -138,6 +144,44 @@ module DSL
it { instance.must_respond_to(:styles=) }
end

describe '#wordwrap' do
context 'when the value is not given' do
subject { instance.wordwrap }

it { subject.must_equal() }
end

context 'when the value is given' do
let(:_value) { false }

subject { instance.wordwrap(_value) }

context 'when the value is nil' do
let(:_value) { nil }

it { subject.must_equal() }
end

context 'when the value is false' do
it { subject.must_equal() }
end

context 'when the value evaluates as true' do
let(:_value) { :a_true_value }

it { subject.must_equal() }
end
end

it { instance.must_respond_to(:wordwrap) }
end

describe '#wordwrap!' do
it { instance.must_respond_to(:wordwrap!) }

# @todo Add more tests.
end

end # Presentation

end # DSL
Expand Down

0 comments on commit 84dce31

Please sign in to comment.