-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug Fix #28
base: master
Are you sure you want to change the base?
Bug Fix #28
Changes from all commits
6f2d6dc
e8ae9f4
9531673
913a397
bf4a717
bfd5d14
959d91e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
require "rubygems" | |||
require "rspec" | |||
require "rails" | |||
require "rails/generators" | |||
require File.dirname(__FILE__) + "/../lib/generators/web_app_theme/themed/themed_generator" | |||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed the spec requires |
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,170 @@ | |||
require File.dirname(__FILE__) + "/spec_helper" | |||
|
|||
describe WebAppTheme::ThemedGenerator, "with 'script/generate themed posts'" do | |||
before do | |||
Post = Class.new | |||
Post.stub!(:columns).and_return([]) | |||
options = {:destination => File.dirname(__FILE__), :quiet => true, :source => File.dirname(__FILE__)} | |||
@generator = WebAppTheme::ThemedGenerator.new(["posts", "post"], options) | |||
end | |||
|
|||
after do | |||
Object::send(:remove_const, :Post) | |||
end | |||
|
|||
it "should set the right controller_routing_path" do | |||
@generator.instance_variable_get("@controller_routing_path").should == "posts" | |||
end | |||
|
|||
it "should set the right singular_controller_routing_path" do | |||
@generator.send(:singular_controller_routing_path).should == "post" | |||
end | |||
|
|||
it "should set the right model_name" do | |||
@generator.instance_variable_get("@model_name").should == "Post" | |||
end | |||
|
|||
it "should set the right plural_model_name" do | |||
@generator.send(:plural_model_name).should == "Posts" | |||
end | |||
|
|||
it "should set the right resource_name" do | |||
@generator.send(:resource_name).should == "post" | |||
end | |||
|
|||
it "should set the right plural_resource_name" do | |||
@generator.send(:plural_resource_name).should == "posts" | |||
end | |||
|
|||
it "should get the right model class" do | |||
@generator.send(:model_class).to_s.should == "Post" | |||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a new spec to method model_class |
|||
end | |||
|
|||
end | |||
|
|||
describe WebAppTheme::ThemedGenerator, "with 'script/generate themed admin/gallery_items'" do | |||
before do | |||
GalleryItem = Class.new | |||
GalleryItem.stub!(:columns).and_return([]) | |||
options = {:destination => File.dirname(__FILE__), :quiet => true, :source => File.dirname(__FILE__)} | |||
@generator = WebAppTheme::ThemedGenerator.new(["admin/gallery_items"], options) | |||
end | |||
|
|||
after do | |||
Object::send(:remove_const, :GalleryItem) | |||
end | |||
|
|||
it "should set the right controller_routing_path" do | |||
@generator.instance_variable_get("@controller_routing_path").should == "admin_gallery_items" | |||
end | |||
|
|||
it "should set the right singular_controller_routing_path" do | |||
@generator.send(:singular_controller_routing_path).should == "admin_gallery_item" | |||
end | |||
|
|||
it "should set the right model_name" do | |||
@generator.instance_variable_get("@model_name").should == "GalleryItem" | |||
end | |||
|
|||
it "should set the right plural_model_name" do | |||
@generator.send(:plural_model_name).should == "GalleryItems" | |||
end | |||
|
|||
it "should set the right resource_name" do | |||
@generator.send(:resource_name).should == "gallery_item" | |||
end | |||
|
|||
it "should set the right plural_resource_name" do | |||
@generator.send(:plural_resource_name).should == "gallery_items" | |||
end | |||
|
|||
it "should get the right model class" do | |||
@generator.send(:model_class).to_s.should == "GalleryItem" | |||
end | |||
|
|||
end | |||
|
|||
describe WebAppTheme::ThemedGenerator, "with 'script/generate themed admin/gallery_items pictures'" do | |||
before do | |||
Picture = Class.new | |||
Picture.stub!(:columns).and_return([]) | |||
options = {:destination => File.dirname(__FILE__), :quiet => true, :source => File.dirname(__FILE__)} | |||
@generator = WebAppTheme::ThemedGenerator.new(["admin/gallery_items", "picture"], options) | |||
end | |||
|
|||
after do | |||
Object::send(:remove_const, :Picture) | |||
end | |||
|
|||
it "should set the right controller_routing_path" do | |||
@generator.instance_variable_get("@controller_routing_path").should == "admin_gallery_items" | |||
end | |||
|
|||
it "should set the right singular_controller_routing_path" do | |||
@generator.send(:singular_controller_routing_path).should == "admin_gallery_item" | |||
end | |||
|
|||
it "should set the right model_name" do | |||
@generator.instance_variable_get("@model_name").should == "Picture" | |||
end | |||
|
|||
it "should set the right plural_model_name" do | |||
@generator.send(:plural_model_name).should == "Pictures" | |||
end | |||
|
|||
it "should set the right resource_name" do | |||
@generator.send(:resource_name).should == "picture" | |||
end | |||
|
|||
it "should set the right plural_resource_name" do | |||
@generator.send(:plural_resource_name).should == "pictures" | |||
end | |||
|
|||
it "should get the right model class" do | |||
@generator.send(:model_class).to_s.should == "Picture" | |||
end | |||
|
|||
end | |||
|
|||
describe WebAppTheme::ThemedGenerator, "width 'script/generate themed admin/gallery Admin::Gallery'" do | |||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a new case os specification receving the model with module |
|||
before do | |||
Admin = Module.new | |||
Admin::Gallery = Class.new | |||
Admin::Gallery.stub!(:columns).and_return([]) | |||
options = {:destination => File.dirname(__FILE__), :quiet => true, :source => File.dirname(__FILE__)} | |||
@generator = WebAppTheme::ThemedGenerator.new(["admin/gallery", "admin::gallery"], options) | |||
end | |||
|
|||
after do | |||
Object::send(:remove_const, :Admin) | |||
end | |||
|
|||
it "should set the right controller_routing_path" do | |||
@generator.instance_variable_get("@controller_routing_path").should == "admin_gallery" | |||
end | |||
|
|||
it "should set the right singular_controller_routing_path" do | |||
@generator.send(:singular_controller_routing_path).should == "admin_gallery" | |||
end | |||
|
|||
it "should set the right model_name" do | |||
@generator.instance_variable_get("@model_name").should == "Admin::Gallery" | |||
end | |||
|
|||
it "should set the right plural_model_name" do | |||
@generator.send(:plural_model_name).should == "Galleries" | |||
end | |||
|
|||
it "should set the right resource_name" do | |||
@generator.send(:resource_name).should == "admin/gallery" | |||
end | |||
|
|||
it "should set the right plural_resource_name" do | |||
@generator.send(:plural_resource_name).should == "admin/galleries" | |||
end | |||
|
|||
it "should get the right model class" do | |||
@generator.send(:model_class).to_s.should == "Admin::Gallery" | |||
end | |||
|
|||
end |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BugFix now the code iterates over the namespace to get the model class