Skip to content

Commit

Permalink
Add specs for controller globbing
Browse files Browse the repository at this point in the history
  • Loading branch information
unixmonkey authored and jmccaffrey committed Aug 2, 2010
1 parent 9702c4c commit f272106
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
51 changes: 51 additions & 0 deletions spec/controllers_diagram_spec.rb
@@ -0,0 +1,51 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'controllers_diagram'
require 'options_struct'

describe ControllersDiagram do
describe 'file processing' do

it 'should select all the files under the controllers dir' do
cd = ControllersDiagram.new
files = cd.get_files("spec/file_fixture/")
files.size.should == 4
end

it 'should exclude a specific file' do
options = OptionsStruct.new(:exclude => ['spec/file_fixture/app/controllers/dummy1_controller.rb'])
cd = ControllersDiagram.new(options)
files = cd.get_files("spec/file_fixture/")
files.size.should == 3
end

it 'should exclude a glob pattern of files' do
options = OptionsStruct.new(:exclude => ['spec/file_fixture/app/controllers/sub-dir/*.rb'])
cd = ControllersDiagram.new(options)
files = cd.get_files("spec/file_fixture/")
files.size.should == 3
end

it 'should include only specific file' do
options = OptionsStruct.new(:specify => ['spec/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb'])
cd = ControllersDiagram.new(options)
files = cd.get_files("spec/file_fixture/")
files.size.should == 1
end

it 'should include only specified files' do
options = OptionsStruct.new(:specify => ['spec/file_fixture/app/controllers/{dummy1_*.rb,sub-dir/sub_dummy_controller.rb}'])
cd = ControllersDiagram.new(options)
files = cd.get_files("spec/file_fixture/")
files.size.should == 2
end

it 'should include only specified files and exclude specified files' do
options = OptionsStruct.new(:specify => ['spec/file_fixture/app/controllers/{dummy1_*.rb,sub-dir/sub_dummy_controller.rb}'],
:exclude => ['spec/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb'])
cd = ControllersDiagram.new(options)
files = cd.get_files("spec/file_fixture/")
files.size.should == 1
end

end
end
2 changes: 2 additions & 0 deletions spec/file_fixture/app/controllers/application_controller.rb
@@ -0,0 +1,2 @@
class ApplicationController < ActionController::Base
end
Empty file.
Empty file.
Empty file.

0 comments on commit f272106

Please sign in to comment.