tabs_on_rails 0.8.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,6 +1,15 @@
1
1
  = Changelog
2
2
 
3
3
 
4
+ == Release 1.0.0
5
+
6
+ * ADDED: Ability to pass arbitrary options to open_tabs and close_tags method. Thanks to aaronchi (closes #315)
7
+
8
+ * REMOVED: tabs_tag no longer accepts a Builder as first parameter. Removed deprecation warning.
9
+
10
+ First stable release.
11
+
12
+
4
13
  == Release 0.8.2
5
14
 
6
15
  * CHANGED: GitHub Gem Building is Defunct. The gem is now hosted on Gemcutter (see http://github.com/blog/515-gem-building-is-defunct)
data/Manifest CHANGED
@@ -1,23 +1,24 @@
1
1
  CHANGELOG.rdoc
2
+ LICENSE.rdoc
3
+ Manifest
4
+ README.rdoc
5
+ Rakefile
2
6
  init.rb
3
7
  install.rb
8
+ lib/tabs_on_rails.rb
4
9
  lib/tabs_on_rails/controller_mixin.rb
5
10
  lib/tabs_on_rails/tabs.rb
11
+ lib/tabs_on_rails/tabs/builder.rb
12
+ lib/tabs_on_rails/tabs/tabs_builder.rb
6
13
  lib/tabs_on_rails/version.rb
7
- lib/tabs_on_rails.rb
8
- LICENSE.rdoc
9
- Manifest
10
14
  rails/init.rb
11
- Rakefile
12
- README.rdoc
13
- tabs_on_rails.gemspec
14
15
  tasks/tabs_on_rails_tasks.rake
15
- test/builder_test.rb
16
16
  test/controller_mixin_helpers_test.rb
17
17
  test/controller_mixin_test.rb
18
18
  test/controller_mixin_with_controller_test.rb
19
- test/fixtures/mixin/standard.html.erb
20
- test/tabs_builder_test.rb
21
- test/tabs_on_rails_test.rb
19
+ test/fixtures/mixin/default.html.erb
20
+ test/fixtures/mixin/with_open_close_tabs.html.erb
21
+ test/tabs/builder_test.rb
22
+ test/tabs/tabs_builder_test.rb
22
23
  test/test_helper.rb
23
24
  uninstall.rb
data/README.rdoc CHANGED
@@ -84,6 +84,22 @@ Use the <tt>current_tab</tt> helper method if you need to access the value of cu
84
84
  # In your view
85
85
  <p>The name of current tab is <%= current_tab %>.</p>
86
86
 
87
+ The open tag can be customized with the `:open_tabs` option.
88
+
89
+ <% tabs_tag :open_tabs => { :id => "tabs", :class => "cool" } do |tab| %>
90
+ <%= tab.home 'Homepage', root_path %>
91
+ <%= tab.dashboard 'Dashboard', dashboard_path %>
92
+ <%= tab.account 'Account', account_path %>
93
+ <% end %>
94
+
95
+ <ul id="tabs" class="cool">
96
+ <li><a href="/">Homepage</a></li>
97
+ <li><a href="/dashboard">Dashboard</a></li>
98
+ <li><a href="/account">Account</a></li>
99
+ </ul>
100
+
101
+ Further customizations require a custom Builder (see below).
102
+
87
103
 
88
104
  == Restricting set_tab scope
89
105
 
@@ -172,7 +188,7 @@ To switch namespace in your template, just pass the :namespace option to the <tt
172
188
 
173
189
  === Namespace scope
174
190
 
175
- As a bonus feature, the namespace name does need to be unique within current request scope, not necessarily across the entire application.
191
+ As a bonus feature, the namespace needs to be unique within current request scope, not necessarily across the entire application.
176
192
 
177
193
  Back to the previous example, you can reuse the same namespace in the other controllers. In this way, you can reuse your templates as well.
178
194
 
@@ -208,7 +224,7 @@ The <tt>Builder</tt> is responsible for creating the tabs HTML code. This librar
208
224
 
209
225
  === Understanding the Builder
210
226
 
211
- Builders act as formatters. A Builder incapsulates all the logic behind the tab creation including the code required to toggle tabs status.
227
+ Builders act as formatters. A Builder encapsulates all the logic behind the tab creation including the code required to toggle tabs status.
212
228
 
213
229
  When the <tt>tabs_tag</tt> helper is called, it creates a new <tt>Tabs</tt> instance with selected Builder.
214
230
  If you don't provide a custom builder, then <tt>Tabs::TabsBuilder</tt> is used by default.
@@ -222,7 +238,7 @@ Additional overridable methods include:
222
238
  <tt>close_tabs</tt>:: the method called after the tab set
223
239
  <tt>tab_for</tt>:: the method called to create a single tab item
224
240
 
225
- The following example creates a custom tab builder called MainTabBuilder.
241
+ The following example creates a custom tab builder called <tt>MenuTabBuilder</tt>.
226
242
 
227
243
  class MenuTabBuilder < TabsOnRails::Tabs::Builder
228
244
  def tab_for(tab, name, options, item_options = {})
data/Rakefile CHANGED
@@ -1,18 +1,13 @@
1
+ $:.unshift(File.dirname(__FILE__) + "/lib")
2
+
1
3
  require 'rubygems'
2
4
  require 'rake'
3
5
  require 'echoe'
4
-
5
- $:.unshift(File.dirname(__FILE__) + "/lib")
6
6
  require 'tabs_on_rails'
7
7
 
8
8
 
9
9
  PKG_NAME = ENV['PKG_NAME'] || TabsOnRails::GEM
10
10
  PKG_VERSION = ENV['PKG_VERSION'] || TabsOnRails::VERSION
11
- PKG_SUMMARY = "A simple Ruby on Rails plugin for creating and managing Tabs."
12
- PKG_FILES = FileList.new("{lib,rails,tasks,test}/**/*") do |files|
13
- files.include %w(*.{rdoc,rb})
14
- files.include %w(Rakefile)
15
- end
16
11
  RUBYFORGE_PROJECT = nil
17
12
 
18
13
  if ENV['SNAPSHOT'].to_i == 1
@@ -23,20 +18,20 @@ end
23
18
  Echoe.new(PKG_NAME, PKG_VERSION) do |p|
24
19
  p.author = "Simone Carletti"
25
20
  p.email = "weppos@weppos.net"
26
- p.summary = PKG_SUMMARY
21
+ p.summary = "A simple Ruby on Rails plugin for creating and managing Tabs."
22
+ p.url = "http://code.simonecarletti.com/tabsonrails"
27
23
  p.description = <<-EOD
28
24
  TabsOnRails is a simple Ruby on Rails plugin for creating and managing Tabs. \
29
25
  It provides helpers for creating tabs with a flexible interface.
30
26
  EOD
31
- p.url = "http://code.simonecarletti.com/tabsonrails"
32
27
  p.project = RUBYFORGE_PROJECT
33
28
 
34
29
  p.need_zip = true
35
- p.rcov_options = ["--main << README.rdoc -x Rakefile -x rcov"]
36
- p.rdoc_pattern = /^(lib|CHANGELOG.rdoc|README.rdoc|LICENSE.rdoc)/
37
30
 
38
- p.development_dependencies += ["rake >=0.8",
39
- "echoe >=3.1"]
31
+ p.development_dependencies += ["rake ~>0.8.7",
32
+ "echoe ~>3.2.0"]
33
+
34
+ p.rcov_options = ["-Itest -x Rakefile,rcov,json,mocha,rack,actionpack,activesupport"]
40
35
  end
41
36
 
42
37
 
@@ -115,16 +115,15 @@ module TabsOnRails
115
115
 
116
116
  def tabs_tag(options = {}, &block)
117
117
  raise LocalJumpError, "no block given" unless block_given?
118
+
119
+ options = options.dup
120
+ open_tabs_options = options.delete(:open_tabs) || {}
121
+ close_tabs_options = options.delete(:close_tabs) || {}
122
+ tabs = Tabs.new(self, { :namespace => :default }.merge(options))
118
123
 
119
- unless options.is_a?(Hash)
120
- ActiveSupport::Deprecation.warn('tabs_tag takes a Hash of options, no longer a builder class. Use :builder => BuilderClass.', caller)
121
- options = { :builder => options }
122
- end
123
- tabs = Tabs.new(self, { :namespace => :default }.merge(options))
124
-
125
- concat(tabs.open_tabs.to_s)
124
+ concat(tabs.open_tabs(open_tabs_options).to_s)
126
125
  yield tabs
127
- concat(tabs.close_tabs.to_s)
126
+ concat(tabs.close_tabs(close_tabs_options).to_s)
128
127
  end
129
128
 
130
129
  end
@@ -14,107 +14,13 @@
14
14
  #++
15
15
 
16
16
 
17
+ require 'tabs_on_rails/tabs/builder'
18
+ require 'tabs_on_rails/tabs/tabs_builder'
19
+
20
+
17
21
  module TabsOnRails
18
-
19
- class Tabs
20
-
21
- #
22
- # = Builder
23
- #
24
- # The Builder class represents the interface for any custom Builder.
25
- #
26
- # To create a custom Builder extend this class
27
- # and implement the following abstract methods:
28
- #
29
- # * tab_for(args)
30
- #
31
- class Builder
32
-
33
- # Initializes a new builder with +context+.
34
- #
35
- # Note. You should not overwrite this method to prevent incompatibility with future versions.
36
- def initialize(context, options = {})
37
- @context = context
38
- @namespace = options.delete(:namespace) || :default
39
- end
40
-
41
- # Returns true if +tab+ is the +current_tab+.
42
- #
43
- # ==== Examples
44
- #
45
- # class MyController < ApplicationController
46
- # tab :foo
47
- # end
48
- #
49
- # current_tab? :foo # => true
50
- # current_tab? 'foo' # => true
51
- # current_tab? :bar # => false
52
- # current_tab? 'bar' # => false
53
- #
54
- def current_tab?(tab)
55
- tab.to_s == @context.current_tab(@namespace).to_s
56
- end
57
22
 
58
-
59
- # Creates and returns a tab with given +args+.
60
- #
61
- # ==== Raises
62
- #
63
- # NotImplemented:: you should implement this method in your custom Builder.
64
- #
65
- def tab_for(*args)
66
- raise NotImplementedError
67
- end
68
-
69
- # Overwrite this method to use a custom open tag for your tabs.
70
- def open_tabs
71
- end
72
-
73
- # Overwrite this method to use a custom close tag for your tabs.
74
- def close_tabs
75
- end
76
-
77
- end
78
-
79
- #
80
- # = Tabs Builder
81
- #
82
- # The TabsBuilder is and example of custom Builder.
83
- # It creates a new tab
84
- #
85
- class TabsBuilder < Builder
86
-
87
- # Implements Builder#tab_for.
88
- # Returns a link_to +tab+ with +name+ and +options+ if +tab+ is not the current tab,
89
- # a simple tab name wrapped by a span tag otherwise.
90
- #
91
- # current_tab? :foo # => true
92
- #
93
- # tab_for :foo, 'Foo', foo_path
94
- # # => <li><span>Foo</span></li>
95
- #
96
- # tab_for :bar, 'Bar', bar_path
97
- # # => <li><a href="/link/to/bar">Bar</a></li>
98
- #
99
- def tab_for(tab, name, options)
100
- content = @context.link_to_unless(current_tab?(tab), name, options) do
101
- @context.content_tag(:span, name)
102
- end
103
- @context.content_tag(:li, content)
104
- end
105
-
106
- # Implements Builder#open_tabs.
107
- def open_tabs
108
- '<ul>'
109
- end
110
-
111
- # Implements Builder#close_tabs.
112
- def close_tabs
113
- '</ul>'
114
- end
115
-
116
- end
117
-
23
+ class Tabs
118
24
 
119
25
  def initialize(context, options = {}, &block)
120
26
  @context = context
@@ -122,8 +28,8 @@ module TabsOnRails
122
28
  end
123
29
 
124
30
  %w(open_tabs close_tabs).each do |method|
125
- define_method(method) do
126
- @builder.send(method)
31
+ define_method(method) do |*args|
32
+ @builder.send(method, *args)
127
33
  end
128
34
  end
129
35
 
@@ -0,0 +1,79 @@
1
+ #
2
+ # = Tabs on Rails
3
+ #
4
+ # A simple Ruby on Rails plugin for creating and managing Tabs.
5
+ #
6
+ #
7
+ # Category:: Rails
8
+ # Package:: TabsOnRails
9
+ # Author:: Simone Carletti <weppos@weppos.net>
10
+ # License:: MIT License
11
+ #
12
+ #--
13
+ #
14
+ #++
15
+
16
+
17
+ module TabsOnRails
18
+ class Tabs
19
+
20
+ #
21
+ # = Builder
22
+ #
23
+ # The Builder class represents the interface for any custom Builder.
24
+ #
25
+ # To create a custom Builder extend this class
26
+ # and implement the following abstract methods:
27
+ #
28
+ # * tab_for(args)
29
+ #
30
+ class Builder
31
+
32
+ # Initializes a new builder with +context+.
33
+ #
34
+ # Note. You should not overwrite this method to prevent incompatibility with future versions.
35
+ def initialize(context, options = {})
36
+ @context = context
37
+ @namespace = options.delete(:namespace) || :default
38
+ end
39
+
40
+ # Returns true if +tab+ is the +current_tab+.
41
+ #
42
+ # ==== Examples
43
+ #
44
+ # class MyController < ApplicationController
45
+ # tab :foo
46
+ # end
47
+ #
48
+ # current_tab? :foo # => true
49
+ # current_tab? 'foo' # => true
50
+ # current_tab? :bar # => false
51
+ # current_tab? 'bar' # => false
52
+ #
53
+ def current_tab?(tab)
54
+ tab.to_s == @context.current_tab(@namespace).to_s
55
+ end
56
+
57
+
58
+ # Creates and returns a tab with given +args+.
59
+ #
60
+ # ==== Raises
61
+ #
62
+ # NotImplemented:: you should implement this method in your custom Builder.
63
+ #
64
+ def tab_for(*args)
65
+ raise NotImplementedError
66
+ end
67
+
68
+ # Overwrite this method to use a custom open tag for your tabs.
69
+ def open_tabs(*args)
70
+ end
71
+
72
+ # Overwrite this method to use a custom close tag for your tabs.
73
+ def close_tabs(*args)
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+ end
@@ -0,0 +1,81 @@
1
+ #
2
+ # = Tabs on Rails
3
+ #
4
+ # A simple Ruby on Rails plugin for creating and managing Tabs.
5
+ #
6
+ #
7
+ # Category:: Rails
8
+ # Package:: TabsOnRails
9
+ # Author:: Simone Carletti <weppos@weppos.net>
10
+ # License:: MIT License
11
+ #
12
+ #--
13
+ #
14
+ #++
15
+
16
+
17
+ module TabsOnRails
18
+ class Tabs
19
+
20
+ #
21
+ # = Tabs Builder
22
+ #
23
+ # The TabsBuilder is and example of custom Builder.
24
+ # It creates a new tab
25
+ #
26
+ class TabsBuilder < Builder
27
+
28
+ # Implements Builder#tab_for.
29
+ # Returns a link_to +tab+ with +name+ and +options+ if +tab+ is not the current tab,
30
+ # a simple tab name wrapped by a span tag otherwise.
31
+ #
32
+ # current_tab? :foo # => true
33
+ #
34
+ # tab_for :foo, 'Foo', foo_path
35
+ # # => <li><span>Foo</span></li>
36
+ #
37
+ # tab_for :bar, 'Bar', bar_path
38
+ # # => <li><a href="/link/to/bar">Bar</a></li>
39
+ #
40
+ def tab_for(tab, name, options)
41
+ content = @context.link_to_unless(current_tab?(tab), name, options) do
42
+ @context.content_tag(:span, name)
43
+ end
44
+ @context.content_tag(:li, content)
45
+ end
46
+
47
+ # Implements Builder#open_tabs.
48
+ #
49
+ # Returns an unordered list open tag.
50
+ # The <tt>options</tt> is used to customize the HTML attributes of the tag.
51
+ #
52
+ # open_tag
53
+ # # => "<ul>"
54
+ #
55
+ # open_tag :class => "centered"
56
+ # # => "<ul class=\"centered\">"
57
+ #
58
+ def open_tabs(options = {})
59
+ @context.tag("ul", options, open = true)
60
+ end
61
+
62
+ # Implements Builder#close_tabs.
63
+ #
64
+ # Returns an unordered list close tag.
65
+ # The <tt>options</tt> hash is ignored. It exists only for
66
+ # coeherence with the parent Builder API.
67
+ #
68
+ # close_tag
69
+ # # => "</ul>"
70
+ #
71
+ # close_tag :class => "centered"
72
+ # # => "</ul>"
73
+ #
74
+ def close_tabs(options = {})
75
+ "</ul>"
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+ end
@@ -17,15 +17,15 @@
17
17
  module TabsOnRails
18
18
 
19
19
  module Version
20
- MAJOR = 0
21
- MINOR = 8
22
- TINY = 2
20
+ MAJOR = 1
21
+ MINOR = 0
22
+ TINY = 0
23
23
 
24
24
  STRING = [MAJOR, MINOR, TINY].join('.')
25
25
  end
26
26
 
27
27
  VERSION = Version::STRING
28
- STATUS = 'beta'
28
+ STATUS = 'stable'
29
29
  BUILD = ''.match(/(\d+)/).to_a.first
30
30
 
31
31
  end
@@ -2,36 +2,36 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{tabs_on_rails}
5
- s.version = "0.8.2"
5
+ s.version = "1.0.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Simone Carletti"]
9
- s.date = %q{2009-10-12}
9
+ s.date = %q{2009-10-29}
10
10
  s.description = %q{ TabsOnRails is a simple Ruby on Rails plugin for creating and managing Tabs. It provides helpers for creating tabs with a flexible interface.
11
11
  }
12
12
  s.email = %q{weppos@weppos.net}
13
- s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/tabs_on_rails/controller_mixin.rb", "lib/tabs_on_rails/tabs.rb", "lib/tabs_on_rails/version.rb", "lib/tabs_on_rails.rb", "LICENSE.rdoc", "README.rdoc"]
14
- s.files = ["CHANGELOG.rdoc", "init.rb", "install.rb", "lib/tabs_on_rails/controller_mixin.rb", "lib/tabs_on_rails/tabs.rb", "lib/tabs_on_rails/version.rb", "lib/tabs_on_rails.rb", "LICENSE.rdoc", "Manifest", "rails/init.rb", "Rakefile", "README.rdoc", "tabs_on_rails.gemspec", "tasks/tabs_on_rails_tasks.rake", "test/builder_test.rb", "test/controller_mixin_helpers_test.rb", "test/controller_mixin_test.rb", "test/controller_mixin_with_controller_test.rb", "test/fixtures/mixin/standard.html.erb", "test/tabs_builder_test.rb", "test/tabs_on_rails_test.rb", "test/test_helper.rb", "uninstall.rb"]
13
+ s.extra_rdoc_files = ["CHANGELOG.rdoc", "LICENSE.rdoc", "README.rdoc", "lib/tabs_on_rails.rb", "lib/tabs_on_rails/controller_mixin.rb", "lib/tabs_on_rails/tabs.rb", "lib/tabs_on_rails/tabs/builder.rb", "lib/tabs_on_rails/tabs/tabs_builder.rb", "lib/tabs_on_rails/version.rb", "tasks/tabs_on_rails_tasks.rake"]
14
+ s.files = ["CHANGELOG.rdoc", "LICENSE.rdoc", "Manifest", "README.rdoc", "Rakefile", "init.rb", "install.rb", "lib/tabs_on_rails.rb", "lib/tabs_on_rails/controller_mixin.rb", "lib/tabs_on_rails/tabs.rb", "lib/tabs_on_rails/tabs/builder.rb", "lib/tabs_on_rails/tabs/tabs_builder.rb", "lib/tabs_on_rails/version.rb", "rails/init.rb", "tasks/tabs_on_rails_tasks.rake", "test/controller_mixin_helpers_test.rb", "test/controller_mixin_test.rb", "test/controller_mixin_with_controller_test.rb", "test/fixtures/mixin/default.html.erb", "test/fixtures/mixin/with_open_close_tabs.html.erb", "test/tabs/builder_test.rb", "test/tabs/tabs_builder_test.rb", "test/test_helper.rb", "uninstall.rb", "tabs_on_rails.gemspec"]
15
15
  s.homepage = %q{http://code.simonecarletti.com/tabsonrails}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Tabs_on_rails", "--main", "README.rdoc"]
17
17
  s.require_paths = ["lib"]
18
18
  s.rubygems_version = %q{1.3.5}
19
19
  s.summary = %q{A simple Ruby on Rails plugin for creating and managing Tabs.}
20
- s.test_files = ["test/builder_test.rb", "test/controller_mixin_helpers_test.rb", "test/controller_mixin_test.rb", "test/controller_mixin_with_controller_test.rb", "test/tabs_builder_test.rb", "test/tabs_on_rails_test.rb", "test/test_helper.rb"]
20
+ s.test_files = ["test/controller_mixin_helpers_test.rb", "test/controller_mixin_test.rb", "test/controller_mixin_with_controller_test.rb", "test/tabs/builder_test.rb", "test/tabs/tabs_builder_test.rb", "test/test_helper.rb"]
21
21
 
22
22
  if s.respond_to? :specification_version then
23
23
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
24
  s.specification_version = 3
25
25
 
26
26
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
- s.add_development_dependency(%q<rake>, [">= 0.8"])
28
- s.add_development_dependency(%q<echoe>, [">= 3.1"])
27
+ s.add_development_dependency(%q<rake>, ["~> 0.8.7"])
28
+ s.add_development_dependency(%q<echoe>, ["~> 3.2.0"])
29
29
  else
30
- s.add_dependency(%q<rake>, [">= 0.8"])
31
- s.add_dependency(%q<echoe>, [">= 3.1"])
30
+ s.add_dependency(%q<rake>, ["~> 0.8.7"])
31
+ s.add_dependency(%q<echoe>, ["~> 3.2.0"])
32
32
  end
33
33
  else
34
- s.add_dependency(%q<rake>, [">= 0.8"])
35
- s.add_dependency(%q<echoe>, [">= 3.1"])
34
+ s.add_dependency(%q<rake>, ["~> 0.8.7"])
35
+ s.add_dependency(%q<echoe>, ["~> 3.2.0"])
36
36
  end
37
37
  end
@@ -23,13 +23,13 @@ class NilBoundariesBuilder < TabsOnRails::Tabs::Builder
23
23
  end
24
24
 
25
25
  class NilOpenBoundaryBuilder < NilBoundariesBuilder
26
- def close_tabs
26
+ def close_tabs(options = {})
27
27
  '<br />'
28
28
  end
29
29
  end
30
30
 
31
31
  class NilCloseBoundaryBuilder < NilBoundariesBuilder
32
- def open_tabs
32
+ def open_tabs(options = {})
33
33
  '<br />'
34
34
  end
35
35
  end
@@ -57,8 +57,8 @@ class ControllerMixinHelpersTest < ActionView::TestCase
57
57
  assert_equal(:custom, builder.instance_variable_get(:'@namespace'))
58
58
  end
59
59
  end
60
-
61
-
60
+
61
+
62
62
  def test_tabs_tag_should_not_concat_open_close_tabs_when_nil
63
63
  content = tabs_tag(:builder => NilBoundariesBuilder) do |t|
64
64
  concat t.single('Single', '#')
@@ -16,7 +16,7 @@ class ControllerMixinWithControllerTest < ActionController::TestCase
16
16
 
17
17
  def method_missing(method, *args)
18
18
  if method =~ /^action_(.*)/
19
- render :action => (params[:template] || 'standard')
19
+ render :action => (params[:template] || 'default')
20
20
  end
21
21
  end
22
22
 
@@ -33,6 +33,23 @@ class ControllerMixinWithControllerTest < ActionController::TestCase
33
33
  end
34
34
 
35
35
 
36
+ def test_render_default
37
+ get :action_dashboard
38
+ assert_equal(%Q{<ul>
39
+ <li><span>Dashboard</span></li>
40
+ <li><a href="/w">Welcome</a></li>
41
+ </ul>}, @response.body)
42
+ end
43
+
44
+ def test_render_with_open_close_tabs
45
+ get :action_dashboard, :template => "with_open_close_tabs"
46
+ assert_equal(%Q{<ul id="tabs">
47
+ <li><span>Dashboard</span></li>
48
+ <li><a href="/w">Welcome</a></li>
49
+ </ul>}, @response.body)
50
+ end
51
+
52
+
36
53
  def test_set_tab
37
54
  get :action_dashboard
38
55
  assert_equal(:dashboard, controller.current_tab)
@@ -64,6 +81,7 @@ class ControllerMixinWithControllerTest < ActionController::TestCase
64
81
  </ul>}, @response.body)
