rspec-model 0.1.0 → 0.2.0

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: 7b55660478d9c51bc6a80bd001baf2f94855e240730f1f75e7c331d5888ffae1
4
- data.tar.gz: ce0a04e24ea66bdd3a5a0e6a56a3e170d05b5d2abb0eb8d9ee1b045462a64f8f
3
+ metadata.gz: 7d18f68c0f206026dcc5b8e964b42196391e7366a3418b12aefbb0f67baab3aa
4
+ data.tar.gz: 5f06dadc0847d4299b358f21859fa6e2cde23cfd8bdd0efdfa239017d097f2da
5
5
  SHA512:
6
- metadata.gz: 733ec7eefca8bfed1c7a2f723384b9a8ace13baca7d01e92f0310768a8449fb334bfe8cac24afe4438332ba12e34dfe2625ef67cb43471c99574129954e2f023
7
- data.tar.gz: c51ed54191e752a499fc1f9fc7bf9c4597b7ad50a0a3f60dc69c7a56cc655059fa4efc0bdd41c1f1267e500f56ee08a932aff500b83ea1bea680f17a489cc398
6
+ metadata.gz: 7ba018cc9eb81b0e05938902a8a51dd91be2ca2ca10492dd6a0f77879f7363638967bb7ef0eeb3385e03a2bee54dfb024e25e314d7ed89812622e39484faca61
7
+ data.tar.gz: cf551f4365b3f6dc2caa58303edc324cb17182531737f90e4b3047418ae0301b4671799b7860cf103a3d52ee19d5bcb32130c0e65e0f8165e9f59703c9a094c0
data/CHANGELOG.md CHANGED
@@ -0,0 +1,14 @@
1
+ # Changelog
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
+
8
+ ## 0.1.1 (2022-04-05)
9
+
10
+ - Use `Array.wrap` in the `specify_user_permissions`
11
+
12
+ ## 0.1.0 (2022-04-05)
13
+
14
+ - Initial commit
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-model (0.1.0)
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.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
data/lib/rspec/specs.rb CHANGED
@@ -11,19 +11,21 @@ module RSpec
11
11
  let(:group) { build :group, permissions: [permission.to_s].compact_blank }
12
12
  let(:user) { build :user, groups: [group] }
13
13
 
14
- abilities[:can]&.each do |action|
14
+ Array.wrap(abilities[:can]).each do |action|
15
15
  it { is_expected.to be_able_to action, described_class }
16
16
  end
17
17
 
18
- abilities[:cannot]&.each do |action|
18
+ Array.wrap(abilities[:cannot]).each do |action|
19
19
  it { is_expected.not_to be_able_to action, described_class }
20
20
  end
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,59 @@ 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?
59
+ end
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
+ predicate = validate_length_of field
70
+ predicate = predicate.is_at_most(options[:at_most]) if options[:at_most]
71
+
72
+ it { is_expected.to predicate }
73
+ end
74
+
75
+ inclusion_of&.each do |field, array|
76
+ it { is_expected.to validate_inclusion_of(field).in_array array }
77
+ end
78
+
79
+ Array.wrap(acceptance_of).each do |field|
80
+ it { is_expected.to validate_acceptance_of field }
81
+ end
82
+
83
+ yield if block_given?
53
84
  end
54
85
  end
86
+
87
+ alias test_factory_validness specify_factory
88
+ alias test_associations specify_associations
89
+ alias test_validations specify_validations
55
90
  end
56
91
  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.0
4
+ version: 0.2.0
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>