-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method for defining default style for a class
See samples/sample56.rb for a test
- Loading branch information
1 parent
78164a4
commit 7746754
Showing
6 changed files
with
90 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# sample56.rb | ||
Para = Shoes::Para | ||
Shoes.app :width => 200, :height => 160 do | ||
style Para, :align => 'center', :stroke => pink, :size => 30 | ||
stack do | ||
para "hello" | ||
para "hello", :size => 10, :stroke => red | ||
para "hello" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
shape | ||
stroke | ||
strokewidth | ||
style | ||
].each do |method| | ||
include_examples "#{method} DSL method" | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
shared_examples_for "style DSL method" do | ||
describe "setting new defaults for text block" do | ||
let(:stroke) { Shoes::COLORS[:chartreuse] } | ||
let(:size) { 42 } | ||
let(:fill) { Shoes::COLORS[:peru] } | ||
let(:font ) { "SOME FONT" } | ||
let(:style) { {:stroke => stroke, :size => size, :fill => fill, :font => font} } | ||
|
||
%w(Banner Title Subtitle Tagline Caption Para Inscription).each do |text_block| | ||
describe text_block do | ||
let(:element) { dsl.public_send text_block.downcase, "Hello!" } | ||
let(:klass) { Shoes.const_get(text_block) } | ||
|
||
before :each do | ||
dsl.style klass, style | ||
end | ||
|
||
it "creates element with appropriate class" do | ||
element.class.should eq(klass) | ||
end | ||
|
||
it "sets size" do | ||
element.font_size.should eq(size) | ||
end | ||
|
||
it "sets font" do | ||
element.font.should eq(font) | ||
end | ||
end | ||
end | ||
end | ||
end |