65
82
  end
66
83
 
84
+
67
85
  def test_current_tab
68
86
  get :action_dashboard
69
87
  assert_equal :dashboard, controller.current_tab
@@ -0,0 +1,4 @@
1
+ <% tabs_tag(:open_tabs => { :id => "tabs" }, :close_tabs => { :class => "ignored" }) do |tabs| %>
2
+ <%= tabs.dashboard 'Dashboard', '/d' %>
3
+ <%= tabs.welcome 'Welcome', '/w' %>
4
+ <% end -%>
@@ -1,26 +1,26 @@
1
1
  require 'test_helper'
2
2
 
3
- class BuilderTemplate
4
- include ActionView::Helpers::TagHelper
5
- include ActionView::Helpers::UrlHelper
6
-
7
- def current_tab(namespace)
8
- case namespace
9
- when nil, :default
10
- :dashboard
11
- when :foospace
12
- :footab
13
- else
14
- :elsetab
3
+ class BuilderTest < ActiveSupport::TestCase
4
+
5
+ BuilderTemplate = Class.new do
6
+ include ActionView::Helpers::TagHelper
7
+ include ActionView::Helpers::UrlHelper
8
+
9
+ def current_tab(namespace)
10
+ case namespace
11
+ when nil, :default
12
+ :dashboard
13
+ when :foospace
14
+ :footab
15
+ else
16
+ :elsetab
17
+ end
15
18
  end
