Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

handle namespaced models in spec generators

closes #279
  • Loading branch information...
commit 6f0d5aae9fca2806311860284e755995adec500f 1 parent d597264
@nashby nashby authored
View
2  lib/generators/rspec/decorator_generator.rb
@@ -3,7 +3,7 @@ class DecoratorGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
def create_spec_file
- template 'decorator_spec.rb', File.join('spec/decorators', "#{singular_name}_decorator_spec.rb")
+ template 'decorator_spec.rb', File.join('spec/decorators', class_path, "#{singular_name}_decorator_spec.rb")
end
end
end
View
2  lib/generators/test_unit/decorator_generator.rb
@@ -3,7 +3,7 @@ class DecoratorGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
def create_test_file
- template 'decorator_test.rb', File.join('test/decorators', "#{singular_name}_decorator_test.rb")
+ template 'decorator_test.rb', File.join('test/decorators', class_path, "#{singular_name}_decorator_test.rb")
end
end
end
View
22 spec/generators/decorator/decorator_generator_spec.rb
@@ -65,7 +65,17 @@ class ApplicationDecorator; end
end
end
- context 'using rspec' do
+ context 'using rspec with namespaced model' do
+ before { run_generator ["Namespace::YourModel", "-t=rspec"] }
+
+ describe 'spec/decorators/your_model_decorator_spec.rb' do
+ subject { file('spec/decorators/namespace/your_model_decorator_spec.rb') }
+ it { should exist }
+ it { should contain "describe Namespace::YourModelDecorator" }
+ end
+ end
+
+ context 'using test-unit' do
before { run_generator ["YourModel", "-t=test_unit"] }
describe 'test/decorators/YourModel_decorator_test.rb' do
@@ -74,4 +84,14 @@ class ApplicationDecorator; end
it { should contain "class YourModelDecoratorTest < ActiveSupport::TestCase" }
end
end
+
+ context 'using test-unit with namespaced model' do
+ before { run_generator ["Namespace::YourModel", "-t=test_unit"] }
+
+ describe 'test/decorators/your_model_decorator_test.rb' do
+ subject { file('test/decorators/namespace/your_model_decorator_test.rb') }
+ it { should exist }
+ it { should contain "class Namespace::YourModelDecoratorTest < ActiveSupport::TestCase" }
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.