sorting_table_for 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. data/CHANGELOG.mdown +6 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README.mdown +7 -7
  4. data/Rakefile +32 -8
  5. data/lib/sorting_table_for/format_cell.rb +1 -5
  6. data/lib/sorting_table_for/tools.rb +0 -8
  7. data/lib/sorting_table_for/version.rb +3 -0
  8. data/spec/dummy/README.rdoc +261 -0
  9. data/spec/dummy/Rakefile +7 -0
  10. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  11. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  12. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  13. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  14. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  15. data/spec/dummy/config.ru +4 -0
  16. data/spec/dummy/config/application.rb +59 -0
  17. data/spec/dummy/config/boot.rb +10 -0
  18. data/spec/dummy/config/database.yml +25 -0
  19. data/spec/dummy/config/environment.rb +5 -0
  20. data/spec/dummy/config/environments/development.rb +37 -0
  21. data/spec/dummy/config/environments/production.rb +67 -0
  22. data/spec/dummy/config/environments/test.rb +37 -0
  23. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  24. data/spec/dummy/config/initializers/inflections.rb +15 -0
  25. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  26. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  27. data/spec/dummy/config/initializers/session_store.rb +8 -0
  28. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  29. data/spec/dummy/config/locales/en.yml +5 -0
  30. data/spec/dummy/config/routes.rb +58 -0
  31. data/spec/dummy/db/test.sqlite3 +0 -0
  32. data/spec/dummy/public/404.html +26 -0
  33. data/spec/dummy/public/422.html +26 -0
  34. data/spec/dummy/public/500.html +25 -0
  35. data/spec/dummy/public/favicon.ico +0 -0
  36. data/spec/dummy/script/rails +6 -0
  37. data/spec/fixtures/sorting_table_for_user.rb +4 -10
  38. data/spec/helpers/builder_spec.rb +13 -13
  39. data/spec/helpers/caption_spec.rb +19 -19
  40. data/spec/helpers/cell_value_spec.rb +23 -23
  41. data/spec/helpers/column_spec.rb +81 -79
  42. data/spec/helpers/footer_spec.rb +46 -46
  43. data/spec/helpers/header_spec.rb +74 -84
  44. data/spec/locales/{test_rails3.yml → test_rails.yml} +0 -0
  45. data/spec/spec_helper.rb +10 -45
  46. metadata +120 -12
  47. data/spec/locales/test.yml +0 -104
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -1,15 +1,9 @@
1
1
  class SortingTableForUser < ActiveRecord::Base
2
- if ::SortingTableFor::Tools::rails3?
3
- attr_accessible :username, :firstname, :lastname, :position,
4
- :salary, :price, :active, :created_at, :updated_at
5
-
6
- scope :good_position, :conditions => 'position > 3'
7
- scope :set_limit, lambda { |limit| { :limit => limit } }
8
- else
9
- named_scope :good_position, :conditions => 'position > 3'
10
- named_scope :set_limit, lambda { |limit| { :limit => limit } }
11
- end
2
+ attr_accessible :username, :firstname, :lastname, :position,
3
+ :salary, :price, :active, :created_at, :updated_at
12
4
 
5
+ scope :good_position, :conditions => 'position > 3'
6
+ scope :set_limit, lambda { |limit| { :limit => limit } }
13
7
  end
14
8
 
15
9
  20.times do |n|
@@ -8,7 +8,7 @@ include SortingTableForSpecHelper
8
8
  describe SortingTableFor, :type => :helper do
9
9
 
10
10
  before :all do
11
- (SortingTableFor::Tools::rails3?) ? routes_rails3 : routes_rails2
11
+ routes_rails
12
12
  end
13
13
 
14
14
  before :each do
@@ -28,13 +28,13 @@ describe SortingTableFor, :type => :helper do
28
28
  it "should have balise table with class" do
29
29
  table_html = helper.sorting_table_for(@users) {}
30
30
  helper.output_buffer.concat(table_html)
31
- helper.output_buffer.should have_comp_tag("table[class=sorting_table_for]")
31
+ helper.output_buffer.should have_selector("table[class=sorting_table_for]")
32
32
  end
33
33
 
34
34
  it "should be custom by html" do
35
35
  table_html = helper.sorting_table_for(@users, :html => { :class => 'hello', :id => 'my_test' }) {}
36
36
  helper.output_buffer.concat(table_html)
37
- helper.output_buffer.should have_comp_tag("table[class='hello sorting_table_for'][id='my_test']")
37
+ helper.output_buffer.should have_selector("table[class='hello sorting_table_for'][id='my_test']")
38
38
  end
39
39
 
40
40
  it "should take another builder" do
@@ -48,14 +48,14 @@ describe SortingTableFor, :type => :helper do
48
48
  it "should use i18n by default" do
49
49
  helper.sorting_table_for(@users) do |table|
50
50
  html = table.headers(:username)
51
- html.should have_comp_tag("th:nth-child(1)", :text => 'Usernames')
51
+ html.should have_selector("th:nth-child(1)", :content => 'Usernames')
52
52
  end