16
19
  end
17
- end
18
-
19
-
20
- class BuilderTest < ActiveSupport::TestCase
21
20
 
22
21
  def setup
23
22
  @template = BuilderTemplate.new
23
+ @builder = TabsOnRails::Tabs::Builder.new(@template)
24
24
  end
25
25
 
26
26
 
@@ -34,7 +34,6 @@ class BuilderTest < ActiveSupport::TestCase
34
34
  end
35
35
 
36
36
  def test_initialize_should_set_context
37
- @builder = TabsOnRails::Tabs::Builder.new(@template)
38
37
  assert_equal(@template, @builder.instance_variable_get(:'@context'))
39
38
  end
40
39
 
@@ -65,21 +64,26 @@ class BuilderTest < ActiveSupport::TestCase
65
64
 
66
65
 
67
66
  def test_open_tabs
68
- @builder = TabsOnRails::Tabs::Builder.new(@template)
69
- assert_equal(nil, @builder.open_tabs)
67
+ assert_equal nil, @builder.open_tabs
68
+ end
69
+
70
+ def test_open_tabs_with_options
71
+ assert_equal nil, @builder.open_tabs(:foo => "bar")
70
72
  end
71
73
 
72
74
  def test_close_tabs
73
- @builder = TabsOnRails::Tabs::Builder.new(@template)
74
- assert_equal(nil, @builder.close_tabs)
75
+ assert_equal nil, @builder.close_tabs
76
+ end
77
+
78
+ def test_close_tabs_with_options
79
+ assert_equal nil, @builder.close_tabs(:foo => "bar")
75
80
  end
