table_help 0.1.5 → 0.1.6
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.
- checksums.yaml +4 -4
- data/lib/table_help/config.rb +2 -0
- data/lib/table_help/version.rb +1 -1
- data/spec/helper_spec.rb +51 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6eb07c6d956fc01d7c308a30661e84b9091ea0cc02f95ebd7d4478107e79462
|
4
|
+
data.tar.gz: 8c42770dd22551fec9ba5edd6bb49c2954150579fbf8ee5349f0e320f8d3c3f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20d346df127433342fb904d9b8c5871c2b703a4518c12b338c990ac1b8c9d1857a8e485d44e4c084f59e95626b29f01f64c195eabe79da876b8da2916b82e1be
|
7
|
+
data.tar.gz: fea7995fb635d04bd803b01402d043c0a7a17027129c3ca7e8b927486cd4d2160125fb2270e11a2efd1a72f9ba7f921be9a9de108bbbd5d0b3541db602a2d52c
|
data/lib/table_help/config.rb
CHANGED
@@ -14,6 +14,8 @@ module TableHelp
|
|
14
14
|
case collection_or_resource
|
15
15
|
when ActiveRecord::Relation
|
16
16
|
collection_or_resource.model.human_attribute_name(name)
|
17
|
+
when Enumerable
|
18
|
+
collection_or_resource.first.class.human_attribute_name(name)
|
17
19
|
else
|
18
20
|
collection_or_resource.class.human_attribute_name(name)
|
19
21
|
end
|
data/lib/table_help/version.rb
CHANGED
data/spec/helper_spec.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe TableHelp::Helper do
|
4
|
+
include TableHelp::Helper
|
5
|
+
include ActionView::Context
|
6
|
+
include ActionView::Helpers::TagHelper
|
7
|
+
include ActionView::Helpers::TextHelper
|
8
|
+
include Capybara::RSpecMatchers
|
9
|
+
|
10
|
+
describe "#table_for" do
|
11
|
+
before do
|
12
|
+
Article.create(title: "My Awesome Title", body: "Lorem ipsum dolor sit amet")
|
13
|
+
end
|
14
|
+
|
15
|
+
subject do
|
16
|
+
table_for articles do |t|
|
17
|
+
t.column :title
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when passed an ActiveRecord::Relation" do
|
22
|
+
let(:articles) { Article.all }
|
23
|
+
|
24
|
+
it "builds an HTML table" do
|
25
|
+
is_expected.to have_css "td.col-title", text: "My Awesome Title"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when passed an ActiveRecord::Relation" do
|
30
|
+
let(:articles) { Article.all.to_a }
|
31
|
+
|
32
|
+
it "builds an HTML table" do
|
33
|
+
is_expected.to have_css "td.col-title", text: "My Awesome Title"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#attributes_table_for" do
|
39
|
+
let(:article) { Article.new(title: "My Awesome Title") }
|
40
|
+
|
41
|
+
subject do
|
42
|
+
attributes_table_for article do |t|
|
43
|
+
t.row :title
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it "builds an HTML table" do
|
48
|
+
is_expected.to have_css "td.col-title", text: "My Awesome Title"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_help
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshiyuki Hirano
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- spec/fake_app/application.rb
|
63
63
|
- spec/fake_app/config.ru
|
64
64
|
- spec/fake_app/log/development.log
|
65
|
+
- spec/helper_spec.rb
|
65
66
|
- spec/spec_helper.rb
|
66
67
|
- spec/table_help_spec.rb
|
67
68
|
homepage: https://github.com/yhirano55/table_help
|
@@ -96,3 +97,4 @@ test_files:
|
|
96
97
|
- spec/fake_app/application.rb
|
97
98
|
- spec/fake_app/log/development.log
|
98
99
|
- spec/table_help_spec.rb
|
100
|
+
- spec/helper_spec.rb
|