53
53
  end
54
54
 
55
55
  it "should not use i18n" do
56
56
  helper.sorting_table_for(@users, :i18n => false) do |table|
57
57
  html = table.headers(:username)
58
- html.should have_comp_tag("th:nth-child(1)", :text => 'username')
58
+ html.should have_selector("th:nth-child(1)", :content => 'username')
59
59
  end
60
60
  end
61
61
 
@@ -69,10 +69,10 @@ describe SortingTableFor, :type => :helper do
69
69
  html += table.headers
70
70
  html += table.columns
71
71
  html += table.footers :username
72
- html.should have_comp_tag("caption", :count => 1)
73
- html.should have_comp_tag("thead", :count => 1)
74
- html.should have_comp_tag("tbody", :count => 1)
75
- html.should have_comp_tag("tfoot", :count => 1)
72
+ html.should have_selector("caption", :count => 1)
73
+ html.should have_selector("thead", :count => 1)
74
+ html.should have_selector("tbody", :count => 1)
75
+ html.should have_selector("tfoot", :count => 1)
76
76
  end
77
77
  end
78
78
 
@@ -82,10 +82,10 @@ describe SortingTableFor, :type => :helper do
82
82
  html += table.headers :username
83
83
  html += table.columns :username
84
84
  html += table.footers :username
85
- html.should have_comp_tag("thead tr th", :count => 1)
86
- html.should have_comp_tag("tbody tr td", :count => @users.count + 1)
87
- html.should have_comp_tag("tbody tr[class=total-entries] td", :count => 1)
88
- html.should have_comp_tag("tfoot tr td", :count => 1)
85
+ html.should have_selector("thead tr th", :count => 1)
86
+ html.should have_selector("tbody tr td", :count => @users.count + 1)
87
+ html.should have_selector("tbody tr[class=total-entries] td", :count => 1)
88
+ html.should have_selector("tfoot tr td", :count => 1)
89
89
  end
90
90
  end
91
91
 
@@ -8,7 +8,7 @@ include SortingTableForSpecHelper
8
8
  describe SortingTableFor, :type => :helper do
9
9
 
10
10
  before :all do
11
- (SortingTableFor::Tools::rails3?) ? routes_rails3 : routes_rails2
11
+ routes_rails
12
12
  end
13
13
 
14
14
  before :each do
@@ -24,42 +24,42 @@ describe SortingTableFor, :type => :helper do
24
24
  it "should set caption tag" do
25
25
  helper.sorting_table_for(@users) do |table|
26
26
  html = table.caption
27
- html.should have_comp_tag("caption", :count => 1)
27
+ html.should have_selector("caption", :count => 1)
28
28
  end
29
29
  end
30
30
 
31
31
  it "should set caption tag with arguments" do
32
32
  helper.sorting_table_for(@users) do |table|
33
33
  html = table.caption 'hello'
34
- html.should have_comp_tag("caption", :text => 'hello')
34
+ html.should have_selector("caption", :content => 'hello')
35
35
  end
36
36
  end
37
37
 
38
38
  it "should set caption tag with arguments and option position left" do
39
39
  helper.sorting_table_for(@users) do |table|
40
40
  html = table.caption 'hello', :position => :left
41
- html.should have_comp_tag("caption[align=left]")
41
+ html.should have_selector("caption[align=left]")
42
42
  end
43
43
  end
44
44
 
45
45
  it "should set caption tag with arguments and option position bottom" do
46
46
  helper.sorting_table_for(@users) do |table|
47
47
  html = table.caption 'hello', :position => :bottom
48
- html.should have_comp_tag("caption[align=bottom]")
48
+ html.should have_selector("caption[align=bottom]")
49
49
  end
50
50
  end
51
51
 
52
52
  it "should works with html options" do
53
53
  helper.sorting_table_for(@users) do |table|
54
54
  html = table.caption 'hello', :html => {:class => 'my_class', :id => 'my_id', :title => 'my_title'}
55
- html.should have_comp_tag("caption[class=my_class][id=my_id][title=my_title]")
55
+ html.should have_selector("caption[class=my_class][id=my_id][title=my_title]")
56
56
  end
57
57
  end
58
58
 
59
59
  it "should works with html options and position option" do
60
60
  helper.sorting_table_for(@users) do |table|
61
61
  html = table.caption 'hello', :position => :right, :html => {:class => 'my_class', :id => 'my_id', :title => 'my_title'}
62
- html.should have_comp_tag("caption[class=my_class][id=my_id][title=my_title][align=right]")
62
+ html.should have_selector("caption[class=my_class][id=my_id][title=my_title][align=right]")
63
63
  end
64
64
  end
65
65
 
@@ -70,7 +70,7 @@ describe SortingTableFor, :type => :helper do
70
70
  it "should set caption tag" do
71
71
  helper.sorting_table_for(@users) do |table|
72
72
  html = table.caption {}
73
- html.should have_comp_tag("caption", :count => 1)
73
+ html.should have_selector("caption", :count => 1)
74
74
  end
75
75
  end
76
76
 