76
81
 
77
82
 
78
83
  def test_tab_for_should_raise_not_implemented_error
79
- @builder = TabsOnRails::Tabs::Builder.new(@template)
80
84
  assert_raise(NotImplementedError) { @builder.tab_for }
81
85
  assert_raise(NotImplementedError) { @builder.tab_for('foo') }
82
86
  assert_raise(NotImplementedError) { @builder.tab_for('foo', 'bar') }
83
87
  end
84
88
 
85
- end
89
+ end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class TabsBuilderTest < ActionView::TestCase
4
4
 
5
- class TabsBuilderTemplate
5
+ TabsBuilderTemplate = Class.new do
6
6
  include ActionView::Helpers::TagHelper
7
7
  include ActionView::Helpers::UrlHelper
8
8
 
@@ -22,7 +22,25 @@ class TabsBuilderTest < ActionView::TestCase
22
22
  @template = TabsBuilderTemplate.new
23
23
  @builder = TabsOnRails::Tabs::TabsBuilder.new(@template)
24
24
  end
25
-
25
+
26
+
27
+ def test_open_tabs
28
+ assert_equal '<ul>', @builder.open_tabs
29
+ end
30
+
31
+ def test_open_tabs_with_options
32
+ assert_equal '<ul style="foo">', @builder.open_tabs(:style => "foo")
33
+ end
34
+
35
+ def test_close_tabs
36
+ assert_equal "</ul>", @builder.close_tabs
37
+ end
38
+
39
+ def test_close_tabs_with_options
40
+ assert_equal '</ul>', @builder.close_tabs(:foo => "bar")
41
+ end
42
+
43
+
26
44
  def test_should_implement_builder
