table_help 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90e6ef99d9eb1a4d5f03c441e2b9669b420867a2a6312e1e2868f2b50d3a246a
4
- data.tar.gz: 0a17b288baf2470bdb44524f4ab6f0bd434c196fce8699fda2cebb0817185d68
3
+ metadata.gz: c6eb07c6d956fc01d7c308a30661e84b9091ea0cc02f95ebd7d4478107e79462
4
+ data.tar.gz: 8c42770dd22551fec9ba5edd6bb49c2954150579fbf8ee5349f0e320f8d3c3f4
5
5
  SHA512:
6
- metadata.gz: 3e696861a37a6dde529f4b4616dd9b6e3a064d0947440c55155366402608b1154716c0221133dd3f369814f195ce1932644e685b3ed47be228534de641899b3b
7
- data.tar.gz: 24db3b20f8d3d46e60053191ecef9e7f4f0f2c8c5a7d144f9acf80e20a4655f570558a67187127b3fca27c70031b9ffb208b9a02773e7399270051693cbe60ac
6
+ metadata.gz: 20d346df127433342fb904d9b8c5871c2b703a4518c12b338c990ac1b8c9d1857a8e485d44e4c084f59e95626b29f01f64c195eabe79da876b8da2916b82e1be
7
+ data.tar.gz: fea7995fb635d04bd803b01402d043c0a7a17027129c3ca7e8b927486cd4d2160125fb2270e11a2efd1a72f9ba7f921be9a9de108bbbd5d0b3541db602a2d52c
@@ -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
@@ -1,3 +1,3 @@
1
1
  module TableHelp
2
- VERSION = "0.1.5".freeze
2
+ VERSION = "0.1.6".freeze
3
3
  end
@@ -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.5
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