@@ -79,7 +79,7 @@ describe SortingTableFor, :type => :helper do
79
79
  html = table.caption do
80
80
  'hello'
81
81
  end
82
- html.should have_comp_tag("caption", :text => 'hello')
82
+ html.should have_selector("caption", :content => 'hello')
83
83
  end
84
84
  end
85
85
 
@@ -88,7 +88,7 @@ describe SortingTableFor, :type => :helper do
88
88
  html = table.caption :position => :left do
89
89
  'hello'
90
90
  end
91
- html.should have_comp_tag("caption[align=left]")
91
+ html.should have_selector("caption[align=left]")
92
92
  end
93
93
  end
94
94
 
@@ -97,7 +97,7 @@ describe SortingTableFor, :type => :helper do
97
97
  html = table.caption :position => :bottom do
98
98
  'hello'
99
99
  end
100
- html.should have_comp_tag("caption[align=bottom]")
100
+ html.should have_selector("caption[align=bottom]")
101
101
  end
102
102
  end
103
103
 
@@ -106,7 +106,7 @@ describe SortingTableFor, :type => :helper do
106
106
  html = table.caption :html => {:class => 'my_class', :id => 'my_id', :title => 'my_title'} do
107
107
  'hello'
108
108
  end
109
- html.should have_comp_tag("caption[class=my_class][id=my_id][title=my_title]")
109
+ html.should have_selector("caption[class=my_class][id=my_id][title=my_title]")
110
110
  end
111
111
  end
112
112
 
@@ -115,7 +115,7 @@ describe SortingTableFor, :type => :helper do
115
115
  html = table.caption :position => :right, :html => {:class => 'my_class', :id => 'my_id', :title => 'my_title'} do
116
116
  'hello'
117
117
  end
118
- html.should have_comp_tag("caption[class=my_class][id=my_id][title=my_title][align=right]")
118
+ html.should have_selector("caption[class=my_class][id=my_id][title=my_title][align=right]")
119
119
  end
120
120
  end
121
121
 
@@ -127,36 +127,36 @@ describe SortingTableFor, :type => :helper do
127
127
  it "should set caption tag with i18n translation" do
128
128
  helper.sorting_table_for(@users) do |table|
129
129
  html = table.caption
130
- html.should have_comp_tag("caption", :count => 1)
131
- html.should have_comp_tag("caption", :text => 'Quick Caption')
130
+ html.should have_selector("caption", :count => 1)
131
+ html.should have_selector("caption", :content => 'Quick Caption')
132
132
  end
133
133
  end
134
134
 
135
135
  it "should set caption tag with arguments and option position left" do
136
136
  helper.sorting_table_for(@users) do |table|
137
137
  html = table.caption :position => :left
138
- html.should have_comp_tag("caption[align=left]")
138
+ html.should have_selector("caption[align=left]")
139
139
  end
140
140
  end
141
141
 
142
142
  it "should set caption tag with arguments and option position bottom" do
143
143
  helper.sorting_table_for(@users) do |table|
144
144
  html = table.caption :position => :bottom
145
- html.should have_comp_tag("caption[align=bottom]")
145
+ html.should have_selector("caption[align=bottom]")
146
146
  end
147
147
  end
148
148
 
149
149
  it "should works with html options" do
150
150
  helper.sorting_table_for(@users) do |table|
151
151
  html = table.caption :html => {:class => 'my_class', :id => 'my_id', :title => 'my_title'}
152
- html.should have_comp_tag("caption[class=my_class][id=my_id][title=my_title]")
152
+ html.should have_selector("caption[class=my_class][id=my_id][title=my_title]")
153
153
  end
154
154
  end
155
155
 
156
156
  it "should works with html options and position option" do
157
157
  helper.sorting_table_for(@users) do |table|
158
158
  html = table.caption :position => :right, :html => {:class => 'my_class', :id => 'my_id', :title => 'my_title'}
159
- html.should have_comp_tag("caption[class=my_class][id=my_id][title=my_title][align=right]")
159
+ html.should have_selector("caption[class=my_class][id=my_id][title=my_title][align=right]")
160
160
  end
161
161
  end
162
162
 
@@ -8,7 +8,7 @@ include SortingTableForSpecHelper
8
8
  describe SortingTableFor, :type => :helper do
9
9
 
10
10
  before :all do
11
- (SortingTableFor::Tools::rails3?) ? routes_rails3 : routes_rails2
11
+ routes_rails
12
12
  end
13
13
 
14
14
  before :each do
@@ -22,15 +22,15 @@ describe SortingTableFor, :type => :helper do
22
22
  it "should format by default values" do
23
23
  helper.sorting_table_for(@users) do |table|
24
24
  html = table.columns
