guard-rspec-graphiti 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6e0eb0edfc0087ddfef3091eca921f19d2bd9715a708cea80437ed7205fcd44f
4
+ data.tar.gz: 903c4fa4a2d132cbe0782ef65071965bf22d1e63fefab25a635891ab3b5d3e73
5
+ SHA512:
6
+ metadata.gz: c328162ea5ac32ac56ebe0ca2350e3f4e12a2cdaca5246074812bec3085a3262a64959294d299c1c206ac4486f9a52394acb6a3d29eae6047c7aca6406681554
7
+ data.tar.gz: 843fe31aa1656d2012ee0a2819e67b1706364daa122ccda7e7bf4341d00ecf41cba747a32d71a63d425d3f286cebdf9810c926bb07525f71106d348df11e5e84
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.16.6
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in guard-rspec-graphiti.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,118 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ guard-rspec-graphiti (1.0.0)
5
+ graphiti
6
+ guard-rspec
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (5.2.2.1)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ coderay (1.1.2)
17
+ concurrent-ruby (1.1.5)
18
+ diff-lcs (1.3)
19
+ dry-configurable (0.8.2)
20
+ concurrent-ruby (~> 1.0)
21
+ dry-core (~> 0.4, >= 0.4.7)
22
+ dry-container (0.7.0)
23
+ concurrent-ruby (~> 1.0)
24
+ dry-configurable (~> 0.1, >= 0.1.3)
25
+ dry-core (0.4.7)
26
+ concurrent-ruby (~> 1.0)
27
+ dry-equalizer (0.2.2)
28
+ dry-inflector (0.1.2)
29
+ dry-logic (0.5.0)
30
+ dry-container (~> 0.2, >= 0.2.6)
31
+ dry-core (~> 0.2)
32
+ dry-equalizer (~> 0.2)
33
+ dry-types (0.15.0)
34
+ concurrent-ruby (~> 1.0)
35
+ dry-container (~> 0.3)
36
+ dry-core (~> 0.4, >= 0.4.4)
37
+ dry-equalizer (~> 0.2, >= 0.2.2)
38
+ dry-inflector (~> 0.1, >= 0.1.2)
39
+ dry-logic (~> 0.5, >= 0.5)
40
+ ffi (1.10.0)
41
+ formatador (0.2.5)
42
+ graphiti (1.0.rc.26)
43
+ activesupport (>= 4.1, < 6)
44
+ concurrent-ruby (~> 1.0)
45
+ dry-types (~> 0.13)
46
+ graphiti_errors (~> 1.0.beta.1)
47
+ jsonapi-serializable (~> 0.3.0)
48
+ graphiti_errors (1.0.beta.2)
49
+ jsonapi-serializable (~> 0.1)
50
+ guard (2.15.0)
51
+ formatador (>= 0.2.4)
52
+ listen (>= 2.7, < 4.0)
53
+ lumberjack (>= 1.0.12, < 2.0)
54
+ nenv (~> 0.1)
55
+ notiffany (~> 0.0)
56
+ pry (>= 0.9.12)
57
+ shellany (~> 0.0)
58
+ thor (>= 0.18.1)
59
+ guard-compat (1.2.1)
60
+ guard-rspec (4.7.3)
61
+ guard (~> 2.1)
62
+ guard-compat (~> 1.1)
63
+ rspec (>= 2.99.0, < 4.0)
64
+ i18n (1.6.0)
65
+ concurrent-ruby (~> 1.0)
66
+ jsonapi-renderer (0.2.0)
67
+ jsonapi-serializable (0.3.1)
68
+ jsonapi-renderer (~> 0.2.0)
69
+ listen (3.1.5)
70
+ rb-fsevent (~> 0.9, >= 0.9.4)
71
+ rb-inotify (~> 0.9, >= 0.9.7)
72
+ ruby_dep (~> 1.2)
73
+ lumberjack (1.0.13)
74
+ method_source (0.9.2)
75
+ minitest (5.11.3)
76
+ nenv (0.3.0)
77
+ notiffany (0.1.1)
78
+ nenv (~> 0.1)
79
+ shellany (~> 0.0)
80
+ pry (0.12.2)
81
+ coderay (~> 1.1.0)
82
+ method_source (~> 0.9.0)
83
+ rake (10.5.0)
84
+ rb-fsevent (0.10.3)
85
+ rb-inotify (0.10.0)
86
+ ffi (~> 1.0)
87
+ rspec (3.8.0)
88
+ rspec-core (~> 3.8.0)
89
+ rspec-expectations (~> 3.8.0)
90
+ rspec-mocks (~> 3.8.0)
91
+ rspec-core (3.8.0)
92
+ rspec-support (~> 3.8.0)
93
+ rspec-expectations (3.8.2)
94
+ diff-lcs (>= 1.2.0, < 2.0)
95
+ rspec-support (~> 3.8.0)
96
+ rspec-mocks (3.8.0)
97
+ diff-lcs (>= 1.2.0, < 2.0)
98
+ rspec-support (~> 3.8.0)
99
+ rspec-support (3.8.0)
100
+ ruby_dep (1.5.0)
101
+ shellany (0.0.1)
102
+ thor (0.20.3)
103
+ thread_safe (0.3.6)
104
+ tzinfo (1.2.5)
105
+ thread_safe (~> 0.1)
106
+
107
+ PLATFORMS
108
+ ruby
109
+
110
+ DEPENDENCIES
111
+ bundler (~> 1.16)
112
+ guard
113
+ guard-rspec-graphiti!
114
+ rake (~> 10.0)
115
+ rspec (~> 3.0)
116
+
117
+ BUNDLED WITH
118
+ 1.16.6
data/Guardfile ADDED
@@ -0,0 +1,17 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Wade Tandy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # Guard::Rspec::Graphiti
2
+
3
+ `guard-rspec-graphiti` is a utility gem for extending the DSL provided by [`guard-rspec`](https://github.com/guard/guard-rspec) to support the new app concepts and test types provided by [Graphiti](https://github.com/graphiti-api/graphiti).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'guard-rspec-graphiti', groups: [:development]
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install guard-rspec-graphiti
20
+
21
+ ## Usage
22
+
23
+ ### Standard Setup
24
+
25
+ This gem is designed to be used to extend the default guard-rspec template so that changes to your models and
26
+ Graphiti resources will trigger the appropriate resource and API specs. Given a guard-rspec configuration
27
+ block:
28
+
29
+ ```ruby
30
+ guard :rspec, cmd: "bundle exec rspec" do
31
+ require "guard/rspec/dsl"
32
+ dsl = Guard::RSpec::Dsl.new(self)
33
+
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+ # ...
39
+ # remaining setup
40
+ #
41
+ end
42
+ ```
43
+
44
+ We need to require the graphiti dsl setup the default watchers:
45
+
46
+ ```ruby
47
+ guard :rspec, cmd: "bundle exec rspec" do
48
+ require "guard/rspec/dsl"
49
+ dsl = Guard::RSpec::Dsl.new(self)
50
+
51
+ # Add everything below this somewhere in your `guard :rspec` block
52
+ require 'guard/rspec/graphiti/dsl'
53
+ graphiti = Guard::RSpec::Graphiti::Dsl.new(self, dsl)
54
+
55
+ graphiti.watch_resources
56
+ graphiti.watch_models
57
+ end
58
+ ```
59
+
60
+ And that's it! Now whenever you change `app/models/post.rb`, the specs in
61
+ `spec/resources/post` and `spec/api/posts` will automatically run.
62
+
63
+ ### Custom Watchers
64
+
65
+ If you have a non-standard setup or wish to add some additional control and watchers, you the dsl also
66
+ exposes some lower-level items to allow you to compose your setup a bit more granularly:
67
+
68
+ - `graphiti.resources`: A regex to match `app/resources`, with a match group for the resource name
69
+ - `graphiti.resource_specs`: The path to the spec directory for resource specs. Accepts an optional
70
+ parameter of the resource name, which will only return the directory for the specific resource
71
+ - `graphiti.api_specs`: The path to the spec directory for e2e API specs. Accepts an optional
72
+ parameter of the resource name, which will only return the directory for the specific API specs
73
+ for that resource. Like graphiti, this will default to `specs/api/v1` as the root directory, but
74
+ if the project has a `.graphiticfg.yml`, it will attempt to replace this with the `namespace`
75
+ configuration option.
76
+
77
+ ## Development
78
+
79
+ Bug reports and pull requests are welcome on GitHub at https://github.com/graphiti-api/guard-rspec-graphiti.
80
+
81
+ ## License
82
+
83
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "guard/rspec/graphiti"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,38 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "guard/rspec/graphiti/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "guard-rspec-graphiti"
8
+ spec.version = Guard::Rspec::Graphiti::VERSION
9
+ spec.authors = ["Wade Tandy"]
10
+ spec.email = ["wtandy@bloomberg.net"]
11
+
12
+ spec.summary = "Guard-rspec DSL extensions for Graphiti"
13
+ spec.description = "Guard-rspec DSL extensions for Graphiti"
14
+ spec.homepage = "https://github.com/graphiti-api/guard-rspec-graphiti"
15
+ spec.license = "MIT"
16
+
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/graphiti-api/guard-rspec-graphiti"
20
+ end
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency 'graphiti'
32
+ spec.add_dependency 'guard-rspec'
33
+
34
+ spec.add_development_dependency "guard"
35
+ spec.add_development_dependency "bundler", "~> 1.16"
36
+ spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency "rspec", "~> 3.0"
38
+ end
@@ -0,0 +1,10 @@
1
+ require "guard/compat/plugin"
2
+ require "guard/rspec"
3
+ require "guard/rspec/graphiti/version"
4
+
5
+ module Guard
6
+ class RSpec < Plugin
7
+ module Graphiti
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,70 @@
1
+ require_relative '../graphiti'
2
+
3
+ module Guard
4
+ class RSpec < Plugin
5
+ module Graphiti
6
+ class Dsl
7
+ def initialize(guard, rspec_dsl)
8
+ @guard_dsl = guard
9
+ @rspec_dsl = rspec_dsl
10
+ end
11
+
12
+ def watch_resources
13
+ @guard_dsl.send(:watch, resources) do |m|
14
+ [
15
+ api_specs(m[1]),
16
+ resource_specs(m[1])
17
+ ]
18
+ end
19
+ end
20
+
21
+ def watch_models
22
+ @guard_dsl.send(:watch, %r{^app/models/(.+)\.rb$}) do |m|
23
+ [
24
+ api_specs(m[1]),
25
+ resource_specs(m[1])
26
+ ]
27
+ end
28
+ end
29
+
30
+ def resources
31
+ %r{^app/resources/(.+)_resource\.rb$}
32
+ end
33
+
34
+ def resource_specs(resource_name = nil)
35
+ resource_base = "#{rspec.spec_dir}/resources"
36
+
37
+ if resource_name
38
+ "#{resource_base}/#{resource_name.underscore}"
39
+ else
40
+ resource_base
41
+ end
42
+ end
43
+
44
+ def api_specs(resource_name = nil)
45
+ api_base = "#{rspec.spec_dir}#{api_namespace}"
46
+
47
+ if resource_name
48
+ "#{api_base}/#{resource_name.underscore.pluralize}"
49
+ else
50
+ api_base
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ def rspec
57
+ @rspec_dsl.rspec
58
+ end
59
+
60
+ def api_namespace
61
+ graphiti_config['namespace'] || '/api/v1'
62
+ end
63
+
64
+ def graphiti_config
65
+ @graphiti_config ||= File.exist?(".graphiticfg.yml") ? YAML.load_file(".graphiticfg.yml") : {}
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,7 @@
1
+ module Guard
2
+ module Rspec
3
+ module Graphiti
4
+ VERSION = "1.0.0"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-rspec-graphiti
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Wade Tandy
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: graphiti
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: guard-rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ description: Guard-rspec DSL extensions for Graphiti
98
+ email:
99
+ - wtandy@bloomberg.net
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - Gemfile.lock
109
+ - Guardfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - guard-rspec-graphiti.gemspec
116
+ - lib/guard/rspec/graphiti.rb
117
+ - lib/guard/rspec/graphiti/dsl.rb
118
+ - lib/guard/rspec/graphiti/version.rb
119
+ homepage: https://github.com/graphiti-api/guard-rspec-graphiti
120
+ licenses:
121
+ - MIT
122
+ metadata:
123
+ homepage_uri: https://github.com/graphiti-api/guard-rspec-graphiti
124
+ source_code_uri: https://github.com/graphiti-api/guard-rspec-graphiti
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.7.9
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Guard-rspec DSL extensions for Graphiti
145
+ test_files: []