radius-spec 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +9 -0
- data/common_rubocop.yml +1 -0
- data/lib/radius/spec/model_factory.rb +13 -7
- data/lib/radius/spec/rails.rb +1 -1
- data/lib/radius/spec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39d958bd163dfff166917fa80d417ccf9afcfe576ec63e18863a75b5fdd46781
|
4
|
+
data.tar.gz: '0722783dcba93751f3b78462b9c7f75c468532b1d3f1bc929316859ed2ba3825'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ecde76170420bfd8af1f96e7430a771ac2ded9f033f4cdb509f5abe74e523ee9e9f8df8a308062f6dd6a4ba8f5f50387fdeb83fb5abb0cea1265fcbb4431f1a
|
7
|
+
data.tar.gz: 4e88ba079d4c3e64a810ec77dc0d88ab7129e7c870c473cf2ab94029a4ff2c7db69f485f44e949e0a2630aa2db86bbef5426987cb28e23ef99e50c2bd330957a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
|
+
## 0.1.1 (March 16, 2018)
|
2
|
+
|
3
|
+
[Full Changelog](https://github.com/RadiusNetworks/radius-spec/compare/v0.1.0...v0.1.1)
|
4
|
+
|
5
|
+
### Bug Fixes
|
6
|
+
|
7
|
+
- Fix `NameError: undefined local variable or method `config` for Rails RSpec
|
8
|
+
configuration (Aaron Kromer, #1)
|
9
|
+
- Fix model factory build issue in which registered template attributes, which
|
10
|
+
use symbol keys, are not replaced by custom attributes using string keys
|
11
|
+
(Aaron Kromer, #1)
|
12
|
+
- Exclude `spec/support/model_factories.rb` from `Metrics/BlockLength` in
|
13
|
+
common Rubocop config (Aaron Kromer, 714b9b3)
|
14
|
+
|
15
|
+
|
1
16
|
## 0.1.0 (March 14, 2018)
|
2
17
|
|
18
|
+
[Full Changelog](https://github.com/RadiusNetworks/radius-spec/compare/0fb9d553f493c7ba454f13c9d4332d62a336f0a4...v0.1.0)
|
19
|
+
|
3
20
|
### Initial release:
|
4
21
|
|
5
22
|
- Common Rubocop configuration
|
data/README.md
CHANGED
@@ -52,10 +52,19 @@ custom RSpec configuration in a `RSpec.configure` block as usual:
|
|
52
52
|
require 'radius/spec'
|
53
53
|
|
54
54
|
RSpec.configure do |config|
|
55
|
+
# Project's with noisy dependencies, and Rails app, include this line to
|
56
|
+
# disable warnings.
|
57
|
+
config.warnings = false
|
58
|
+
|
55
59
|
# Your project specific custom settings here
|
56
60
|
end
|
57
61
|
```
|
58
62
|
|
63
|
+
**NOTE:** By default warnings are enabled by this gem. Enabling Ruby warnings
|
64
|
+
is generally recommended. However, for large projects, and including most Rails
|
65
|
+
apps, with lots of noisy dependencies this can be an issue. For these projects,
|
66
|
+
we suggest disabling warnings per the above method.
|
67
|
+
|
59
68
|
For Rails apps, we suggest a similar approach to your Rails helper:
|
60
69
|
|
61
70
|
```ruby
|
data/common_rubocop.yml
CHANGED
@@ -67,6 +67,7 @@ Metrics/BlockLength:
|
|
67
67
|
- '**/*.rake'
|
68
68
|
- 'spec/spec_helper.rb'
|
69
69
|
- 'spec/**/*_spec.rb'
|
70
|
+
- 'spec/support/model_factories.rb'
|
70
71
|
|
71
72
|
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
72
73
|
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
@@ -253,6 +253,17 @@ module Radius
|
|
253
253
|
end
|
254
254
|
alias_method :factory, :define_factory
|
255
255
|
|
256
|
+
# @private
|
257
|
+
def merge_attrs(template, custom_attrs)
|
258
|
+
template_only = template.keys - custom_attrs.keys
|
259
|
+
template.slice(*template_only)
|
260
|
+
.delete_if { |_, v| :optional == v }
|
261
|
+
.transform_values! { |v|
|
262
|
+
::Radius::Spec::ModelFactory.safe_transform(v)
|
263
|
+
}
|
264
|
+
.merge(custom_attrs)
|
265
|
+
end
|
266
|
+
|
256
267
|
# @private
|
257
268
|
def safe_transform(value)
|
258
269
|
return value.call if value.is_a?(Proc)
|
@@ -407,13 +418,8 @@ module Radius
|
|
407
418
|
def build(name, custom_attrs = {}, &block)
|
408
419
|
name = name.to_s
|
409
420
|
template = ::Radius::Spec::ModelFactory.template(name)
|
410
|
-
|
411
|
-
attrs =
|
412
|
-
.delete_if { |_, v| :optional == v }
|
413
|
-
.transform_values! { |v|
|
414
|
-
::Radius::Spec::ModelFactory.safe_transform(v)
|
415
|
-
}
|
416
|
-
.merge(custom_attrs)
|
421
|
+
custom_attrs = custom_attrs.transform_keys(&:to_sym)
|
422
|
+
attrs = ::Radius::Spec::ModelFactory.merge_attrs(template, custom_attrs)
|
417
423
|
# TODO: Always yield to the provided block even if new doesn't
|
418
424
|
::Object.const_get(name).new(attrs, &block)
|
419
425
|
end
|
data/lib/radius/spec/rails.rb
CHANGED
@@ -5,7 +5,7 @@ require 'radius/spec'
|
|
5
5
|
require 'radius/spec/rspec'
|
6
6
|
require 'rspec/rails'
|
7
7
|
|
8
|
-
RSpec.configure do
|
8
|
+
RSpec.configure do |config|
|
9
9
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
10
10
|
config.fixture_path = ::Rails.root.join("spec", "fixtures")
|
11
11
|
|
data/lib/radius/spec/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radius-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radius Networks
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-03-
|
12
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|