25
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(1)", :text => @users.first.username)
26
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(2)", :text => @users.first.firstname)
27
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(3)", :text => @users.first.lastname)
28
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(4)", :text => @users.first.position.to_s)
29
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(5)", :text => @users.first.salary.to_s)
30
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(6)", :text => number_to_currency(@users.first.price))
31
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(7)", :text => "True")
32
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(8)", :text => I18n.l(@users.first.created_at, :format => :default))
33
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(9)", :text => I18n.l(@users.first.updated_at, :format => :default))
25
+ html.should have_selector("tr:nth-child(2) td:nth-child(1)", :content => @users.first.username)
26
+ html.should have_selector("tr:nth-child(2) td:nth-child(2)", :content => @users.first.firstname)
27
+ html.should have_selector("tr:nth-child(2) td:nth-child(3)", :content => @users.first.lastname)
28
+ html.should have_selector("tr:nth-child(2) td:nth-child(4)", :content => @users.first.position.to_s)
29
+ html.should have_selector("tr:nth-child(2) td:nth-child(5)", :content => @users.first.salary.to_s)
30
+ html.should have_selector("tr:nth-child(2) td:nth-child(6)", :content => number_to_currency(@users.first.price))
31
+ html.should have_selector("tr:nth-child(2) td:nth-child(7)", :content => "True")
32
+ html.should have_selector("tr:nth-child(2) td:nth-child(8)", :content => I18n.l(@users.first.created_at, :format => :default))
33
+ html.should have_selector("tr:nth-child(2) td:nth-child(9)", :content => I18n.l(@users.first.updated_at, :format => :default))
34
34
  end
35
35
  end
36
36
 
@@ -47,14 +47,14 @@ describe SortingTableFor, :type => :helper do
47
47
  table.column true
48
48
  table.column :active
49
49
  end
50
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(1)", :text => number_to_currency(@users.first.price))
51
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(2)", :text => number_to_currency(@users.first.price))
52
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(3)", :text => I18n.l(current_datetime, :format => :default))
53
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(4)", :text => I18n.l(current_datetime.to_date, :format => :default))
54
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(5)", :text => I18n.l(current_datetime, :format => :short))
55
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(6)", :text => I18n.l(current_datetime.to_date, :format => :short))
56
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(7)", :text => "True")
57
- html.should have_comp_tag("tr:nth-child(3) td:nth-child(8)", :text => "False")
50
+ html.should have_selector("tr:nth-child(2) td:nth-child(1)", :content => number_to_currency(@users.first.price))
51
+ html.should have_selector("tr:nth-child(2) td:nth-child(2)", :content => number_to_currency(@users.first.price))
52
+ html.should have_selector("tr:nth-child(2) td:nth-child(3)", :content => I18n.l(current_datetime, :format => :default))
53
+ html.should have_selector("tr:nth-child(2) td:nth-child(4)", :content => I18n.l(current_datetime.to_date, :format => :default))
54
+ html.should have_selector("tr:nth-child(2) td:nth-child(5)", :content => I18n.l(current_datetime, :format => :short))
55
+ html.should have_selector("tr:nth-child(2) td:nth-child(6)", :content => I18n.l(current_datetime.to_date, :format => :short))
56
+ html.should have_selector("tr:nth-child(2) td:nth-child(7)", :content => "True")
57
+ html.should have_selector("tr:nth-child(3) td:nth-child(8)", :content => "False")
58
58
  end
59
59
  end
60
60
 
@@ -65,8 +65,8 @@ describe SortingTableFor, :type => :helper do
65
65
  table.column true
66
66
  table.column :active
67
67
  end
68
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(1)", :text => "BoolTrue")
69
- html.should have_comp_tag("tr:nth-child(3) td:nth-child(2)", :text => "BoolFalse")
68
+ html.should have_selector("tr:nth-child(2) td:nth-child(1)", :content => "BoolTrue")
69
+ html.should have_selector("tr:nth-child(3) td:nth-child(2)", :content => "BoolFalse")
70
70
  end
71
71
  end
72
72
 
@@ -79,9 +79,9 @@ describe SortingTableFor, :type => :helper do
79
79
  table.column current_datetime, :as => :time
80
80
  table.column current_datetime, :as => :time, :format => :default
81
81
  end
82
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(1)", :text => I18n.l(@users.first.created_at, :format => :short))
83
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(2)", :text => I18n.l(current_datetime, :format => :short))
84
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(3)", :text => I18n.l(current_datetime, :format => :default))
82
+ html.should have_selector("tr:nth-child(2) td:nth-child(1)", :content => I18n.l(@users.first.created_at, :format => :short))
83
+ html.should have_selector("tr:nth-child(2) td:nth-child(2)", :content => I18n.l(current_datetime, :format => :short))
84
+ html.should have_selector("tr:nth-child(2) td:nth-child(3)", :content => I18n.l(current_datetime, :format => :default))
85
85
  end
86
86
  end
87
87
 
@@ -8,7 +8,7 @@ include SortingTableForSpecHelper
8
8
  describe SortingTableFor, :type => :helper do
9
9
 
10
10
  before :all do
11
- (SortingTableFor::Tools::rails3?) ? routes_rails3 : routes_rails2
11
+ routes_rails
12
12
  end
13
13
 
14
14
  before :each do
@@ -22,9 +22,9 @@ describe SortingTableFor, :type => :helper do
22
22
  it "should works" do
