Implemented Django 1.3 staticfile handling app, removed grapelli from
the included 3rd party apps folder, updated to a recent version of rosetta
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
Given /^I have a new rails app$/ do
|
||||
generate_rails_app
|
||||
end
|
||||
|
||||
Given /^I have no layouts$/ do
|
||||
remove_layouts
|
||||
end
|
||||
|
||||
Given /^I have no stylesheets$/ do
|
||||
remove_stylesheets
|
||||
end
|
||||
|
||||
Given /^I generate a theme$/ do
|
||||
generate_layout
|
||||
end
|
||||
|
||||
Given /^I generate a theme with name "([^\"]*)"$/ do |name|
|
||||
generate_layout(name)
|
||||
end
|
||||
|
||||
Given /^I generate a theme choosing the "([^\"]*)" theme$/ do |theme_name|
|
||||
generate_layout(:theme => theme_name)
|
||||
end
|
||||
|
||||
Then /^I should have a layout named "([^\"]*)"$/ do |filename|
|
||||
layout_exists?(filename).should be_true
|
||||
end
|
||||
|
||||
Then /^I should have a stylesheet named "([^\"]*)"$/ do |filename|
|
||||
stylesheet_exists?(filename).should be_true
|
||||
end
|
||||
|
||||
Then /^I should have an image named "([^\"]*)"$/ do |filename|
|
||||
image_exists?(filename).should be_true
|
||||
end
|
||||
|
||||
Given /^I generate a theme without layout choosing the "([^\"]*)" theme$/ do |theme_name|
|
||||
generate_layout(:theme => theme_name, :no_layout => true )
|
||||
end
|
||||
|
||||
Then /^I should not have any layouts$/ do
|
||||
layouts_count.should == 0
|
||||
end
|
||||
|
||||
Given /^I generate a theme with application name "([^\"]*)"$/ do |name|
|
||||
generate_layout(:app_name => name )
|
||||
end
|
||||
|
||||
Then /^the layout "([^\"]*)" should have "([^\"]*)" as page title$/ do |layout, title|
|
||||
layout_title(layout).should == title
|
||||
end
|
||||
|
||||
Given /^I generate a theme for signin and signup$/ do
|
||||
generate_layout(:layout_type => :sign)
|
||||
end
|
||||
|
||||
Then /^I should have a layout named "([^\"]*)" with just a box$/ do |layout|
|
||||
layout_with_box?(layout).should be_true
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
Given /^a model "([^\"]*)"$/ do |model_name|
|
||||
generate_model(model_name)
|
||||
end
|
||||
|
||||
Given /^I generate views for controller "([^\"]*)"$/ do |controller_path|
|
||||
generate_views(controller_path)
|
||||
end
|
||||
|
||||
When /^I generate views for controller "([^\"]*)" and model "([^\"]*)"$/ do |controller_path, model_name|
|
||||
generate_views(controller_path, model_name)
|
||||
end
|
||||
|
||||
When /^I generate text views for "([^\"]*)"/ do |controller_path|
|
||||
generate_views(controller_path, :themed_type => :text)
|
||||
end
|
||||
|
||||
Then /^I should have a view named "([^\"]*)"$/ do |view_path|
|
||||
view_exists?(view_path).should be_true
|
||||
end
|
||||
@@ -0,0 +1,86 @@
|
||||
$:.unshift(File.dirname(__FILE__) + "/../../rails_generators")
|
||||
require "rubygems"
|
||||
require "rails_generator"
|
||||
require 'rails_generator/scripts/generate'
|
||||
require "fileutils"
|
||||
require "theme/theme_generator"
|
||||
|
||||
web_app_theme_root = File.join(File.dirname(__FILE__), "/../../")
|
||||
tmp_rails_app_name = "tmp_rails_app"
|
||||
tmp_rails_app_root = File.join(web_app_theme_root, tmp_rails_app_name)
|
||||
|
||||
Rails::Generator::Base.append_sources(Rails::Generator::PathSource.new(:plugin, "#{web_app_theme_root}/rails_generators/"))
|
||||
|
||||
module GeneratorHelpers
|
||||
def generate_rails_app
|
||||
FileUtils.mkdir(File.join(@app_root))
|
||||
end
|
||||
|
||||
def remove_layouts
|
||||
FileUtils.rm_rf(File.join(@app_root, "app", "views", "layouts"))
|
||||
end
|
||||
|
||||
def remove_stylesheets
|
||||
FileUtils.rm_rf(File.join(@app_root, "public", "stylesheets"))
|
||||
end
|
||||
|
||||
def generate(*args)
|
||||
options = !args.empty? && args.last.is_a?(Hash) ? args.pop : {}
|
||||
options.merge!({:destination => @app_root, :quiet => true})
|
||||
Rails::Generator::Scripts::Generate.new.run(args, options)
|
||||
end
|
||||
|
||||
def generate_layout(*args)
|
||||
generate(:theme, *args)
|
||||
end
|
||||
|
||||
def generate_views(*args)
|
||||
generate(:themed, *args)
|
||||
end
|
||||
|
||||
def generate_model(model_name)
|
||||
Object.const_get(model_name)
|
||||
rescue NameError
|
||||
Object.const_set(model_name, Class.new)
|
||||
klass = Object.const_get(model_name)
|
||||
def klass.columns; []; end
|
||||
end
|
||||
|
||||
def layouts_count
|
||||
Dir[File.join(@app_root, "app", "views", "layouts", "**", "*.erb")].size
|
||||
end
|
||||
|
||||
def layout_exists?(filename)
|
||||
File.exists?(File.join(@app_root, "app", "views", "layouts", filename))
|
||||
end
|
||||
|
||||
def view_exists?(view_path)
|
||||
File.exists?(File.join(@app_root, "app", "views", view_path))
|
||||
end
|
||||
|
||||
def image_exists?(image_path)
|
||||
File.exists?(File.join(@app_root, "public", "images", image_path))
|
||||
end
|
||||
|
||||
def stylesheet_exists?(relative_path)
|
||||
File.exists?(File.join(@app_root, "public", "stylesheets", relative_path)).should be_true
|
||||
end
|
||||
|
||||
def layout_title(layout)
|
||||
File.open(File.join(@app_root, "app", "views", "layouts", layout), "r").read.match(/<title>([^<]*)<\/title>/)[1]
|
||||
end
|
||||
|
||||
def layout_with_box?(layout)
|
||||
File.open(File.join(@app_root, "app", "views", "layouts", layout), "r").read =~ %r|<div id="box">|
|
||||
end
|
||||
end
|
||||
|
||||
Before do
|
||||
@app_root = tmp_rails_app_root
|
||||
end
|
||||
|
||||
After do
|
||||
FileUtils.rm_rf(tmp_rails_app_root)
|
||||
end
|
||||
|
||||
World(GeneratorHelpers)
|
||||
@@ -0,0 +1,55 @@
|
||||
Feature: Layout generation
|
||||
In order to create a great application
|
||||
I should be able to generate a layout with Web App Theme
|
||||
|
||||
# script/generate theme
|
||||
Scenario: Generate a layout
|
||||
Given I have a new rails app
|
||||
And I have no layouts
|
||||
And I have no stylesheets
|
||||
When I generate a theme
|
||||
Then I should have a layout named "application.html.erb"
|
||||
And I should have a stylesheet named "web_app_theme.css"
|
||||
And I should have a stylesheet named "web_app_theme_override.css"
|
||||
And I should have a stylesheet named "themes/default/style.css"
|
||||
And I should have an image named "web-app-theme/cross.png"
|
||||
And I should have an image named "web-app-theme/key.png"
|
||||
And I should have an image named "web-app-theme/tick.png"
|
||||
And I should have an image named "web-app-theme/application_edit.png"
|
||||
|
||||
# script/generate theme admin
|
||||
Scenario: Generate a layout with a name
|
||||
Given I have a new rails app
|
||||
And I have no layouts
|
||||
And I generate a theme with name "admin"
|
||||
Then I should have a layout named "admin.html.erb"
|
||||
|
||||
# script/generate theme --theme="drastic-dark"
|
||||
Scenario: Generate a layout choosing a theme
|
||||
Given I have a new rails app
|
||||
And I have no stylesheets
|
||||
And I generate a theme choosing the "drastic-dark" theme
|
||||
Then I should have a stylesheet named "themes/drastic-dark/style.css"
|
||||
|
||||
# script/generate theme --theme=bec --no_layout
|
||||
Scenario: Generate only stylesheets without layout
|
||||
Given I have a new rails app
|
||||
And I have no layouts
|
||||
And I generate a theme without layout choosing the "bec" theme
|
||||
Then I should have a stylesheet named "themes/bec/style.css"
|
||||
But I should not have any layouts
|
||||
|
||||
# script/generate theme --app_name="My New Application"
|
||||
Scenario: Generate layout with application name
|
||||
Given I have a new rails app
|
||||
And I have no layouts
|
||||
And I generate a theme with application name "My New Application"
|
||||
Then the layout "application.html.erb" should have "My New Application" as page title
|
||||
|
||||
# script/generate theme --type=sign
|
||||
Scenario: Generate layout for signin and signup
|
||||
Given I have a new rails app
|
||||
And I have no layouts
|
||||
And I generate a theme for signin and signup
|
||||
Then I should have a layout named "sign.html.erb"
|
||||
And I should have a layout named "sign.html.erb" with just a box
|
||||
@@ -0,0 +1,52 @@
|
||||
Feature: Theme generation
|
||||
In order to create a great application
|
||||
I should be able to creare theme after creating a layout
|
||||
|
||||
# script/generate themed posts
|
||||
Scenario: Creating CRUD views with controller path
|
||||
Given I have a new rails app
|
||||
And a model "Post"
|
||||
When I generate views for controller "posts"
|
||||
Then I should have a view named "posts/index.html.erb"
|
||||
And I should have a view named "posts/new.html.erb"
|
||||
And I should have a view named "posts/show.html.erb"
|
||||
And I should have a view named "posts/edit.html.erb"
|
||||
|
||||
# script/generate themed items Post
|
||||
Scenario: Creating CRUD views with controller path and model name
|
||||
Given I have a new rails app
|
||||
And a model "Post"
|
||||
When I generate views for controller "items" and model "Post"
|
||||
Then I should have a view named "items/index.html.erb"
|
||||
And I should have a view named "items/new.html.erb"
|
||||
And I should have a view named "items/show.html.erb"
|
||||
And I should have a view named "items/edit.html.erb"
|
||||
|
||||
# script/generate themed admin/items Post
|
||||
Scenario: Creating CRUD views with controller path "admin/items" and model name
|
||||
Given I have a new rails app
|
||||
And a model "Post"
|
||||
When I generate views for controller "admin/items" and model "Post"
|
||||
Then I should have a view named "admin/items/index.html.erb"
|
||||
And I should have a view named "admin/items/new.html.erb"
|
||||
And I should have a view named "admin/items/show.html.erb"
|
||||
And I should have a view named "admin/items/edit.html.erb"
|
||||
|
||||
# script/generate themed admin/gallery_pictures
|
||||
Scenario: Creating CRUD views with controller path "admin/gallery_pictures"
|
||||
Given I have a new rails app
|
||||
And a model "GalleryPicture"
|
||||
When I generate views for controller "admin/gallery_pictures"
|
||||
Then I should have a view named "admin/gallery_pictures/index.html.erb"
|
||||
And I should have a view named "admin/gallery_pictures/new.html.erb"
|
||||
And I should have a view named "admin/gallery_pictures/show.html.erb"
|
||||
And I should have a view named "admin/gallery_pictures/edit.html.erb"
|
||||
|
||||
# script/generate themed homes --type=text
|
||||
Scenario: Creating text theme
|
||||
Given I have a new rails app
|
||||
When I generate text views for "homes"
|
||||
Then I should have a view named "homes/show.html.erb"
|
||||
And I should have a view named "homes/_sidebar.html.erb"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user