No release in over 3 years
Low commit activity in last 3 years
Guard-rspec DSL extensions for Graphiti
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
>= 0
~> 10.0
~> 3.0

Runtime

 Project Readme

Guard::Rspec::Graphiti

guard-rspec-graphiti is a utility gem for extending the DSL provided by guard-rspec to support the new app concepts and test types provided by Graphiti.

Installation

Add this line to your application's Gemfile:

gem 'guard-rspec-graphiti', groups: [:development]

And then execute:

$ bundle

Or install it yourself as:

$ gem install guard-rspec-graphiti

Usage

Standard Setup

This gem is designed to be used to extend the default guard-rspec template so that changes to your models and Graphiti resources will trigger the appropriate resource and API specs. Given a guard-rspec configuration block:

guard :rspec, cmd: "bundle exec rspec" do
  require "guard/rspec/dsl"
  dsl = Guard::RSpec::Dsl.new(self)

  rspec = dsl.rspec
  watch(rspec.spec_helper) { rspec.spec_dir }
  watch(rspec.spec_support) { rspec.spec_dir }
  watch(rspec.spec_files)
  # ...
  # remaining setup
  #
end

We need to require the graphiti dsl setup the default watchers:

guard :rspec, cmd: "bundle exec rspec" do
  require "guard/rspec/dsl"
  dsl = Guard::RSpec::Dsl.new(self)

  # Add everything below this somewhere in your `guard :rspec` block
  require 'guard/rspec/graphiti/dsl'
  graphiti = Guard::RSpec::Graphiti::Dsl.new(self, dsl)

  graphiti.watch_resources
  graphiti.watch_models
end

And that's it! Now whenever you change app/models/post.rb, the specs in spec/resources/post and spec/api/posts will automatically run.

Custom Watchers

If you have a non-standard setup or wish to add some additional control and watchers, you the dsl also exposes some lower-level items to allow you to compose your setup a bit more granularly:

  • graphiti.resources: A regex to match app/resources, with a match group for the resource name
  • graphiti.resource_specs: The path to the spec directory for resource specs. Accepts an optional parameter of the resource name, which will only return the directory for the specific resource
  • graphiti.api_specs: The path to the spec directory for e2e API specs. Accepts an optional parameter of the resource name, which will only return the directory for the specific API specs for that resource. Like graphiti, this will default to specs/api/v1 as the root directory, but if the project has a .graphiticfg.yml, it will attempt to replace this with the namespace configuration option.

Development

Bug reports and pull requests are welcome on GitHub at https://github.com/graphiti-api/guard-rspec-graphiti.

License

The gem is available as open source under the terms of the MIT License.