23
23
  helper.sorting_table_for(@users) do |table|
24
24
  html = table.columns
25
- html.should have_comp_tag("tbody", :count => 1)
26
- html.should have_comp_tag("tr", :count => (@users.size + 1))
27
- html.should have_comp_tag("td", :count => (@users.size * (SortingTableForUser.content_columns.size + 2)) + 1)
25
+ html.should have_selector("tbody", :count => 1)
26
+ html.should have_selector("tr", :count => (@users.size + 1))
27
+ html.should have_selector("td", :count => (@users.size * (SortingTableForUser.content_columns.size + 2)) + 1)
28
28
  end
29
29
  end
30
30
 
@@ -54,41 +54,41 @@ describe SortingTableFor, :type => :helper do
54
54
 
55
55
  it "should add link columns" do
56
56
  helper.sorting_table_for(@users) do |table|
57
- table.columns.should have_comp_tag('a', :count => (@users.size * 2))
57
+ table.columns.should have_selector('a', :count => (@users.size * 2))
58
58
  end
59
59
  end
60
60
 
61
61
  it "should add i18n to link columns" do
62
62
  helper.sorting_table_for(@users) do |table|
63
63
  html = table.columns
64
- html.should have_comp_tag('a', :text => 'Edit', :count => @users.size)
65
- html.should have_comp_tag('a', :text => 'Delete', :count => @users.size)
64
+ html.should have_selector('a', :content => 'Edit', :count => @users.size)
65
+ html.should have_selector('a', :content => 'Delete', :count => @users.size)
66
66
  end
67
67
  end
68
68
 
69
69
  it "should add class odd/even" do
70
70
  helper.sorting_table_for(@users) do |table|
71
71
  html = table.columns
72
- html.should have_comp_tag("tr[class=odd]", :count => (@users.size / 2))
73
- html.should have_comp_tag("tr[class=even]", :count => (@users.size / 2))
72
+ html.should have_selector("tr[class=odd]", :count => (@users.size / 2))
73
+ html.should have_selector("tr[class=even]", :count => (@users.size / 2))
74
74
  end
75
75
  end
76
76
 
77
77
  it "should customize html" do
78
78
  table_html = helper.sorting_table_for(@users, :html => { :class => 'table_class', :id => 'table_id' }) do |table|
79
79
  html = table.columns :html => { :class => 'hello_class', :id => 'hello_id', :title => 'hello_title' }
80
- html.should have_comp_tag("tr:nth-child(2)[class='hello_class odd']")
81
- html.should have_comp_tag("tr:nth-child(2)[id=hello_id]")
82
- html.should have_comp_tag("tr:nth-child(2)[title=hello_title]")
80
+ html.should have_selector("tr:nth-child(2)[class='hello_class odd']")
81
+ html.should have_selector("tr:nth-child(2)[id=hello_id]")
82
+ html.should have_selector("tr:nth-child(2)[title=hello_title]")
83
83
  end
84
84
  helper.output_buffer.concat(table_html)
85
- helper.output_buffer.should have_comp_tag("table[class='table_class sorting_table_for'][id=table_id]")
85
+ helper.output_buffer.should have_selector("table[class='table_class sorting_table_for'][id=table_id]")
86
86
  end
87
87
 
88
88
  it "should have option colspan" do
89
89
  table_html = helper.sorting_table_for(@users) do |table|
90
90
  html = table.columns :colspan => 5
91
- html.should have_comp_tag('td[colspan="5"]', :count => (@users.size * SortingTableForUser.content_columns.size))
91
+ html.should have_selector('td[colspan="5"]', :count => (@users.size * SortingTableForUser.content_columns.size))
92
92
  end
93
93
  end
94
94
 
@@ -99,81 +99,77 @@ describe SortingTableFor, :type => :helper do
99
99
  it "should works with one column" do
100
100
  helper.sorting_table_for(@users) do |table|
101
101
  html = table.columns :username
102
- html.should have_comp_tag("tbody", :count => 1)
103
- html.should have_comp_tag("tr", :count => (@users.size + 1))
104
- html.should have_comp_tag("td", :count => (@users.size + 1))
102
+ html.should have_selector("tbody", :count => 1)
103
+ html.should have_selector("tr", :count => (@users.size + 1))
104
+ html.should have_selector("td", :count => (@users.size + 1))
105
105
  end
106
106
  end
107
107
 
108
108
  it "should have multi columns" do
109
109
  helper.sorting_table_for(@users) do |table|
110
110
  html = table.columns :username, :price
111
- html.should have_comp_tag("tbody", :count => 1)
112
- html.should have_comp_tag("tr", :count => (@users.size + 1))
113
- html.should have_comp_tag("td", :count => ((@users.size * 2) + 1))
111
+ html.should have_selector("tbody", :count => 1)
112
+ html.should have_selector("tr", :count => (@users.size + 1))
113
+ html.should have_selector("td", :count => ((@users.size * 2) + 1))
114
114
  end
115
115
  end
116
116
 
117
117
  it "should have multi columns and action" do
