rspec-model 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c3a6231e6b38e5e1cd5cefaf4c6ea04abb1fd300de366bfca26f3d80b3adbac
4
- data.tar.gz: e6269fb4d4e33f1cf2dcb9d4e01758c2cf5ec00ab18d7b236030fc6c0e30519d
3
+ metadata.gz: e1663b42b5f21becd421eeb8a7e616a8ff6dfa57e6a73d177bee123d75b1c3d2
4
+ data.tar.gz: 737185535b18c55bc9156cf0f6e8028192ccc2c3b5cafca05196d042f0167820
5
5
  SHA512:
6
- metadata.gz: 9c137de19721b4a3608c78ee558bba0f212402adb2697ad2c0c812323bd83b631252e59d1fff62b3052a2ac8596c0d47466665f8f11fc5c24c820b476f7664f5
7
- data.tar.gz: b136321e9b6495b880231203adad998c52d6c984d4a92e9f8486375ba86759a350fb1b84b5f24ba6dd25c3b5b5741f03625d87a91c5a9526bdf06e3c7b0fa7ba
6
+ metadata.gz: 357b1f1ce392cd9e5ce3ca01dfdd7fb20ea1db03dc6fe69a12617a843b706b1e278416049fee1a5e47b03350be321fb3a5f0040a3162c29623944c7f886c83b9
7
+ data.tar.gz: 84f6f0c754303c06fddaa1948173c0408db51a26b34d51587ed66144da71038f8407675291a78cc6f6fddd86e7f2f109118df43d031af7700795012b99881b15
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2 (2022-04-07)
4
+
5
+ - Remove .idea directory from the gem (#1)
6
+ - Use `Array.wrap` in the `specify_factory` and `specify_associations` (#2)
7
+
3
8
  ## 0.1.1 (2022-04-05)
4
9
 
5
10
  - Use `Array.wrap` in the `specify_user_permissions`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-model (0.1.1)
4
+ rspec-model (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rspec::Model
1
+ # RSpec::Model
2
2
 
3
3
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rspec/model`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Model
5
- VERSION = "0.1.1"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
data/lib/rspec/specs.rb CHANGED
@@ -21,9 +21,11 @@ module RSpec
21
21
  end
22
22
  end
23
23
  end
24
+
25
+ yield if block_given?
24
26
  end
25
27
 
26
- def specify_factory(factory_name: nil, traits: nil, context_name: nil) # :nodoc:
28
+ def specify_factory(factory_name: nil, traits: nil, context_name: nil) # :nodoc:
27
29
  factory_name = described_class.name.underscore.gsub('/', '_').to_sym unless factory_name
28
30
 
29
31
  describe context_name || 'factory' do
@@ -31,26 +33,61 @@ module RSpec
31
33
 
32
34
  it { is_expected.to be_valid }
33
35
 
34
- traits&.each do |trait|
36
+ Array.wrap(traits).each do |trait|
35
37
  context "with #{trait} trait" do
36
38
  subject { build_stubbed factory_name, trait }
37
39
 
38
40
  it { is_expected.to be_valid }
39
41
  end
40
42
  end
43
+
44
+ yield if block_given?
41
45
  end
42
46
  end
43
47
 
44
48
  def specify_associations(belongs_to: nil, has_many: nil, context_name: nil) # :nodoc:
45
49
  describe context_name || 'associations' do
46
- belongs_to&.each do |association|
50
+ Array.wrap(belongs_to).each do |association|
47
51
  it { is_expected.to belong_to association }
48
52
  end
49
53
 
50
- has_many&.each do |association, dependent|
54
+ Array.wrap(has_many).each do |association, dependent|
51
55
  it { is_expected.to have_many(association).dependent(dependent) }
52
56
  end
57
+
58
+ yield if block_given?
53
59
  end
54
60
  end
61
+
62
+ def specify_validations(presence_of: nil, length_of: nil, inclusion_of: nil, acceptance_of: nil, context_name: nil) # :nodoc:
63
+ describe context_name || 'validations' do
64
+ Array.wrap(presence_of).each do |field|
65
+ it { is_expected.to validate_presence_of field }
66
+ end
67
+
68
+ length_of&.each do |field, options|
69
+ it do
70
+ predicate = validate_length_of field
71
+ predicate = predicate.is_at_most(options[:at_most]) if options[:at_most]
72
+
73
+ is_expected.to predicate
74
+ end
75
+ end
76
+
77
+ inclusion_of&.each do |field, array|
78
+ it { is_expected.to validate_inclusion_of(field).in_array array }
79
+ end
80
+
81
+ Array.wrap(acceptance_of).each do |field|
82
+ it { is_expected.to validate_acceptance_of field }
83
+ end
84
+
85
+ yield if block_given?
86
+ end
87
+ end
88
+
89
+ alias test_factory_validness specify_factory
90
+ alias test_associations specify_associations
91
+ alias test_validations specify_validations
55
92
  end
56
93
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - roman.strazanec
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-05 00:00:00.000000000 Z
11
+ date: 2022-07-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Write common specifications for the models in your Ruby on Rails application.
14
14
  email:
@@ -17,11 +17,6 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".idea/.gitignore"
21
- - ".idea/misc.xml"
22
- - ".idea/modules.xml"
23
- - ".idea/rspec-model.iml"
24
- - ".idea/vcs.xml"
25
20
  - ".rspec"
26
21
  - ".standard.yml"
27
22
  - CHANGELOG.md
data/.idea/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- # Default ignored files
2
- /shelf/
3
- /workspace.xml
4
- # Editor-based HTTP Client requests
5
- /httpRequests/
6
- # Datasource local storage ignored files
7
- /dataSources/
8
- /dataSources.local.xml
9
- # CodeStream ignored files
10
- /codestream.xml
data/.idea/misc.xml DELETED
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-3.1.1" project-jdk-type="RUBY_SDK" />
4
- </project>
data/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/rspec-model.iml" filepath="$PROJECT_DIR$/.idea/rspec-model.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,74 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="ModuleRunConfigurationManager">
4
- <shared />
5
- </component>
6
- <component name="NewModuleRootManager">
7
- <content url="file://$MODULE_DIR$">
8
- <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
- <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
- <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
- </content>
12
- <orderEntry type="inheritedJdk" />
13
- <orderEntry type="sourceFolder" forTests="false" />
14
- <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-3.1.1) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.7, RVM: ruby-3.1.1) [gem]" level="application" />
16
- <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-3.1.1) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, RVM: ruby-3.1.1) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="parser (v3.1.1.0, RVM: ruby-3.1.1) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-3.1.1) [gem]" level="application" />
20
- <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-3.1.1) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.2.1, RVM: ruby-3.1.1) [gem]" level="application" />
22
- <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-3.1.1) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="rspec (v3.11.0, RVM: ruby-3.1.1) [gem]" level="application" />
24
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.11.0, RVM: ruby-3.1.1) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.11.0, RVM: ruby-3.1.1) [gem]" level="application" />
26
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.11.1, RVM: ruby-3.1.1) [gem]" level="application" />
27
- <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.11.0, RVM: ruby-3.1.1) [gem]" level="application" />
28
- <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.26.1, RVM: ruby-3.1.1) [gem]" level="application" />
29
- <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.16.0, RVM: ruby-3.1.1) [gem]" level="application" />
30
- <orderEntry type="library" scope="PROVIDED" name="rubocop-performance (v1.13.3, RVM: ruby-3.1.1) [gem]" level="application" />
31
- <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, RVM: ruby-3.1.1) [gem]" level="application" />
32
- <orderEntry type="library" scope="PROVIDED" name="standard (v1.9.1, RVM: ruby-3.1.1) [gem]" level="application" />
33
- <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, RVM: ruby-3.1.1) [gem]" level="application" />
34
- </component>
35
- <component name="RakeTasksCache">
36
- <option name="myRootTask">
37
- <RakeTaskImpl id="rake">
38
- <subtasks>
39
- <RakeTaskImpl description="Build rspec-model-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
40
- <RakeTaskImpl id="build">
41
- <subtasks>
42
- <RakeTaskImpl description="Generate SHA512 checksum if rspec-model-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
43
- </subtasks>
44
- </RakeTaskImpl>
45
- <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
46
- <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
47
- <RakeTaskImpl description="Build and install rspec-model-0.1.0.gem into system gems" fullCommand="install" id="install" />
48
- <RakeTaskImpl id="install">
49
- <subtasks>
50
- <RakeTaskImpl description="Build and install rspec-model-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
51
- </subtasks>
52
- </RakeTaskImpl>
53
- <RakeTaskImpl description="Create tag v0.1.0 and build and push rspec-model-0.1.0.gem to TODO: Set to your gem server 'https://example.com'" fullCommand="release[remote]" id="release[remote]" />
54
- <RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
55
- <RakeTaskImpl description="Lint with the Standard Ruby style guide" fullCommand="standard" id="standard" />
56
- <RakeTaskImpl id="standard">
57
- <subtasks>
58
- <RakeTaskImpl description="Lint and automatically fix with the Standard Ruby style guide" fullCommand="standard:fix" id="fix" />
59
- </subtasks>
60
- </RakeTaskImpl>
61
- <RakeTaskImpl description="" fullCommand="default" id="default" />
62
- <RakeTaskImpl description="" fullCommand="release" id="release" />
63
- <RakeTaskImpl id="release">
64
- <subtasks>
65
- <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
66
- <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
67
- <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
68
- </subtasks>
69
- </RakeTaskImpl>
70
- </subtasks>
71
- </RakeTaskImpl>
72
- </option>
73
- </component>
74
- </module>
data/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>