table_help 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ # load Rails first
4
+ require "rails"
5
+
6
+ # load the plugin
7
+ require "table_help"
8
+
9
+ # needs to load the app next
10
+ require "fake_app/application"
11
+
12
+ require "capybara/rspec"
13
+ require "capybara/rails"
14
+ require "pry"
15
+
16
+ RSpec.configure do |config|
17
+ config.example_status_persistence_file_path = ".rspec_status"
18
+ config.disable_monkey_patching!
19
+
20
+ config.expect_with :rspec do |c|
21
+ c.syntax = :expect
22
+ end
23
+ end
24
+
25
+ CreateArticles.migrate(:up) unless ActiveRecord::Base.connection.table_exists? "articles"
@@ -0,0 +1,41 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe TableHelp, type: :feature do
4
+ before do
5
+ 3.times.each do |i|
6
+ Article.create(title: "My Awesome Title #{i}", body: ("abc#{i}" * 30))
7
+ end
8
+ end
9
+
10
+ describe "#table_for" do
11
+ subject { page.body }
12
+
13
+ it "display table" do
14
+ visit "/articles"
15
+ Article.all.find_each do |article|
16
+ within("tr.table-row-article#{article.id}") do
17
+ is_expected.to have_css "td.col-title", text: article.title
18
+ is_expected.to have_css "td.col-body", text: article.body.truncate(26)
19
+ is_expected.to have_css "td.col-created_at", text: I18n.l(article.created_at)
20
+ is_expected.to have_css "td.col-updated_at", text: I18n.l(article.updated_at)
21
+ is_expected.to have_link "Show", href: "/articles/#{article.id}"
22
+ is_expected.to have_link "Edit", href: "/articles/#{article.id}/edit"
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ describe "#attributes_table_for" do
29
+ let(:article) { Article.all.sample }
30
+ subject { page.body }
31
+
32
+ it "display table" do
33
+ visit "/articles/#{article.id}"
34
+ is_expected.to have_css "td.col-title", text: article.title
35
+ is_expected.to have_css "td.col-body", text: article.body.truncate(26)
36
+ is_expected.to have_css "td.col-created_at", text: I18n.l(article.created_at)
37
+ is_expected.to have_css "td.col-updated_at", text: I18n.l(article.updated_at)
38
+ is_expected.to have_link "Edit", href: "/articles/#{article.id}/edit"
39
+ end
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: table_help
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yoshiyuki Hirano
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-10-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ description: Provide helper methods to build collection or resource tables for Rails
42
+ 5
43
+ email:
44
+ - yhirano@me.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - README.md
50
+ - Rakefile
51
+ - lib/table_help.rb
52
+ - lib/table_help/attributes_table_for.rb
53
+ - lib/table_help/config.rb
54
+ - lib/table_help/formatter.rb
55
+ - lib/table_help/helper.rb
56
+ - lib/table_help/railtie.rb
57
+ - lib/table_help/strategy.rb
58
+ - lib/table_help/table_for.rb
59
+ - lib/table_help/version.rb
60
+ - spec/fake_app/app/views/articles/index.html.erb
61
+ - spec/fake_app/app/views/articles/show.html.erb
62
+ - spec/fake_app/application.rb
63
+ - spec/fake_app/config.ru
64
+ - spec/fake_app/log/development.log
65
+ - spec/spec_helper.rb
66
+ - spec/table_help_spec.rb
67
+ homepage: https://github.com/yhirano55/table_help
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 2.2.0
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.6.13
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Provide helper methods to build collection or resource tables for Rails 5
91
+ test_files:
92
+ - spec/fake_app/app/views/articles/index.html.erb
93
+ - spec/fake_app/app/views/articles/show.html.erb
94
+ - spec/fake_app/application.rb
95
+ - spec/fake_app/config.ru
96
+ - spec/fake_app/log/development.log
97
+ - spec/spec_helper.rb
98
+ - spec/table_help_spec.rb