27
45
  assert_equal(TabsOnRails::Tabs::Builder, TabsOnRails::Tabs::TabsBuilder.superclass)
28
46
  end
data/test/test_helper.rb CHANGED
@@ -1,8 +1,6 @@
1
-
2
-
3
1
  require 'rubygems'
4
2
  gem 'rails', '~>2.3.0'
5
- gem 'mocha', '0.9.7'
3
+ gem 'mocha', '~>0.9.7'
6
4
 
7
5
  # Remember! Due to some Mocha internal changes,
8
6
  # Rails 2.2.x requires Mocha 0.9.5 and
@@ -10,12 +8,9 @@ gem 'mocha', '0.9.7'
10
8
  # gem 'rails', '2.2.2'
11
9
  # gem 'mocha', '0.9.5'
12
10
 
13
- require 'mocha'
14
11
  require 'test/unit'
15
12
  require 'active_support'
16
13
  require 'action_controller'
17
- require 'action_controller/cgi_ext'
18
- require 'action_controller/test_process'
19
14
  require 'action_view/test_case'
20
15
 
21
16
  $:.unshift File.dirname(__FILE__) + '/../lib'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabs_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Carletti
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-12 00:00:00 +02:00
12
+ date: 2009-10-29 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,9 +18,9 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ">="
21
+ - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: "0.8"
23
+ version: 0.8.7
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: echoe
@@ -28,9 +28,9 @@ dependencies:
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: "3.1"
33
+ version: 3.2.0
34
34
  version:
