Merge pull request #121 from SuperTux88/update-ruby-and-gems
Drop ruby 2.5 (EOL) and 2.6 (EOL soon) and update gems
This commit is contained in:
commit
9ea7115362
25 changed files with 227 additions and 167 deletions
|
|
@ -2,7 +2,7 @@
|
|||
engines:
|
||||
rubocop:
|
||||
enabled: true
|
||||
channel: rubocop-1-10-0
|
||||
channel: rubocop-1-22-3
|
||||
bundler-audit:
|
||||
enabled: true
|
||||
ratings:
|
||||
|
|
|
|||
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
|
|
@ -14,10 +14,9 @@ jobs:
|
|||
fail-fast: false
|
||||
matrix:
|
||||
ruby:
|
||||
- 3.0
|
||||
- 2.7
|
||||
- 2.6
|
||||
- 2.5
|
||||
- "3.1"
|
||||
- "3.0"
|
||||
- "2.7"
|
||||
gemfile:
|
||||
- Gemfile
|
||||
- test/gemfiles/no-rails.Gemfile
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
require: rubocop-rails
|
||||
require:
|
||||
- rubocop-rails
|
||||
- rubocop-rake
|
||||
|
||||
AllCops:
|
||||
TargetRubyVersion: 2.5
|
||||
TargetRubyVersion: 2.7
|
||||
NewCops: enable
|
||||
Exclude:
|
||||
- "bin/**/*"
|
||||
|
|
@ -12,7 +14,7 @@ Rails:
|
|||
Enabled: true
|
||||
|
||||
# Commonly used screens these days easily fit more than 80 characters.
|
||||
Metrics/LineLength:
|
||||
Layout/LineLength:
|
||||
Max: 120
|
||||
|
||||
# Too short methods lead to extraction of single-use methods, which can make
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.0
|
||||
3.1
|
||||
|
|
|
|||
5
Gemfile
5
Gemfile
|
|
@ -21,8 +21,9 @@ group :development do
|
|||
# code style
|
||||
gem "pronto", "0.11.0", require: false
|
||||
gem "pronto-rubocop", "0.11.1", require: false
|
||||
gem "rubocop", "1.18.0", require: false
|
||||
gem "rubocop-rails", "2.11.1", require: false
|
||||
gem "rubocop", "1.23.0", require: false
|
||||
gem "rubocop-rails", "2.12.4", require: false
|
||||
gem "rubocop-rake", "0.6.0", require: false
|
||||
|
||||
# debugging
|
||||
gem "pry"
|
||||
|
|
|
|||
104
Gemfile.lock
104
Gemfile.lock
|
|
@ -19,26 +19,26 @@ PATH
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionpack (6.1.4)
|
||||
actionview (= 6.1.4)
|
||||
activesupport (= 6.1.4)
|
||||
actionpack (6.1.4.1)
|
||||
actionview (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
rack (~> 2.0, >= 2.0.9)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||
actionview (6.1.4)
|
||||
activesupport (= 6.1.4)
|
||||
actionview (6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||
activesupport (6.1.4)
|
||||
activesupport (6.1.4.1)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 1.6, < 2)
|
||||
minitest (>= 5.1)
|
||||
tzinfo (~> 2.0)
|
||||
zeitwerk (~> 2.3)
|
||||
addressable (2.7.0)
|
||||
addressable (2.8.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
ast (2.4.2)
|
||||
builder (3.2.4)
|
||||
|
|
@ -51,25 +51,31 @@ GEM
|
|||
diff-lcs (1.4.4)
|
||||
docile (1.4.0)
|
||||
erubi (1.10.0)
|
||||
ethon (0.14.0)
|
||||
ethon (0.15.0)
|
||||
ffi (>= 1.15.0)
|
||||
fabrication (2.22.0)
|
||||
faraday (1.4.3)
|
||||
faraday (1.8.0)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
faraday-httpclient (~> 1.0.1)
|
||||
faraday-net_http (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.1)
|
||||
faraday-patron (~> 1.0)
|
||||
faraday-rack (~> 1.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-em_http (1.0.0)
|
||||
faraday-em_synchrony (1.0.0)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-net_http (1.0.1)
|
||||
faraday-net_http_persistent (1.1.0)
|
||||
faraday_middleware (1.0.0)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
faraday_middleware (1.2.0)
|
||||
faraday (~> 1.0)
|
||||
ffi (1.15.3)
|
||||
ffi (1.15.4)
|
||||
fuubar (2.5.1)
|
||||
rspec-core (~> 3.0)
|
||||
ruby-progressbar (~> 1.4)
|
||||
|
|
@ -77,42 +83,42 @@ GEM
|
|||
httparty (~> 0.18)
|
||||
terminal-table (~> 1.5, >= 1.5.1)
|
||||
hashdiff (1.0.1)
|
||||
httparty (0.18.1)
|
||||
httparty (0.20.0)
|
||||
mime-types (~> 3.0)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (1.8.10)
|
||||
i18n (1.8.11)
|
||||
concurrent-ruby (~> 1.0)
|
||||
json-schema (2.8.1)
|
||||
addressable (>= 2.4)
|
||||
json-schema-rspec (0.0.4)
|
||||
json-schema (~> 2.5)
|
||||
rspec
|
||||
listen (3.5.1)
|
||||
listen (3.7.0)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
loofah (2.10.0)
|
||||
loofah (2.12.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
macaddr (1.7.2)
|
||||
systemu (~> 2.6.5)
|
||||
method_source (1.0.0)
|
||||
mime-types (3.3.1)
|
||||
mime-types (3.4.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2021.0225)
|
||||
mini_portile2 (2.5.3)
|
||||
mime-types-data (3.2021.1115)
|
||||
mini_portile2 (2.8.0)
|
||||
minitest (5.14.4)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
nokogiri (1.11.7)
|
||||
mini_portile2 (~> 2.5.0)
|
||||
nokogiri (1.13.3)
|
||||
mini_portile2 (~> 2.8.0)
|
||||
racc (~> 1.4)
|
||||
nyan-cat-formatter (0.12.0)
|
||||
rspec (>= 2.99, >= 2.14.2, < 4)
|
||||
octokit (4.21.0)
|
||||
faraday (>= 0.9)
|
||||
sawyer (~> 0.8.0, >= 0.5.3)
|
||||
parallel (1.20.1)
|
||||
parser (3.0.1.1)
|
||||
parallel (1.21.0)
|
||||
parser (3.0.3.0)
|
||||
ast (~> 2.4.1)
|
||||
pronto (0.11.0)
|
||||
gitlab (~> 4.4, >= 4.4.0)
|
||||
|
|
@ -125,30 +131,30 @@ GEM
|
|||
pronto-rubocop (0.11.1)
|
||||
pronto (~> 0.11.0)
|
||||
rubocop (>= 0.63.1, < 2.0)
|
||||
pry (0.13.1)
|
||||
pry (0.14.1)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
pry-byebug (3.9.0)
|
||||
pry-byebug (3.8.0)
|
||||
byebug (~> 11.0)
|
||||
pry (~> 0.13.0)
|
||||
pry (~> 0.10)
|
||||
public_suffix (4.0.6)
|
||||
racc (1.5.2)
|
||||
racc (1.6.0)
|
||||
rack (2.2.3)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.3.0)
|
||||
rails-html-sanitizer (1.4.2)
|
||||
loofah (~> 2.3)
|
||||
railties (6.1.4)
|
||||
actionpack (= 6.1.4)
|
||||
activesupport (= 6.1.4)
|
||||
railties (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
method_source
|
||||
rake (>= 0.13)
|
||||
thor (~> 1.0)
|
||||
rainbow (3.0.0)
|
||||
rake (13.0.3)
|
||||
rake (13.0.6)
|
||||
rb-fsevent (0.11.0)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
|
|
@ -169,7 +175,7 @@ GEM
|
|||
rspec-mocks (3.10.2)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.10.0)
|
||||
rspec-rails (5.0.1)
|
||||
rspec-rails (5.0.2)
|
||||
actionpack (>= 5.2)
|
||||
activesupport (>= 5.2)
|
||||
railties (>= 5.2)
|
||||
|
|
@ -177,24 +183,26 @@ GEM
|
|||
rspec-expectations (~> 3.10)
|
||||
rspec-mocks (~> 3.10)
|
||||
rspec-support (~> 3.10)
|
||||
rspec-support (3.10.2)
|
||||
rubocop (1.18.0)
|
||||
rspec-support (3.10.3)
|
||||
rubocop (1.23.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.0.0.0)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml
|
||||
rubocop-ast (>= 1.7.0, < 2.0)
|
||||
rubocop-ast (>= 1.12.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 1.4.0, < 3.0)
|
||||
rubocop-ast (1.7.0)
|
||||
rubocop-ast (1.13.0)
|
||||
parser (>= 3.0.1.1)
|
||||
rubocop-rails (2.11.1)
|
||||
rubocop-rails (2.12.4)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-rake (0.6.0)
|
||||
rubocop (~> 1.0)
|
||||
ruby-progressbar (1.11.0)
|
||||
ruby2_keywords (0.0.4)
|
||||
ruby2_keywords (0.0.5)
|
||||
rugged (1.0.1)
|
||||
sawyer (0.8.2)
|
||||
addressable (>= 2.3.5)
|
||||
|
|
@ -208,23 +216,22 @@ GEM
|
|||
simplecov (>= 0.4.1)
|
||||
simplecov_json_formatter (0.1.3)
|
||||
systemu (2.6.5)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
terminal-table (1.6.0)
|
||||
thor (1.1.0)
|
||||
typhoeus (1.4.0)
|
||||
ethon (>= 0.9.0)
|
||||
tzinfo (2.0.4)
|
||||
concurrent-ruby (~> 1.0)
|
||||
unicode-display_width (1.7.0)
|
||||
unicode-display_width (2.1.0)
|
||||
uuid (2.3.9)
|
||||
macaddr (~> 1.0)
|
||||
valid (1.2.0)
|
||||
webmock (3.13.0)
|
||||
addressable (>= 2.3.6)
|
||||
webmock (3.14.0)
|
||||
addressable (>= 2.8.0)
|
||||
crack (>= 0.3.2)
|
||||
hashdiff (>= 0.4.0, < 2.0.0)
|
||||
yard (0.9.26)
|
||||
zeitwerk (2.4.2)
|
||||
zeitwerk (2.5.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
|
@ -247,12 +254,13 @@ DEPENDENCIES
|
|||
rspec-collection_matchers (~> 1.2.0)
|
||||
rspec-json_expectations (~> 2.1)
|
||||
rspec-rails (~> 5.0.1)
|
||||
rubocop (= 1.18.0)
|
||||
rubocop-rails (= 2.11.1)
|
||||
rubocop (= 1.23.0)
|
||||
rubocop-rails (= 2.12.4)
|
||||
rubocop-rake (= 0.6.0)
|
||||
simplecov (= 0.21.2)
|
||||
simplecov-rcov (= 0.2.3)
|
||||
webmock (~> 3.0)
|
||||
yard
|
||||
|
||||
BUNDLED WITH
|
||||
2.2.21
|
||||
2.3.7
|
||||
|
|
|
|||
1
Rakefile
1
Rakefile
|
|
@ -29,5 +29,6 @@ end
|
|||
|
||||
Bundler::GemHelper.install_tasks name: "diaspora_federation"
|
||||
|
||||
desc "Run all tests"
|
||||
task test: :spec
|
||||
task default: :test
|
||||
|
|
|
|||
|
|
@ -16,8 +16,11 @@ Gem::Specification.new do |s|
|
|||
s.description = "This gem provides JSON schemas (currently one schema) for "\
|
||||
"validating JSON serialized federation objects."
|
||||
s.license = "AGPL-3.0"
|
||||
s.metadata = {
|
||||
"rubygems_mfa_required" => "true"
|
||||
}
|
||||
|
||||
s.files = Dir["lib/diaspora_federation/schemas.rb", "lib/diaspora_federation/schemas/*.json"]
|
||||
s.files = Dir["lib/diaspora_federation/schemas.rb", "lib/diaspora_federation/schemas/*.json"]
|
||||
|
||||
s.required_ruby_version = ">= 2.5"
|
||||
s.required_ruby_version = ">= 2.7"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,11 +15,14 @@ Gem::Specification.new do |s|
|
|||
s.summary = "diaspora* federation rails engine"
|
||||
s.description = "A rails engine that adds the diaspora* federation protocol to a rails app"
|
||||
s.license = "AGPL-3.0"
|
||||
s.metadata = {
|
||||
"rubygems_mfa_required" => "true"
|
||||
}
|
||||
|
||||
s.files = Dir["app/**/*", "config/routes.rb", "config/initializers/*",
|
||||
"lib/diaspora_federation/{engine,rails}.rb", "LICENSE", "README.md", "Changelog.md"]
|
||||
s.files = Dir["app/**/*", "config/routes.rb", "config/initializers/*",
|
||||
"lib/diaspora_federation/{engine,rails}.rb", "LICENSE", "README.md", "Changelog.md"]
|
||||
|
||||
s.required_ruby_version = ">= 2.5"
|
||||
s.required_ruby_version = ">= 2.7"
|
||||
|
||||
s.add_dependency "actionpack", ">= 5.2", "< 7"
|
||||
|
||||
|
|
|
|||
|
|
@ -16,10 +16,13 @@ Gem::Specification.new do |s|
|
|||
s.description = "This gem provides some supplimentary code (factory definitions), that"\
|
||||
"helps to build tests for users of the diaspora_federation gem."
|
||||
s.license = "AGPL-3.0"
|
||||
s.metadata = {
|
||||
"rubygems_mfa_required" => "true"
|
||||
}
|
||||
|
||||
s.files = Dir["lib/diaspora_federation/test.rb", "lib/diaspora_federation/test/*"]
|
||||
s.files = Dir["lib/diaspora_federation/test.rb", "lib/diaspora_federation/test/*"]
|
||||
|
||||
s.required_ruby_version = ">= 2.5"
|
||||
s.required_ruby_version = ">= 2.7"
|
||||
|
||||
s.add_dependency "diaspora_federation", DiasporaFederation::VERSION
|
||||
s.add_dependency "fabrication", "~> 2.16"
|
||||
|
|
|
|||
|
|
@ -17,14 +17,17 @@ Gem::Specification.new do |s|
|
|||
"de-/encryption of Entities in the protocols used for communication " \
|
||||
"among the various installations of Diaspora*"
|
||||
s.license = "AGPL-3.0"
|
||||
s.metadata = {
|
||||
"rubygems_mfa_required" => "true"
|
||||
}
|
||||
|
||||
s.files = Dir["lib/**/*", "LICENSE", "README.md", "Changelog.md"] -
|
||||
Dir["lib/diaspora_federation/{engine,rails,schemas,test}.rb",
|
||||
"lib/diaspora_federation/schemas/*",
|
||||
"lib/diaspora_federation/test/*",
|
||||
"lib/tasks/*.rake"]
|
||||
s.files = Dir["lib/**/*", "LICENSE", "README.md", "Changelog.md"] -
|
||||
Dir["lib/diaspora_federation/{engine,rails,schemas,test}.rb",
|
||||
"lib/diaspora_federation/schemas/*",
|
||||
"lib/diaspora_federation/test/*",
|
||||
"lib/tasks/*.rake"]
|
||||
|
||||
s.required_ruby_version = ">= 2.5"
|
||||
s.required_ruby_version = ">= 2.7"
|
||||
|
||||
s.add_dependency "faraday", "~> 1.0"
|
||||
s.add_dependency "faraday_middleware", "~> 1.0"
|
||||
|
|
|
|||
|
|
@ -95,9 +95,9 @@ module DiasporaFederation
|
|||
# The order for signing
|
||||
# @return [Array]
|
||||
def signature_order
|
||||
@signature_order || self.class.class_props.keys.reject {|key|
|
||||
@signature_order || (self.class.class_props.keys.reject {|key|
|
||||
self.class.optional_props.include?(key) && public_send(key).nil?
|
||||
} - %i[author_signature parent]
|
||||
} - %i[author_signature parent])
|
||||
end
|
||||
|
||||
private
|
||||
|
|
@ -136,7 +136,7 @@ module DiasporaFederation
|
|||
|
||||
def signature_order=(order)
|
||||
prop_names = self.class.class_props.keys.map(&:to_s)
|
||||
@signature_order = order.reject {|name| name =~ /signature/ }
|
||||
@signature_order = order.grep_v(/signature/)
|
||||
.map {|name| prop_names.include?(name) ? name.to_sym : name }
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ module DiasporaFederation
|
|||
end
|
||||
|
||||
def setable_property?(type, val)
|
||||
setable_string?(type, val) || type == :timestamp && val.is_a?(Time)
|
||||
setable_string?(type, val) || (type == :timestamp && val.is_a?(Time))
|
||||
end
|
||||
|
||||
def setable_string?(type, val)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ module DiasporaFederation
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8"></meta>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>#{person.full_name}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -86,19 +86,19 @@ module DiasporaFederation
|
|||
<dl class="entity_photo">
|
||||
<dt>Photo</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="300" height="300" src="#{photo_large_url}"></img>
|
||||
<img class="photo avatar" width="300" height="300" src="#{photo_large_url}"/>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo_medium">
|
||||
<dt>Photo_medium</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="100" height="100" src="#{photo_medium_url}"></img>
|
||||
<img class="photo avatar" width="100" height="100" src="#{photo_medium_url}"/>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo_small">
|
||||
<dt>Photo_small</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="50" height="50" src="#{photo_small_url}"></img>
|
||||
<img class="photo avatar" width="50" height="50" src="#{photo_small_url}"/>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
|
@ -137,10 +137,9 @@ module DiasporaFederation
|
|||
it "reads minimal hCard" do
|
||||
minimal_html = <<~HTML
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta charset="UTF-8" />
|
||||
<meta charset="UTF-8"/>
|
||||
<title>#{person.full_name}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -187,19 +186,19 @@ module DiasporaFederation
|
|||
<dl class="entity_photo">
|
||||
<dt>Photo</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="300" height="300" src="#{photo_large_url}" />
|
||||
<img class="photo avatar" width="300" height="300" src="#{photo_large_url}"/>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo_medium">
|
||||
<dt>Photo_medium</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="100" height="100" src="#{photo_medium_url}" />
|
||||
<img class="photo avatar" width="100" height="100" src="#{photo_medium_url}"/>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo_small">
|
||||
<dt>Photo_small</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="50" height="50" src="#{photo_small_url}" />
|
||||
<img class="photo avatar" width="50" height="50" src="#{photo_small_url}"/>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ module DiasporaFederation
|
|||
expect(entity.test1).to be_nil
|
||||
end
|
||||
|
||||
context "validation" do
|
||||
context "when validating" do
|
||||
let(:invalid_data) { {test1: "as;df", test2: nil, test3: "no boolean"} }
|
||||
|
||||
it "validates the entity and raise an error with failed properties if not valid" do
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ module DiasporaFederation
|
|||
end
|
||||
|
||||
it "doesn't fail when the entity doesn't have optional props" do
|
||||
entity = OpenStruct.new(test1: nil)
|
||||
entity = Struct.new(:test1).new(nil)
|
||||
validator = Validators::TestUnknownEntityValidator.new(entity)
|
||||
expect(validator).not_to be_valid
|
||||
expect(validator.errors).to include(:test1)
|
||||
|
|
|
|||
|
|
@ -12,9 +12,13 @@ describe Validation::Rule::Birthday do
|
|||
expect(described_class.new.error_key).to eq(:birthday)
|
||||
end
|
||||
|
||||
context "validation" do
|
||||
context "when validating" do
|
||||
before do
|
||||
stub_const("BirthdayHolder", Struct.new(:birthday))
|
||||
end
|
||||
|
||||
it "validates a date object" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(birthday: Date.new))
|
||||
validator = Validation::Validator.new(BirthdayHolder.new(Date.new))
|
||||
validator.rule(:birthday, :birthday)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -22,7 +26,7 @@ describe Validation::Rule::Birthday do
|
|||
end
|
||||
|
||||
it "validates a string" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(birthday: "2015-07-19"))
|
||||
validator = Validation::Validator.new(BirthdayHolder.new("2015-07-19"))
|
||||
validator.rule(:birthday, :birthday)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -31,7 +35,7 @@ describe Validation::Rule::Birthday do
|
|||
|
||||
it "allows nil and empty" do
|
||||
[nil, ""].each do |val|
|
||||
validator = Validation::Validator.new(OpenStruct.new(birthday: val))
|
||||
validator = Validation::Validator.new(BirthdayHolder.new(val))
|
||||
validator.rule(:birthday, :birthday)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -40,7 +44,7 @@ describe Validation::Rule::Birthday do
|
|||
end
|
||||
|
||||
it "fails for invalid date string" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(birthday: "i'm no date"))
|
||||
validator = Validation::Validator.new(BirthdayHolder.new("i'm no date"))
|
||||
validator.rule(:birthday, :birthday)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ describe Validation::Rule::Boolean do
|
|||
it "will not accept parameters" do
|
||||
validator = Validation::Validator.new({})
|
||||
expect {
|
||||
validator.rule(:number, numeric: {param: true})
|
||||
validator.rule(:boolean, boolean: {param: true})
|
||||
}.to raise_error ArgumentError
|
||||
end
|
||||
|
||||
|
|
@ -12,11 +12,15 @@ describe Validation::Rule::Boolean do
|
|||
expect(described_class.new.error_key).to eq(:boolean)
|
||||
end
|
||||
|
||||
context "validation" do
|
||||
context "when validating" do
|
||||
before do
|
||||
stub_const("BooleanHolder", Struct.new(:boolean))
|
||||
end
|
||||
|
||||
context "strings" do
|
||||
it "validates boolean-esque strings" do
|
||||
%w[true false yes no t f y n 1 0].each do |str|
|
||||
validator = Validation::Validator.new(OpenStruct.new(boolean: str))
|
||||
validator = Validation::Validator.new(BooleanHolder.new(str))
|
||||
validator.rule(:boolean, :boolean)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -25,7 +29,7 @@ describe Validation::Rule::Boolean do
|
|||
end
|
||||
|
||||
it "fails for non-boolean-esque strings" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(boolean: "asdf"))
|
||||
validator = Validation::Validator.new(BooleanHolder.new("asdf"))
|
||||
validator.rule(:boolean, :boolean)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -36,7 +40,7 @@ describe Validation::Rule::Boolean do
|
|||
context "numbers" do
|
||||
it "validates 0 and 1 to boolean" do
|
||||
[0, 1].each do |num|
|
||||
validator = Validation::Validator.new(OpenStruct.new(boolean: num))
|
||||
validator = Validation::Validator.new(BooleanHolder.new(num))
|
||||
validator.rule(:boolean, :boolean)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -45,7 +49,7 @@ describe Validation::Rule::Boolean do
|
|||
end
|
||||
|
||||
it "fails for all other numbers" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(boolean: 1234))
|
||||
validator = Validation::Validator.new(BooleanHolder.new(1234))
|
||||
validator.rule(:boolean, :boolean)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -56,7 +60,7 @@ describe Validation::Rule::Boolean do
|
|||
context "boolean types" do
|
||||
it "validates true and false" do
|
||||
[true, false].each do |bln|
|
||||
validator = Validation::Validator.new(OpenStruct.new(boolean: bln))
|
||||
validator = Validation::Validator.new(BooleanHolder.new(bln))
|
||||
validator.rule(:boolean, :boolean)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -67,7 +71,7 @@ describe Validation::Rule::Boolean do
|
|||
|
||||
it "fails if nil or empty" do
|
||||
[nil, ""].each do |val|
|
||||
validator = Validation::Validator.new(OpenStruct.new(boolean: val))
|
||||
validator = Validation::Validator.new(BooleanHolder.new(val))
|
||||
validator.rule(:boolean, :boolean)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
|
|||
|
|
@ -39,9 +39,13 @@ describe Validation::Rule::DiasporaIdList do
|
|||
expect(described_class.new(maximum: 5).error_key).to eq(:diaspora_id_list)
|
||||
end
|
||||
|
||||
context "validation" do
|
||||
context "when validating" do
|
||||
before do
|
||||
stub_const("DiasporaIdsHolder", Struct.new(:ids))
|
||||
end
|
||||
|
||||
it "validates less ids" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(ids: id_str))
|
||||
validator = Validation::Validator.new(DiasporaIdsHolder.new(id_str))
|
||||
validator.rule(:ids, diaspora_id_list: {maximum: 5})
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -50,7 +54,7 @@ describe Validation::Rule::DiasporaIdList do
|
|||
|
||||
it "fails for less but non ids" do
|
||||
bad_str = "user@example.com;i am a weird diaspora* ID @@@ ### 12345;shouldnt be reached by a rule"
|
||||
validator = Validation::Validator.new(OpenStruct.new(ids: bad_str))
|
||||
validator = Validation::Validator.new(DiasporaIdsHolder.new(bad_str))
|
||||
validator.rule(:ids, diaspora_id_list: {maximum: 5})
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -58,7 +62,7 @@ describe Validation::Rule::DiasporaIdList do
|
|||
end
|
||||
|
||||
it "validates exactly as many ids" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(ids: id_str))
|
||||
validator = Validation::Validator.new(DiasporaIdsHolder.new(id_str))
|
||||
validator.rule(:ids, diaspora_id_list: {minimum: 3, maximum: 3})
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -66,7 +70,7 @@ describe Validation::Rule::DiasporaIdList do
|
|||
end
|
||||
|
||||
it "validates without params" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(ids: id_str))
|
||||
validator = Validation::Validator.new(DiasporaIdsHolder.new(id_str))
|
||||
validator.rule(:ids, :diaspora_id_list)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -74,7 +78,7 @@ describe Validation::Rule::DiasporaIdList do
|
|||
end
|
||||
|
||||
it "fails for too many ids" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(ids: id_str))
|
||||
validator = Validation::Validator.new(DiasporaIdsHolder.new(id_str))
|
||||
validator.rule(:ids, diaspora_id_list: {maximum: 2})
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -82,7 +86,7 @@ describe Validation::Rule::DiasporaIdList do
|
|||
end
|
||||
|
||||
it "fails for too less ids" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(ids: id_str))
|
||||
validator = Validation::Validator.new(DiasporaIdsHolder.new(id_str))
|
||||
validator.rule(:ids, diaspora_id_list: {minimum: 4})
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
|
|||
|
|
@ -12,9 +12,13 @@ describe Validation::Rule::DiasporaId do
|
|||
expect(described_class.new.error_key).to eq(:diaspora_id)
|
||||
end
|
||||
|
||||
context "validation" do
|
||||
context "when validating" do
|
||||
before do
|
||||
stub_const("DiasporaIdHolder", Struct.new(:diaspora_id))
|
||||
end
|
||||
|
||||
it "validates a normal diaspora* ID" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@example.com"))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new("some_user@example.com"))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -22,7 +26,7 @@ describe Validation::Rule::DiasporaId do
|
|||
end
|
||||
|
||||
it "validates a diaspora* ID with localhost" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@localhost"))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new("some_user@localhost"))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -30,7 +34,7 @@ describe Validation::Rule::DiasporaId do
|
|||
end
|
||||
|
||||
it "validates a diaspora* ID with port" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@example.com:3000"))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new("some_user@example.com:3000"))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -38,7 +42,7 @@ describe Validation::Rule::DiasporaId do
|
|||
end
|
||||
|
||||
it "validates a diaspora* ID with IPv4 address" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@123.45.67.89"))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new("some_user@123.45.67.89"))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -46,7 +50,7 @@ describe Validation::Rule::DiasporaId do
|
|||
end
|
||||
|
||||
it "validates a diaspora* ID with IPv6 address" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@[2001:1234:5678:90ab:cdef::1]"))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new("some_user@[2001:1234:5678:90ab:cdef::1]"))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -54,7 +58,7 @@ describe Validation::Rule::DiasporaId do
|
|||
end
|
||||
|
||||
it "validates a diaspora* ID with . and -" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some-fancy.user@example.com"))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new("some-fancy.user@example.com"))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -62,7 +66,7 @@ describe Validation::Rule::DiasporaId do
|
|||
end
|
||||
|
||||
it "fails if the diaspora* ID contains a / in the domain-name" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@example.com/friendica"))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new("some_user@example.com/friendica"))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -70,7 +74,7 @@ describe Validation::Rule::DiasporaId do
|
|||
end
|
||||
|
||||
it "fails if the diaspora* ID contains a _ in the domain-name" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@invalid_domain.com"))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new("some_user@invalid_domain.com"))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -78,7 +82,7 @@ describe Validation::Rule::DiasporaId do
|
|||
end
|
||||
|
||||
it "fails if the diaspora* ID contains a special-chars in the username" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user$^%@example.com"))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new("some_user$^%@example.com"))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -86,7 +90,7 @@ describe Validation::Rule::DiasporaId do
|
|||
end
|
||||
|
||||
it "fails if the diaspora* ID contains uppercase characters in the username" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "SOME_USER@example.com"))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new("SOME_USER@example.com"))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -94,7 +98,7 @@ describe Validation::Rule::DiasporaId do
|
|||
end
|
||||
|
||||
it "fails if the diaspora* ID contains uppercase characters in the domain-name" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "some_user@EXAMPLE.com"))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new("some_user@EXAMPLE.com"))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -102,7 +106,7 @@ describe Validation::Rule::DiasporaId do
|
|||
end
|
||||
|
||||
it "fails if the diaspora* ID is longer than 255 characters" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: "#{'a' * 244}@example.com"))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new("#{'a' * 244}@example.com"))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -111,7 +115,7 @@ describe Validation::Rule::DiasporaId do
|
|||
|
||||
it "fails for nil and empty" do
|
||||
[nil, ""].each do |val|
|
||||
validator = Validation::Validator.new(OpenStruct.new(diaspora_id: val))
|
||||
validator = Validation::Validator.new(DiasporaIdHolder.new(val))
|
||||
validator.rule(:diaspora_id, :diaspora_id)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
|
|||
|
|
@ -12,9 +12,13 @@ describe Validation::Rule::Guid do
|
|||
expect(described_class.new.error_key).to eq(:guid)
|
||||
end
|
||||
|
||||
context "validation" do
|
||||
context "when validating" do
|
||||
before do
|
||||
stub_const("GuidHolder", Struct.new(:guid))
|
||||
end
|
||||
|
||||
it "validates a string at least 16 chars long, consisting of [0-9a-f] (diaspora)" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(guid: "abcdef0123456789"))
|
||||
validator = Validation::Validator.new(GuidHolder.new("abcdef0123456789"))
|
||||
validator.rule(:guid, :guid)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -22,9 +26,7 @@ describe Validation::Rule::Guid do
|
|||
end
|
||||
|
||||
it "validates a long string with random characters and [-_@.:] (redmatrix)" do
|
||||
validator = Validation::Validator.new(
|
||||
OpenStruct.new(guid: "1234567890ABCDefgh_ijkl-mnopqrSTUVwxyz@example.com:3000")
|
||||
)
|
||||
validator = Validation::Validator.new(GuidHolder.new("1234567890ABCDefgh_ijkl-mnopqrSTUVwxyz@example.com:3000"))
|
||||
validator.rule(:guid, :guid)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -32,7 +34,7 @@ describe Validation::Rule::Guid do
|
|||
end
|
||||
|
||||
it "fails if the string is too short" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(guid: "012345"))
|
||||
validator = Validation::Validator.new(GuidHolder.new("012345"))
|
||||
validator.rule(:guid, :guid)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -40,7 +42,7 @@ describe Validation::Rule::Guid do
|
|||
end
|
||||
|
||||
it "fails if the string is too long" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(guid: "a" * 256))
|
||||
validator = Validation::Validator.new(GuidHolder.new("a" * 256))
|
||||
validator.rule(:guid, :guid)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -48,7 +50,7 @@ describe Validation::Rule::Guid do
|
|||
end
|
||||
|
||||
it "fails if the string contains special chars at the end" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(guid: "abcdef0123456789."))
|
||||
validator = Validation::Validator.new(GuidHolder.new("abcdef0123456789."))
|
||||
validator.rule(:guid, :guid)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -56,7 +58,7 @@ describe Validation::Rule::Guid do
|
|||
end
|
||||
|
||||
it "fails if the string contains invalid chars" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(guid: "ghijklmnopqrstuvwxyz++"))
|
||||
validator = Validation::Validator.new(GuidHolder.new("ghijklmnopqrstuvwxyz++"))
|
||||
validator.rule(:guid, :guid)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -65,7 +67,7 @@ describe Validation::Rule::Guid do
|
|||
|
||||
it "fails if the string is empty" do
|
||||
[nil, ""].each do |val|
|
||||
validator = Validation::Validator.new(OpenStruct.new(guid: val))
|
||||
validator = Validation::Validator.new(GuidHolder.new(val))
|
||||
validator.rule(:guid, :guid)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
|
|||
|
|
@ -12,34 +12,38 @@ describe Validation::Rule::NotNil do
|
|||
expect(described_class.new.error_key).to eq(:not_nil)
|
||||
end
|
||||
|
||||
context "validation" do
|
||||
context "when validating" do
|
||||
before do
|
||||
stub_const("ValueHolder", Struct.new(:value))
|
||||
end
|
||||
|
||||
it "validates a string" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(not_nil: "abcd"))
|
||||
validator.rule(:not_nil, :not_nil)
|
||||
validator = Validation::Validator.new(ValueHolder.new("abcd"))
|
||||
validator.rule(:value, :not_nil)
|
||||
|
||||
expect(validator).to be_valid
|
||||
expect(validator.errors).to be_empty
|
||||
end
|
||||
|
||||
it "validates a object" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(not_nil: Object.new))
|
||||
validator.rule(:not_nil, :not_nil)
|
||||
validator = Validation::Validator.new(ValueHolder.new(Object.new))
|
||||
validator.rule(:value, :not_nil)
|
||||
|
||||
expect(validator).to be_valid
|
||||
expect(validator.errors).to be_empty
|
||||
end
|
||||
|
||||
it "fails if it is nil" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(not_nil: nil))
|
||||
validator.rule(:not_nil, :not_nil)
|
||||
validator = Validation::Validator.new(ValueHolder.new(nil))
|
||||
validator.rule(:value, :not_nil)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
expect(validator.errors).to include(:not_nil)
|
||||
expect(validator.errors).to include(:value)
|
||||
end
|
||||
|
||||
it "allows an empty string" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(not_nil: ""))
|
||||
validator.rule(:not_nil, :not_nil)
|
||||
validator = Validation::Validator.new(ValueHolder.new(""))
|
||||
validator.rule(:value, :not_nil)
|
||||
|
||||
expect(validator).to be_valid
|
||||
expect(validator.errors).to be_empty
|
||||
|
|
|
|||
|
|
@ -12,7 +12,11 @@ describe Validation::Rule::PublicKey do
|
|||
expect(described_class.new.error_key).to eq(:public_key)
|
||||
end
|
||||
|
||||
context "validation" do
|
||||
context "when validating" do
|
||||
before do
|
||||
stub_const("PublicKeyHolder", Struct.new(:key))
|
||||
end
|
||||
|
||||
["PUBLIC KEY", "RSA PUBLIC KEY"].each do |key_type|
|
||||
context key_type do
|
||||
let(:prefix) { "-----BEGIN #{key_type}-----" }
|
||||
|
|
@ -21,7 +25,7 @@ describe Validation::Rule::PublicKey do
|
|||
let(:key) { "#{prefix}\nAAAAAA==\n#{suffix}\n" }
|
||||
|
||||
it "validates an exported RSA key" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(key: key))
|
||||
validator = Validation::Validator.new(PublicKeyHolder.new(key))
|
||||
validator.rule(:key, :public_key)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -29,7 +33,7 @@ describe Validation::Rule::PublicKey do
|
|||
end
|
||||
|
||||
it "strips whitespace" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(key: " \n #{key}\n \n "))
|
||||
validator = Validation::Validator.new(PublicKeyHolder.new(" \n #{key}\n \n "))
|
||||
validator.rule(:key, :public_key)
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -37,7 +41,7 @@ describe Validation::Rule::PublicKey do
|
|||
end
|
||||
|
||||
it "fails if the prefix is missing" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(key: "\nAAAAAA==\n#{suffix}\n"))
|
||||
validator = Validation::Validator.new(PublicKeyHolder.new("\nAAAAAA==\n#{suffix}\n"))
|
||||
validator.rule(:key, :public_key)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -45,7 +49,7 @@ describe Validation::Rule::PublicKey do
|
|||
end
|
||||
|
||||
it "fails if the suffix is missing" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(key: "#{prefix}\nAAAAAA==\n\n"))
|
||||
validator = Validation::Validator.new(PublicKeyHolder.new("#{prefix}\nAAAAAA==\n\n"))
|
||||
validator.rule(:key, :public_key)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -54,7 +58,7 @@ describe Validation::Rule::PublicKey do
|
|||
|
||||
it "fails if the key is nil or empty" do
|
||||
[nil, ""].each do |val|
|
||||
validator = Validation::Validator.new(OpenStruct.new(key: val))
|
||||
validator = Validation::Validator.new(PublicKeyHolder.new(val))
|
||||
validator.rule(:key, :public_key)
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
|
|||
|
|
@ -21,11 +21,15 @@ describe Validation::Rule::TagCount do
|
|||
expect(described_class.new(maximum: 5).error_key).to eq(:tag_count)
|
||||
end
|
||||
|
||||
context "validation" do
|
||||
context "when validating" do
|
||||
let(:tag_str) { "#i #love #tags" }
|
||||
|
||||
before do
|
||||
stub_const("TagsHolder", Struct.new(:tags))
|
||||
end
|
||||
|
||||
it "validates less tags" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(tags: tag_str))
|
||||
validator = Validation::Validator.new(TagsHolder.new(tag_str))
|
||||
validator.rule(:tags, tag_count: {maximum: 5})
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -33,7 +37,7 @@ describe Validation::Rule::TagCount do
|
|||
end
|
||||
|
||||
it "validates exactly as many tags" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(tags: tag_str))
|
||||
validator = Validation::Validator.new(TagsHolder.new(tag_str))
|
||||
validator.rule(:tags, tag_count: {maximum: 3})
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
@ -41,7 +45,7 @@ describe Validation::Rule::TagCount do
|
|||
end
|
||||
|
||||
it "fails for too many tags" do
|
||||
validator = Validation::Validator.new(OpenStruct.new(tags: tag_str))
|
||||
validator = Validation::Validator.new(TagsHolder.new(tag_str))
|
||||
validator.rule(:tags, tag_count: {maximum: 1})
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
@ -50,7 +54,7 @@ describe Validation::Rule::TagCount do
|
|||
|
||||
it "allows nil and empty" do
|
||||
[nil, ""].each do |val|
|
||||
validator = Validation::Validator.new(OpenStruct.new(tags: val))
|
||||
validator = Validation::Validator.new(TagsHolder.new(val))
|
||||
validator.rule(:tags, tag_count: {maximum: 5})
|
||||
|
||||
expect(validator).to be_valid
|
||||
|
|
|
|||
|
|
@ -16,31 +16,37 @@ PATH
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
addressable (2.7.0)
|
||||
addressable (2.8.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
crack (0.4.5)
|
||||
rexml
|
||||
diff-lcs (1.4.4)
|
||||
docile (1.4.0)
|
||||
ethon (0.14.0)
|
||||
ethon (0.15.0)
|
||||
ffi (>= 1.15.0)
|
||||
fabrication (2.22.0)
|
||||
faraday (1.4.3)
|
||||
faraday (1.8.0)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
faraday-httpclient (~> 1.0.1)
|
||||
faraday-net_http (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.1)
|
||||
faraday-patron (~> 1.0)
|
||||
faraday-rack (~> 1.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-em_http (1.0.0)
|
||||
faraday-em_synchrony (1.0.0)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-net_http (1.0.1)
|
||||
faraday-net_http_persistent (1.1.0)
|
||||
faraday_middleware (1.0.0)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
faraday_middleware (1.2.0)
|
||||
faraday (~> 1.0)
|
||||
ffi (1.15.3)
|
||||
ffi (1.15.4)
|
||||
fuubar (2.5.1)
|
||||
rspec-core (~> 3.0)
|
||||
ruby-progressbar (~> 1.4)
|
||||
|
|
@ -52,14 +58,16 @@ GEM
|
|||
rspec
|
||||
macaddr (1.7.2)
|
||||
systemu (~> 2.6.5)
|
||||
mini_portile2 (2.8.0)
|
||||
multipart-post (2.1.1)
|
||||
nokogiri (1.11.7-x86_64-linux)
|
||||
nokogiri (1.13.3)
|
||||
mini_portile2 (~> 2.8.0)
|
||||
racc (~> 1.4)
|
||||
nyan-cat-formatter (0.12.0)
|
||||
rspec (>= 2.99, >= 2.14.2, < 4)
|
||||
public_suffix (4.0.6)
|
||||
racc (1.5.2)
|
||||
rake (13.0.3)
|
||||
racc (1.6.0)
|
||||
rake (13.0.6)
|
||||
rexml (3.2.5)
|
||||
rspec (3.10.0)
|
||||
rspec-core (~> 3.10.0)
|
||||
|
|
@ -76,9 +84,9 @@ GEM
|
|||
rspec-mocks (3.10.2)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.10.0)
|
||||
rspec-support (3.10.2)
|
||||
rspec-support (3.10.3)
|
||||
ruby-progressbar (1.11.0)
|
||||
ruby2_keywords (0.0.4)
|
||||
ruby2_keywords (0.0.5)
|
||||
simplecov (0.21.2)
|
||||
docile (~> 1.1)
|
||||
simplecov-html (~> 0.11)
|
||||
|
|
@ -93,8 +101,8 @@ GEM
|
|||
uuid (2.3.9)
|
||||
macaddr (~> 1.0)
|
||||
valid (1.2.0)
|
||||
webmock (3.13.0)
|
||||
addressable (>= 2.3.6)
|
||||
webmock (3.14.0)
|
||||
addressable (>= 2.8.0)
|
||||
crack (>= 0.3.2)
|
||||
hashdiff (>= 0.4.0, < 2.0.0)
|
||||
|
||||
|
|
@ -117,4 +125,4 @@ DEPENDENCIES
|
|||
webmock (~> 3.0)
|
||||
|
||||
BUNDLED WITH
|
||||
2.2.21
|
||||
2.3.7
|
||||
|
|
|
|||
Loading…
Reference in a new issue