Skip to content

Commit

Permalink
refactoring generator spec
Browse files Browse the repository at this point in the history
  • Loading branch information
alameenkhader committed Sep 23, 2016
1 parent 6a20c25 commit 1b58235
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ruby:
config_file: .rubocop.yml
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Style/IfUnlessModifier:
MaxLineLength: 120
Style/WhileUntilModifier:
MaxLineLength: 120
Metrics/LineLength:
Max: 120
Style/FrozenStringLiteralComment:
Enabled: false
20 changes: 10 additions & 10 deletions spec/generators/apidoco_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 1b58235

Please sign in to comment.