Skip to content

Commit d9d1485

Browse files
added integration test, little refactoring
1 parent 10d8c1f commit d9d1485

File tree

15 files changed

+74
-35
lines changed

15 files changed

+74
-35
lines changed

Gemfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,12 @@ gem "sqlite3"
88

99
# Start debugger with binding.b [https://github.com/ruby/debug]
1010
# gem "debug", ">= 1.0.0"
11+
12+
gem "sprockets-rails"
13+
gem "pry"
14+
gem "wrapped_print"
15+
16+
group :test do
17+
gem "capybara"
18+
gem "selenium-webdriver"
19+
end

Gemfile.lock

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
lazy_value (0.1.0)
5-
ast
6-
parser
4+
lazy_value (0.0.1)
75
rails
86

97
GEM
@@ -74,8 +72,18 @@ GEM
7472
i18n (>= 1.6, < 2)
7573
minitest (>= 5.1)
7674
tzinfo (~> 2.0)
77-
ast (2.4.2)
75+
addressable (2.8.4)
76+
public_suffix (>= 2.0.2, < 6.0)
7877
builder (3.2.4)
78+
capybara (3.39.0)
79+
addressable
80+
matrix
81+
mini_mime (>= 0.1.3)
82+
nokogiri (~> 1.8)
83+
rack (>= 1.6.0)
84+
rack-test (>= 0.6.3)
85+
regexp_parser (>= 1.5, < 3.0)
86+
xpath (~> 3.2)
7987
coderay (1.1.3)
8088
concurrent-ruby (1.2.2)
8189
crass (1.0.6)
@@ -94,6 +102,7 @@ GEM
94102
net-pop
95103
net-smtp
96104
marcel (1.0.2)
105+
matrix (0.4.2)
97106
method_source (1.0.0)
98107
mini_mime (1.1.2)
99108
minitest (5.18.0)
@@ -109,11 +118,10 @@ GEM
109118
nio4r (2.5.9)
110119
nokogiri (1.14.3-x86_64-darwin)
111120
racc (~> 1.4)
112-
parser (3.2.2.0)
113-
ast (~> 2.4.1)
114121
pry (0.14.2)
115122
coderay (~> 1.1)
116123
method_source (~> 1.0)
124+
public_suffix (5.0.1)
117125
puma (6.2.1)
118126
nio4r (~> 2.0)
119127
racc (1.6.2)
@@ -147,6 +155,13 @@ GEM
147155
thor (~> 1.0)
148156
zeitwerk (~> 2.5)
149157
rake (13.0.6)
158+
regexp_parser (2.7.0)
159+
rexml (3.2.5)
160+
rubyzip (2.3.2)
161+
selenium-webdriver (4.8.6)
162+
rexml (~> 3.2, >= 3.2.5)
163+
rubyzip (>= 1.2.2, < 3.0)
164+
websocket (~> 1.0)
150165
sprockets (4.2.0)
151166
concurrent-ruby (~> 1.0)
152167
rack (>= 2.2.4, < 4)
@@ -159,20 +174,25 @@ GEM
159174
timeout (0.3.2)
160175
tzinfo (2.0.6)
161176
concurrent-ruby (~> 1.0)
177+
websocket (1.2.9)
162178
websocket-driver (0.7.5)
163179
websocket-extensions (>= 0.1.0)
164180
websocket-extensions (0.1.5)
165181
wrapped_print (0.1.1)
166182
activesupport
183+
xpath (3.2.0)
184+
nokogiri (~> 1.8)
167185
zeitwerk (2.6.7)
168186

169187
PLATFORMS
170188
x86_64-darwin-21
171189

172190
DEPENDENCIES
191+
capybara
173192
lazy_value!
174193
pry
175194
puma
195+
selenium-webdriver
176196
sprockets-rails
177197
sqlite3
178198
wrapped_print

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# LazyValue
2+
23
Short description and motivation.
34

45
## Usage
6+
57
How to use my plugin.
68

79
## Installation
10+
811
Add this line to your application's Gemfile:
912

1013
```ruby
@@ -21,8 +24,13 @@ Or install it yourself as:
2124
$ gem install lazy_value
2225
```
2326

27+
## Testing
28+
29+
`bin/rails test:system`.
30+
2431
## Contributing
25-
Contribution directions go here.
32+
33+
You are welcome to contribute.
2634

2735
## License
2836
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

Rakefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
require "bundler/setup"
22

33
require "bundler/gem_tasks"
4+
5+
require_relative "test/dummy/config/application"
6+
7+
Rails.application.load_tasks

app/controllers/lazy_value/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base
33
REGEX = /<%= lazy_value_tag (?:do|{.+?}) %>(.+?)<% end %>|<%= lazy_value_tag { (.+?) } %>/m
44

55
def show
6-
data = JSON.parse(LazyValue.message_encryptor.decrypt_and_verify(payload))
6+
data = JSON.parse(LazyValue.cryptography.decrypt_and_verify(payload))
77
code = File.read(data["path"]).lines[data["lineno"]-1..-1].join
88
str = code.match(REGEX)
99

app/helpers/lazy_value/application_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def lazy_value_tag(options: {}, &block)
1111
options[:class] ||= "lazy-value-tag"
1212
options[:id] = element_id
1313

14-
data = LazyValue.message_encryptor.encrypt_and_sign(
14+
data = LazyValue.cryptography.encrypt_and_sign(
1515
{
1616
path: kaller.path,
1717
lineno: kaller.lineno

lazy_value.gemspec

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ require_relative "lib/lazy_value/version"
33
Gem::Specification.new do |spec|
44
spec.name = "lazy_value"
55
spec.version = LazyValue::VERSION
6-
spec.authors = ["Igor Kasyanchuk"]
7-
spec.email = ["[email protected]"]
6+
spec.authors = ["Igor Kasyanchuk", "Liubomyr Manastyretskyi"]
7+
88
spec.homepage = "https://github.com/railsjazz.com/lazy_value"
9-
spec.summary = "Summary of LazyValue."
10-
spec.description = "Description of LazyValue."
9+
spec.summary = "Lazy load values in Rails views."
10+
spec.description = "Lazy load values in Rails views."
1111
spec.license = "MIT"
1212

1313
spec.metadata["homepage_uri"] = spec.homepage
1414

1515
spec.add_dependency "rails"
16-
spec.add_dependency "parser"
17-
spec.add_dependency "ast"
1816
spec.add_development_dependency "puma"
1917
spec.add_development_dependency "pry"
2018
spec.add_development_dependency "wrapped_print"
2119
spec.add_development_dependency "sprockets-rails"
20+
spec.add_development_dependency "capybara"
21+
spec.add_development_dependency "selenium-webdriver"
2222
end

lib/lazy_value.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
require 'parser/current'
2-
require 'ast'
31
require "lazy_value/version"
42
require "lazy_value/routes"
53
require "lazy_value/engine"
64

75
module LazyValue
8-
mattr_accessor :message_encryptor
6+
mattr_accessor :cryptography
97

10-
@@message_encryptor = begin
8+
@@cryptography = begin
119
len = ActiveSupport::MessageEncryptor.key_len
1210
salt = SecureRandom.random_bytes(len)
1311
key = ActiveSupport::KeyGenerator.new(SecureRandom.hex(32)).generate_key(salt, len)

lib/lazy_value/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module LazyValue
2-
VERSION = "0.1.0"
2+
VERSION = "0.0.1"
33
end

test/application_system_test_case.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require "test_helper"
2+
3+
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
4+
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
5+
end

0 commit comments

Comments
 (0)