118
118
  helper.sorting_table_for(@users) do |table|
119
- table.columns(:username, :price, :actions => :edit).should have_comp_tag("td", :count => ((@users.size * 3) + 1))
119
+ table.columns(:username, :price, :actions => :edit).should have_selector("td", :count => ((@users.size * 3) + 1))
120
120
  end
121
121
  end
122
122
 
123
123
  it "should have multi columns and multi action" do
124
124
  helper.sorting_table_for(@users) do |table|
125
- table.columns(:username, :price, :actions => [:edit, :delete]).should have_comp_tag("td", :count => ((@users.size * 4) + 1))
125
+ table.columns(:username, :price, :actions => [:edit, :delete]).should have_selector("td", :count => ((@users.size * 4) + 1))
126
126
  end
127
127
  end
128
128
 
129
129
  it "should do nothing if the key isn't correct" do
130
130
  helper.sorting_table_for(@users) do |table|
131
- table.columns(:username, :price, :blabla => :edit).should have_comp_tag("td", :count => ((@users.size * 2) + 1))
131
+ table.columns(:username, :price, :blabla => :edit).should have_selector("td", :count => ((@users.size * 2) + 1))
132
132
  end
133
133
  end
134
134
 
135
135
  it "should works symbol and non symbol" do
136
136
  helper.sorting_table_for(@users) do |table|
137
137
  html = table.columns(:username, 'hello', image_tag('rails.png'), :actions => :edit)
138
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(1)", :text => @users.first.username)
139
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(2)", :text => 'hello')
140
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(3) img")
141
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(4) a")
138
+ html.should have_selector("tr:nth-child(2) td:nth-child(1)", :content => @users.first.username)
139
+ html.should have_selector("tr:nth-child(2) td:nth-child(2)", :content => 'hello')
140
+ html.should have_selector("tr:nth-child(2) td:nth-child(3) img")
141
+ html.should have_selector("tr:nth-child(2) td:nth-child(4) a")
142
142
  end
143
143
  end
144
144
 
145
145
  it "should works with non key symbol" do
146
146
  helper.sorting_table_for(@users) do |table|
147
147
  html = table.columns(:username, :test)
148
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(1)", :text => @users.first.username)
149
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(2)", :text => '')
148
+ html.should have_selector("tr:nth-child(2) td:nth-child(1)", :content => @users.first.username)
149
+ html.should have_selector("tr:nth-child(2) td:nth-child(2)", :content => '')
150
150
  end
151
151
  end
152
152
 
153
153
  it "should add remote on link" do
154
154
  helper.sorting_table_for(@users, :link_remote => true) do |table|
155
155
  html = table.columns :username, :actions => :edit
156
- if SortingTableFor::Tools::rails3?
157
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(2) a[data-remote]")
158
- else
159
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(2) a[onclick]")
160
- end
156
+ html.should have_selector("tr:nth-child(2) td:nth-child(2) a[data-remote]")
161
157
  end
162
158
  end
163
159
 
164
160
  it "should customize html" do
165
161
  table_html = helper.sorting_table_for(@users, :html => { :class => 'table_class', :id => 'table_id' }) do |table|
166
162
  html = table.columns :username, :price, :html => { :class => 'hello_class', :id => 'hello_id', :title => 'hello_title' }
167
- html.should have_comp_tag("tr:nth-child(2)[class='hello_class odd'][id=hello_id][title=hello_title]")
163
+ html.should have_selector("tr:nth-child(2)[class='hello_class odd'][id=hello_id][title=hello_title]")
168
164
  end
169
165
  helper.output_buffer.concat(table_html)
170
- helper.output_buffer.should have_comp_tag("table[class='table_class sorting_table_for'][id=table_id]")
166
+ helper.output_buffer.should have_selector("table[class='table_class sorting_table_for'][id=table_id]")
171
167
  end
172
168
 
173
169
  it "should have option colspan" do
174
170
  table_html = helper.sorting_table_for(@users) do |table|
175
171
  html = table.columns :username, :colspan => 5
176
- html.should have_comp_tag('td[colspan="5"]', :count => @users.size)
172
+ html.should have_selector('td[colspan="5"]', :count => @users.size)
177
173
  end
178
174
  end
179
175
 
@@ -186,9 +182,9 @@ describe SortingTableFor, :type => :helper do
186
182
  html = table.columns do
187
183
  table.column :username
188
184
  end
189
- html.should have_comp_tag("tbody", :count => 1)
190
- html.should have_comp_tag("tr", :count => (@users.size + 1))
191
- html.should have_comp_tag("td", :count => (@users.size + 1))
185
+ html.should have_selector("tbody", :count => 1)
186
+ html.should have_selector("tr", :count => (@users.size + 1))
187
+ html.should have_selector("td", :count => (@users.size + 1))
192
188
  end
193
189
  end
194
190
 
@@ -198,9 +194,9 @@ describe SortingTableFor, :type => :helper do
198
194
  table.column :username
199
195
  table.column :price
200
196
  end
