Class: Guard::RSpec::Graphiti::Dsl
- Inherits:
-
Object
- Object
- Guard::RSpec::Graphiti::Dsl
- Defined in:
- lib/guard/rspec/graphiti/dsl.rb
Instance Method Summary collapse
- #api_specs(resource_name = nil) ⇒ Object
-
#initialize(guard, rspec_dsl) ⇒ Dsl
constructor
A new instance of Dsl.
- #resource_specs(resource_name = nil) ⇒ Object
- #resources ⇒ Object
- #watch_models ⇒ Object
- #watch_resources ⇒ Object
Constructor Details
#initialize(guard, rspec_dsl) ⇒ Dsl
Returns a new instance of Dsl.
7 8 9 10 |
# File 'lib/guard/rspec/graphiti/dsl.rb', line 7 def initialize(guard, rspec_dsl) @guard_dsl = guard @rspec_dsl = rspec_dsl end |
Instance Method Details
#api_specs(resource_name = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/guard/rspec/graphiti/dsl.rb', line 44 def api_specs(resource_name = nil) api_base = "#{rspec.spec_dir}#{api_namespace}" if resource_name "#{api_base}/#{resource_name.underscore.pluralize}" else api_base end end |
#resource_specs(resource_name = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/guard/rspec/graphiti/dsl.rb', line 34 def resource_specs(resource_name = nil) resource_base = "#{rspec.spec_dir}/resources" if resource_name "#{resource_base}/#{resource_name.underscore}" else resource_base end end |
#resources ⇒ Object
30 31 32 |
# File 'lib/guard/rspec/graphiti/dsl.rb', line 30 def resources %r{^app/resources/(.+)_resource\.rb$} end |
#watch_models ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/guard/rspec/graphiti/dsl.rb', line 21 def watch_models @guard_dsl.send(:watch, %r{^app/models/(.+)\.rb$}) do |m| [ api_specs(m[1]), resource_specs(m[1]) ] end end |
#watch_resources ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/guard/rspec/graphiti/dsl.rb', line 12 def watch_resources @guard_dsl.send(:watch, resources) do |m| [ api_specs(m[1]), resource_specs(m[1]) ] end end |