lib/generators/graphiti/resource_test_generator.rb in graphiti-1.0.rc.21 vs lib/generators/graphiti/resource_test_generator.rb in graphiti-1.0.rc.22
- old
+ new
@@ -1,23 +1,23 @@
$:.unshift File.dirname(__FILE__)
-require 'generator_mixin'
+require "generator_mixin"
module Graphiti
class ResourceTestGenerator < ::Rails::Generators::Base
include GeneratorMixin
- source_root File.expand_path('../templates', __FILE__)
+ source_root File.expand_path("../templates", __FILE__)
argument :resource, type: :string
argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
- class_option :'actions',
+ class_option :actions,
type: :array,
default: nil,
- aliases: ['--actions', '-a'],
+ aliases: ["--actions", "-a"],
desc: 'Array of controller actions, e.g. "index show destroy"'
- desc 'Generates rspec request specs at spec/api'
+ desc "Generates rspec request specs at spec/api"
def generate
generate_resource_specs
end
private
@@ -25,21 +25,21 @@
def var
dir.singularize
end
def dir
- @resource.gsub('Resource', '').underscore.pluralize
+ @resource.gsub("Resource", "").underscore.pluralize
end
def generate_resource_specs
- if actions?('create', 'update', 'destroy')
+ if actions?("create", "update", "destroy")
to = "spec/resources/#{var}/writes_spec.rb"
- template('resource_writes_spec.rb.erb', to)
+ template("resource_writes_spec.rb.erb", to)
end
- if actions?('index', 'show')
+ if actions?("index", "show")
to = "spec/resources/#{var}/reads_spec.rb"
- template('resource_reads_spec.rb.erb', to)
+ template("resource_reads_spec.rb.erb", to)
end
end
def resource_class
@resource.constantize