201
- html.should have_comp_tag("tbody", :count => 1)
202
- html.should have_comp_tag("tr", :count => (@users.size + 1))
203
- html.should have_comp_tag("td", :count => ((@users.size * 2) + 1))
197
+ html.should have_selector("tbody", :count => 1)
198
+ html.should have_selector("tr", :count => (@users.size + 1))
199
+ html.should have_selector("td", :count => ((@users.size * 2) + 1))
204
200
  end
205
201
  end
206
202
 
@@ -213,11 +209,11 @@ describe SortingTableFor, :type => :helper do
213
209
  table.column image_tag('rails.png')
214
210
  table.column :action => :edit
215
211
  end
216
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(1)", :text => @users.first.username)
217
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(2)", :text => '')
218
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(3)", :text => 'hello')
219
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(4) img")
220
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(5) a")
212
+ html.should have_selector("tr:nth-child(2) td:nth-child(1)", :content => @users.first.username)
213
+ html.should have_selector("tr:nth-child(2) td:nth-child(2)", :content => '')
214
+ html.should have_selector("tr:nth-child(2) td:nth-child(3)", :content => 'hello')
215
+ html.should have_selector("tr:nth-child(2) td:nth-child(4) img")
216
+ html.should have_selector("tr:nth-child(2) td:nth-child(5) a")
221
217
  end
222
218
  end
223
219
 
@@ -226,11 +222,11 @@ describe SortingTableFor, :type => :helper do
226
222
  html = table.columns :html => { :class => 'hello_class', :id => 'hello_id', :title => 'hello_title' } do
227
223
  table.column :username, :html => { :class => 'hi_class', :id => 'hi_id', :title => 'hi_title' }
228
224
  end
229
- html.should have_comp_tag("tr:nth-child(2)[class='hello_class odd'][id=hello_id][title=hello_title]")
230
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(1)[class='hi_class'][id=hi_id][title=hi_title]")
225
+ html.should have_selector("tr:nth-child(2)[class='hello_class odd'][id=hello_id][title=hello_title]")
226
+ html.should have_selector("tr:nth-child(2) td:nth-child(1)[class='hi_class'][id=hi_id][title=hi_title]")
231
227
  end
232
228
  helper.output_buffer.concat(table_html)
233
- helper.output_buffer.should have_comp_tag("table[class='table_class sorting_table_for'][id=table_id]")
229
+ helper.output_buffer.should have_selector("table[class='table_class sorting_table_for'][id=table_id]")
234
230
  end
235
231
 
236
232
  it "should have option colspan" do
@@ -239,8 +235,8 @@ describe SortingTableFor, :type => :helper do
239
235
  table.column :username, :colspan => 5
240
236
  table.column :price, :colspan => 3
241
237
  end
242
- html.should have_comp_tag('td[colspan="5"]', :count => @users.size)
243
- html.should have_comp_tag('td[colspan="3"]', :count => @users.size)
238
+ html.should have_selector('td[colspan="5"]', :count => @users.size)
239
+ html.should have_selector('td[colspan="3"]', :count => @users.size)
244
240
  end
245
241
  end
246
242
 
@@ -253,10 +249,10 @@ describe SortingTableFor, :type => :helper do
253
249
  html = table.columns do |value|
254
250
  table.column value.username
255
251
  end
256
- html.should have_comp_tag("tbody", :count => 1)
257
- html.should have_comp_tag("tr", :count => (@users.size + 1))
258
- html.should have_comp_tag("td", :count => (@users.size + 1))
259
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(1)", :text => @users.first.username)
252
+ html.should have_selector("tbody", :count => 1)
253
+ html.should have_selector("tr", :count => (@users.size + 1))
254
+ html.should have_selector("td", :count => (@users.size + 1))
255
+ html.should have_selector("tr:nth-child(2) td:nth-child(1)", :content => @users.first.username)
260
256
  end
261
257
  end
262
258
 
@@ -266,8 +262,8 @@ describe SortingTableFor, :type => :helper do
266
262
  table.column :price
267
263
  table.column (value.price - 1)
268
264
  end
269
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(1)", :text => number_to_currency(@users.first.price))
270
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(2)", :text => (@users.first.price - 1).to_s)
265
+ html.should have_selector("tr:nth-child(2) td:nth-child(1)", :content => number_to_currency(@users.first.price))
266
+ html.should have_selector("tr:nth-child(2) td:nth-child(2)", :content => (@users.first.price - 1).to_s)
271
267
  end
272
268
  end
273
269
 
@@ -285,12 +281,8 @@ describe SortingTableFor, :type => :helper do
285
281
  'hello'
286
282
  end
287
283
  end
288
- if SortingTableFor::Tools::rails3?
289
- html.should have_comp_tag('tr:nth-child(2) td:nth-child(1)', :text => '')
290
- else
291
- html.should have_comp_tag('tr:nth-child(2) td:nth-child(1)', :text => 'username')
292
- end
293
- html.should have_comp_tag('tr:nth-child(2) td:nth-child(2)', :text => 'hello')
284
+ html.should have_selector('tr:nth-child(2) td:nth-child(1)', :content => '')
285
+ html.should have_selector('tr:nth-child(2) td:nth-child(2)', :content => 'hello')
294
286
  end