35
35
  description: " TabsOnRails is a simple Ruby on Rails plugin for creating and managing Tabs. It provides helpers for creating tabs with a flexible interface.\n"
36
36
  email: weppos@weppos.net
@@ -40,36 +40,41 @@ extensions: []
40
40
 
41
41
  extra_rdoc_files:
42
42
  - CHANGELOG.rdoc
43
+ - LICENSE.rdoc
44
+ - README.rdoc
45
+ - lib/tabs_on_rails.rb
43
46
  - lib/tabs_on_rails/controller_mixin.rb
44
47
  - lib/tabs_on_rails/tabs.rb
48
+ - lib/tabs_on_rails/tabs/builder.rb
49
+ - lib/tabs_on_rails/tabs/tabs_builder.rb
45
50
  - lib/tabs_on_rails/version.rb
46
- - lib/tabs_on_rails.rb
47
- - LICENSE.rdoc
48
- - README.rdoc
51
+ - tasks/tabs_on_rails_tasks.rake
49
52
  files:
50
53
  - CHANGELOG.rdoc
54
+ - LICENSE.rdoc
55
+ - Manifest
56
+ - README.rdoc
57
+ - Rakefile
51
58
  - init.rb
52
59
  - install.rb
60
+ - lib/tabs_on_rails.rb
53
61
  - lib/tabs_on_rails/controller_mixin.rb
