crumby 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
3
+
4
+ describe Crumby::Renderer::Base do
5
+ let(:trail) { stub :trail }
6
+ let(:view) { stub :view }
7
+ let(:options) { { test: true } }
8
+ subject { Crumby::Renderer::Base.new(trail, view, options) }
9
+
10
+ describe "#new" do
11
+ its(:trail) { should equal trail }
12
+ its(:view) { should equal view }
13
+ its(:options) { should include options }
14
+ end
15
+
16
+ describe "#render" do
17
+ pending "todo"
18
+ end
19
+
20
+ describe "#default_options" do
21
+ it { subject.default_options.should be_empty }
22
+ end
23
+
24
+ describe "#render_list" do
25
+ it "should raise a NotImplementedError error" do
26
+ expect { subject.render_list }.to raise_error NotImplementedError
27
+ end
28
+ end
29
+
30
+ describe "#render_entry" do
31
+ it "should raise a NotImplementedError error" do
32
+ expect { subject.render_entry(stub) }.to raise_error NotImplementedError
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,207 @@
1
+ # encoding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
+
4
+ class DummyRenderer < Crumby::Renderer::Haml
5
+ end
6
+
7
+ class DummyModelName
8
+ def human
9
+ "dummy human name"
10
+ end
11
+ end
12
+
13
+ class DummyModel
14
+ def model_name
15
+ DummyModelName.new
16
+ end
17
+ end
18
+
19
+ def DummyRenderer
20
+ end
21
+
22
+ describe Crumby::Trail do
23
+ let(:trail) { Crumby::Trail.new } # use subject
24
+ let(:rendered) { stub :rendered }
25
+ let(:renderer) { stub :renderer, render: rendered }
26
+ let(:default_renderer) { Renderer.default_renderer.stub renderer: renderer }
27
+ let(:custom_renderer) { DummyRenderer.stub :renderer, renderer: renderer }
28
+
29
+ context "have 10 entries" do
30
+ before { 10.times { subject.add :entry } }
31
+
32
+ its(:count) {should eq 10}
33
+
34
+ it "each breadcrumb should have the correct position" do
35
+ 10.times do |position|
36
+ subject.entries[position].position.should eq position
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+
43
+ describe "#add" do
44
+
45
+ context "without an argument" do
46
+ it "should get an ArgumentError" do
47
+ expect { subject.add }.to raise_error(ArgumentError)
48
+ end
49
+ end
50
+
51
+ context "with one argument" do
52
+ subject { trail.add first_argument }
53
+
54
+ context "that is a string" do
55
+ let(:first_argument) { "example string" }
56
+ its(:label) { should equal first_argument }
57
+ its(:route) { should be_nil }
58
+ end
59
+
60
+ context "that is a symbol" do
61
+ let(:first_argument) { :example_symbol }
62
+ its(:label) { should eq first_argument.to_s.humanize }
63
+ its(:route) { should equal first_argument }
64
+ end
65
+
66
+ context "that is an object with model_name method" do
67
+ let(:first_argument) { DummyModel.new }
68
+ its(:label) { should eq first_argument.model_name.human }
69
+ its(:route) { should equal first_argument }
70
+ end
71
+
72
+ context "that is an array of objects" do
73
+ context "last is an object with model_name method" do
74
+ let(:first_argument) { [:admin, DummyModel.new] }
75
+ its(:label) { should eq first_argument.last.model_name.human }
76
+ its(:route) { should equal first_argument }
77
+ end
78
+
79
+ context "last is a string" do
80
+ let(:first_argument) { [:admin, "other string"] }
81
+ its(:label) { should eq first_argument.last.to_s.humanize }
82
+ its(:route) { should equal first_argument }
83
+ end
84
+
85
+ end
86
+
87
+ context "that any other type" do
88
+ let(:first_argument) { 5.5 }
89
+ its(:label) { should eq first_argument.to_s.humanize }
90
+ its(:route) { should be_nil }
91
+ end
92
+ end
93
+
94
+ context "with label and route argument" do
95
+ let(:label) { "Name" }
96
+ let(:route) { :route }
97
+
98
+ subject { trail.add(label, route) }
99
+
100
+ its(:label) { should equal label }
101
+ its(:route) { should equal route }
102
+ end
103
+
104
+ context "with options" do
105
+ let(:options) { { option1: true, option2: false, string: "Text" } }
106
+ subject { trail.add(:test, options) }
107
+ its(:options) { should equal options }
108
+ end
109
+ end
110
+
111
+ describe "#entries" do
112
+ subject { trail.entries }
113
+
114
+ it { should be_an Array }
115
+
116
+ context "have no entry" do
117
+ its(:count) { should be_zero }
118
+ end
119
+
120
+ context "have on entry" do
121
+ subject { trail.add :test }
122
+ its(:count) { should_not be_zero }
123
+ end
124
+ end
125
+
126
+ # describe '#renderer' do
127
+
128
+ # subject { trail }
129
+
130
+ # context "without an arguments" do
131
+ # it "should return default renderer" do
132
+ # Crumby::Renderer.default_renderer.should_receive(:new).with(subject)
133
+ # subject.send(:renderer)
134
+ # end
135
+ # end
136
+
137
+ # context "with a DummyRenderer renderer" do
138
+ # let(:renderer) { DummyRenderer }
139
+ # it "should return the DummyRenderer renderer" do
140
+ # renderer.should_receive(:new).with(subject)
141
+ # subject.send(:renderer, renderer)
142
+ # end
143
+ # end
144
+
145
+ # context "with a String" do
146
+ # let(:renderer) { "String" }
147
+ # it "raise an ArgumentError" do
148
+ # expect { subject.send(:renderer, renderer) }.to raise_error(ArgumentError)
149
+ # end
150
+ # end
151
+
152
+ # context "with an renderer class" do
153
+ # end
154
+ # end
155
+
156
+ # describe "#render" do
157
+
158
+
159
+ # context "with default renderer" do
160
+ # after { trail.render }
161
+
162
+ # it "should load default renderer" do
163
+ # trail.should_receive(:renderer).with(nil).and_return(renderer)
164
+ # end
165
+ # end
166
+
167
+ # context "with custom renderer" do
168
+ # after { trail.render renderer: DummyRenderer }
169
+
170
+ # it "should load custom renderer" do
171
+ # trail.should_receive(:renderer).with(DummyRenderer).and_return(renderer)
172
+ # end
173
+ # end
174
+ # end
175
+
176
+ # describe "#renderer" do
177
+ # it "should raise ArgumentError with String class" do
178
+ # expect {
179
+ # trail.renderer String
180
+ # }.to raise_error ArgumentError
181
+ # end
182
+
183
+ # it "should raise ArgumentError with instance of String" do
184
+ # expect {
185
+ # trail.renderer "String"
186
+ # }.to raise_error ArgumentError
187
+ # end
188
+
189
+ # context "without renderer" do
190
+ # after { trail.renderer }
191
+
192
+ # it "should return instance of default renderer with trail" do
193
+ # Crumby::Renderer.default_renderer.should_receive(:new).with(trail)
194
+ # end
195
+ # end
196
+
197
+ # context "with custom renderer" do
198
+ # after { trail.renderer DummyRenderer }
199
+
200
+ # it "should return instance of DummyRenderer with trail" do
201
+ # DummyRenderer.should_receive(:new).with(trail)
202
+ # end
203
+ # end
204
+ # end
205
+
206
+
207
+ end
@@ -0,0 +1,26 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ require 'bundler/setup'
5
+ Bundler.require
6
+
7
+ require 'rails'
8
+ require 'rspec'
9
+
10
+ if ENV['COVERAGE']
11
+ require 'simplecov'
12
+ SimpleCov.start do
13
+ add_filter "/spec/"
14
+ end
15
+ end
16
+
17
+ require "active_support/all"
18
+ require 'crumby'
19
+
20
+ # Requires supporting files with custom matchers and macros, etc,
21
+ # in ./support/ and its subdirectories.
22
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
23
+
24
+ RSpec.configure do |config|
25
+
26
+ end
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crumby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Marco Scholl
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec-rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: yard
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: jeweler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: simplecov
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: A simple breadcrumb plugin for rails
111
+ email: develop@marco-scholl.de
112
+ executables: []
113
+ extensions: []
114
+ extra_rdoc_files:
115
+ - LICENSE.txt
116
+ - README.rdoc
117
+ files:
118
+ - .document
119
+ - .rspec
120
+ - Gemfile
121
+ - Gemfile.lock
122
+ - LICENSE.txt
123
+ - README.rdoc
124
+ - Rakefile
125
+ - VERSION
126
+ - crumby.gemspec
127
+ - lib/crumby.rb
128
+ - lib/crumby/entry.rb
129
+ - lib/crumby/helper.rb
130
+ - lib/crumby/helper/controller.rb
131
+ - lib/crumby/helper/view.rb
132
+ - lib/crumby/renderer.rb
133
+ - lib/crumby/renderer/base.rb
134
+ - lib/crumby/renderer/haml.rb
135
+ - lib/crumby/trail.rb
136
+ - spec/crumby/entry_spec.rb
137
+ - spec/crumby/helper_spec.rb
138
+ - spec/crumby/renderer/base_spec.rb
139
+ - spec/crumby/trail_spec.rb
140
+ - spec/spec_helper.rb
141
+ homepage: http://github.com/phatworx/crumby
142
+ licenses:
143
+ - MIT
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ segments:
155
+ - 0
156
+ hash: 870723315963817778
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ none: false
159
+ requirements:
160
+ - - ! '>='
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 1.8.24
166
+ signing_key:
167
+ specification_version: 3
168
+ summary: A simple breadcrumb plugin for rails
169
+ test_files: []