295
287
  end
296
288
 
@@ -301,7 +293,7 @@ describe SortingTableFor, :type => :helper do
301
293
  value.username
302
294
  end
303
295
  end
304
- html.should have_comp_tag('tr:nth-child(2) td:nth-child(1)', :text => @users.first.username)
296
+ html.should have_selector('tr:nth-child(2) td:nth-child(1)', :content => @users.first.username)
305
297
  end
306
298
  end
307
299
 
@@ -312,11 +304,11 @@ describe SortingTableFor, :type => :helper do
312
304
  'hello'
313
305
  end
314
306
  end
315
- html.should have_comp_tag("tr:nth-child(2)[class='hello_class odd'][id=hello_id][title=hello_title]")
316
- html.should have_comp_tag("tr:nth-child(2) td:nth-child(1)[class='hi_class'][id=hi_id][title=hi_title]")
307
+ html.should have_selector("tr:nth-child(2)[class='hello_class odd'][id=hello_id][title=hello_title]")
308
+ html.should have_selector("tr:nth-child(2) td:nth-child(1)[class='hi_class'][id=hi_id][title=hi_title]")
317
309
  end
318
310
  helper.output_buffer.concat(table_html)
319
- helper.output_buffer.should have_comp_tag("table[class='table_class sorting_table_for'][id=table_id]")
311
+ helper.output_buffer.should have_selector("table[class='table_class sorting_table_for'][id=table_id]")
320
312
  end
321
313
 
322
314
  it "should have option colspan" do
@@ -329,8 +321,8 @@ describe SortingTableFor, :type => :helper do
329
321
  'my_colspan_2'
330
322
  end
331
323
  end
332
- html.should have_comp_tag('td[colspan="5"]', :count => @users.size)
333
- html.should have_comp_tag('td[colspan="3"]', :count => @users.size)
324
+ html.should have_selector('td[colspan="5"]', :count => @users.size)
325
+ html.should have_selector('td[colspan="3"]', :count => @users.size)
334
326
  end
335
327
  end
336
328
 
@@ -367,8 +359,8 @@ describe SortingTableFor, :type => :helper do
367
359
  SortingTableFor::TableBuilder.reserved_columns = [:id, :firstname, :lastname, :position, :salary, :price, :active, :created_at, :updated_at]
368
360
  helper.sorting_table_for(@users) do |table|
369
361
  html = table.columns
370
- html.should have_comp_tag("tr", :count => (@users.size + 1))
371
- html.should have_comp_tag("td", :count => ((@users.size * 3) + 1))
362
+ html.should have_selector("tr", :count => (@users.size + 1))
363
+ html.should have_selector("td", :count => ((@users.size * 3) + 1))
372
364
  end
373
365
  end
374
366
 
@@ -379,24 +371,34 @@ describe SortingTableFor, :type => :helper do
379
371
  table.column :username
380
372
  table.column :price
381
373
  end
382
- html.should have_comp_tag("td", :count => ((@users.size * 2) + 1))
374
+ html.should have_selector("td", :count => ((@users.size * 2) + 1))
383
375
  end
384
376
  end
385
377
 
386
- it "should edit default actions" do
378
+ it "should edit create actions" do
387
379
  SortingTableFor::TableBuilder.default_actions = [:show, :edit_password, :edit, :delete]
388
380
  helper.sorting_table_for(@users) do |table|
389
- table.columns.should have_comp_tag("td", :count => (@users.size * (SortingTableForUser.content_columns.size + 4)) + 1)
381
+ table.columns.should have_selector("td", :count => (@users.size * (SortingTableForUser.content_columns.size + 4)) + 1)
390
382
  end
391
383
  end
392
384
 
393
- it "should edit default actions" do
394
- pending('should check if the links are valids')
385
+ it "links should be correct by default" do
395
386
  SortingTableFor::TableBuilder.default_actions = [:show, :edit_password, :edit, :delete]
396
387
  helper.sorting_table_for(@users) do |table|
388
+ html = table.columns
389
+ html.should match("<a href=\"/sorting_table_for_users/#{@users.first.id}\"")
390
+ html.should match("<a href=\"/sorting_table_for_users/#{@users.first.id}/edit\"")
391
+ html.should match("<a href=\"/sorting_table_for_users/#{@users.first.id}\" data-confirm=\"translation missing: test.sorting_table_for_users.index.confirm_delete\" data-method=\"delete\" rel=\"nofollow\">")
397
392
  end
398
393
  end
399
394
 
395
+ it "should work with custom links" do
396
+ SortingTableFor::TableBuilder.default_actions = [:show, :edit_password, :edit, :delete]
397
+ helper.sorting_table_for(@users) do |table|
398
+ html = table.columns
399
+ html.should match("<a href=\"/sorting_table_for_users/#{@users.first.id}/edit_password\"")
400
+ end
401
+ end
402
+
400
403
  end
401
- ## Add spec for links
402
404
  end