From 1b58235818981be8d44822f2ae49d218329c9456 Mon Sep 17 00:00:00 2001 From: Al Ameen Date: Fri, 23 Sep 2016 12:37:46 +0530 Subject: [PATCH] refactoring generator spec --- .hound.yml | 2 ++ .rubocop.yml | 8 ++++++++ spec/generators/apidoco_generator_spec.rb | 20 ++++++++++---------- 3 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 .hound.yml create mode 100644 .rubocop.yml diff --git a/.hound.yml b/.hound.yml new file mode 100644 index 0000000..5d0ff60 --- /dev/null +++ b/.hound.yml @@ -0,0 +1,2 @@ +ruby: + config_file: .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..abe7cb5 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,8 @@ +Style/IfUnlessModifier: + MaxLineLength: 120 +Style/WhileUntilModifier: + MaxLineLength: 120 +Metrics/LineLength: + Max: 120 +Style/FrozenStringLiteralComment: + Enabled: false diff --git a/spec/generators/apidoco_generator_spec.rb b/spec/generators/apidoco_generator_spec.rb index 2569cf7..c2356a1 100644 --- a/spec/generators/apidoco_generator_spec.rb +++ b/spec/generators/apidoco_generator_spec.rb @@ -1,6 +1,6 @@ -require "rails/generators" -require "generators/apidoco_generator" -require "generator_spec" +require 'rails/generators' +require 'generators/apidoco_generator' +require 'generator_spec' describe ApidocoGenerator, type: :generator do def remove_docs_directory @@ -12,20 +12,20 @@ def remove_docs_directory end context 'default actions' do - it "creates a crud documentation files" do + it 'creates a crud documentation files' do run_generator %w(api/v1/posts) - assert_file "#{Rails.root}/docs/api/v1/posts/create.json", /api\/v1\/posts.json/ - assert_file "#{Rails.root}/docs/api/v1/posts/destroy.json", /api\/v1\/posts\/:id.json/ - assert_file "#{Rails.root}/docs/api/v1/posts/index.json", /api\/v1\/posts.json/ - assert_file "#{Rails.root}/docs/api/v1/posts/show.json", /api\/v1\/posts\/:id.json/ - assert_file "#{Rails.root}/docs/api/v1/posts/update.json", /api\/v1\/posts\/:id.json/ + assert_file "#{Rails.root}/docs/api/v1/posts/create.json", %r{api/v1/posts.json} + assert_file "#{Rails.root}/docs/api/v1/posts/destroy.json", %r{api/v1/posts/:id.json} + assert_file "#{Rails.root}/docs/api/v1/posts/index.json", %r{api/v1/posts.json} + assert_file "#{Rails.root}/docs/api/v1/posts/show.json", %r{api/v1/posts/:id.json} + assert_file "#{Rails.root}/docs/api/v1/posts/update.json", %r{api/v1/posts/:id.json} end end context 'custom actions' do let(:upload_acton) { 'upload' } - it "creates the documentation files for the actions supplied in arguments" do + it 'creates the documentation files for the actions supplied in arguments' do run_generator ['api/v1/posts', upload_acton] assert_file "#{Rails.root}/docs/api/v1/posts/#{upload_acton}.json"