Permalink
Browse files

Added level to crumb.

  • Loading branch information...
1 parent e3e6b66 commit ab8ec941f088d3b7ea1cef1bfcb7830d9e142c13 @58bits 58bits committed Mar 31, 2012
Showing with 14 additions and 4 deletions.
  1. +3 −0 .rspec
  2. +4 −2 lib/ariane/crumb.rb
  3. +1 −1 spec/ariane/breadcrumb_spec.rb
  4. +6 −1 spec/ariane/crumb_spec.rb
View
3 .rspec
@@ -0,0 +1,3 @@
+--colour
+--drb
+--format documentation
View
@@ -6,18 +6,20 @@ class Crumb
# Public: Gets/Sets the String data of the crumb.
# Public: Gets/Sets the String text of the crumb.
# Public: Gets/Sets the String url of the crumb.
- attr_accessor :data, :text, :url
+ # Public: Gets/Sets the Integer level of the crumb.
+ attr_accessor :text, :url, :level, :data
# Internal: Initialize a Crumb.
#
# text - A String representing the text of the crumb (default: '').
# url - A String representing the url of the crumb (default: nil).
# data - A Hash used to store any data that can be used by renderers
# (default: {}).
- def initialize(text='', url=nil, data={})
+ def initialize(text='', url=nil, level=1, data={})
@text = text
@url = url
@data = data
+ @level = level
end
end
end
@@ -18,7 +18,7 @@ module Ariane
describe "#add" do
it "creates a new crumb and push it to crumbs" do
- subject.add 'text', 'url', :foo => :bar
+ subject.add 'text', 'url', 1, :foo => :bar
subject.crumbs.count.should be(1)
subject.crumbs.last.text.should == 'text'
subject.crumbs.last.url.should == 'url'
@@ -16,7 +16,12 @@ module Ariane
end
it "sets its data based on third argument of the initializer" do
- crumb = Crumb.new('text', 'url', :foo => :bar)
+ crumb = Crumb.new('text', 'url', 1)
+ crumb.level.should == 1
+ end
+
+ it "sets its data based on fourth argument of the initializer" do
+ crumb = Crumb.new('text', 'url', 1, :foo => :bar)
crumb.data.should == { :foo => :bar }
end
end

0 comments on commit ab8ec94

Please sign in to comment.