54
62
  - lib/tabs_on_rails/tabs.rb
63
+ - lib/tabs_on_rails/tabs/builder.rb
64
+ - lib/tabs_on_rails/tabs/tabs_builder.rb
55
65
  - lib/tabs_on_rails/version.rb
56
- - lib/tabs_on_rails.rb
57
- - LICENSE.rdoc
58
- - Manifest
59
66
  - rails/init.rb
60
- - Rakefile
61
- - README.rdoc
62
- - tabs_on_rails.gemspec
63
67
  - tasks/tabs_on_rails_tasks.rake
64
- - test/builder_test.rb
65
68
  - test/controller_mixin_helpers_test.rb
66
69
  - test/controller_mixin_test.rb
67
70
  - test/controller_mixin_with_controller_test.rb
68
- - test/fixtures/mixin/standard.html.erb
69
- - test/tabs_builder_test.rb
70
- - test/tabs_on_rails_test.rb
71
+ - test/fixtures/mixin/default.html.erb
72
+ - test/fixtures/mixin/with_open_close_tabs.html.erb
73
+ - test/tabs/builder_test.rb
74
+ - test/tabs/tabs_builder_test.rb
71
75
  - test/test_helper.rb
72
76
  - uninstall.rb
77
+ - tabs_on_rails.gemspec
73
78
  has_rdoc: true
74
79
  homepage: http://code.simonecarletti.com/tabsonrails
75
80
  licenses: []
@@ -104,10 +109,9 @@ signing_key:
104
109
  specification_version: 3
105
110
  summary: A simple Ruby on Rails plugin for creating and managing Tabs.
106
111
  test_files:
107
- - test/builder_test.rb
108
112
  - test/controller_mixin_helpers_test.rb
109
113
  - test/controller_mixin_test.rb
110
114
  - test/controller_mixin_with_controller_test.rb
111
- - test/tabs_builder_test.rb
112
- - test/tabs_on_rails_test.rb
115
+ - test/tabs/builder_test.rb
116
+ - test/tabs/tabs_builder_test.rb
113
117
  - test/test_helper.rb
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TabsOnRailsTest < ActiveSupport::TestCase
4
-
5
- def test_nothing_because_I_have_the_other_test_files
6
- assert true
7
- end
8
-
9
- end