shakespeare 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/README.md +85 -0
  2. data/Rakefile +43 -0
  3. data/app/controllers/admin/pages_controller.rb +47 -0
  4. data/app/controllers/pages_controller.rb +5 -0
  5. data/app/models/page.rb +10 -0
  6. data/app/views/admin/pages/_form.html.erb +38 -0
  7. data/app/views/admin/pages/edit.html.erb +3 -0
  8. data/app/views/admin/pages/index.html.erb +24 -0
  9. data/app/views/admin/pages/new.html.erb +3 -0
  10. data/app/views/layouts/admin.html.erb +9 -0
  11. data/app/views/pages/show.html.erb +3 -0
  12. data/config/cucumber.yml +7 -0
  13. data/config/routes.rb +8 -0
  14. data/features/admin_pages.feature +38 -0
  15. data/features/public_pages.feature +12 -0
  16. data/features/step_definitions/page_steps.rb +7 -0
  17. data/features/step_definitions/web_steps.rb +259 -0
  18. data/features/support/env.rb +55 -0
  19. data/features/support/paths.rb +32 -0
  20. data/features/support/shakespeare_env.rb +3 -0
  21. data/generators/definition.txt +0 -0
  22. data/generators/shakespeare/USAGE +5 -0
  23. data/generators/shakespeare/shakespeare_generator.rb +8 -0
  24. data/generators/shakespeare/templates/20091230095600_create_pages.rb +25 -0
  25. data/lib/shakespeare.rb +7 -0
  26. data/lib/shakespeare/helpers.rb +16 -0
  27. data/lib/shakespeare/settings.rb +30 -0
  28. data/lib/shakespeare/shakespeare.rb +8 -0
  29. data/lib/shakespeare/view_helpers.rb +29 -0
  30. data/rails/init.rb +1 -0
  31. data/rerun.txt +1 -0
  32. data/spec/blueprints.rb +9 -0
  33. data/spec/controllers/admin/pages_controller_spec.rb +35 -0
  34. data/spec/database.yml +21 -0
  35. data/spec/debug.log +1937 -0
  36. data/spec/helpers_spec.rb +19 -0
  37. data/spec/models/page_spec.rb +28 -0
  38. data/spec/schema.rb +16 -0
  39. data/spec/shakespeare_generator_spec.rb +36 -0
  40. data/spec/shakespeare_spec.rb +3 -0
  41. data/spec/spec_helper.rb +41 -0
  42. data/spec/view_helpers_spec.rb +103 -0
  43. metadata +104 -0
@@ -0,0 +1,19 @@
1
+ require 'spec/spec_helper.rb'
2
+
3
+ describe Shakespeare::Helpers do
4
+
5
+ class TestController < ApplicationController
6
+ end
7
+
8
+ describe "#page_content" do
9
+ before do
10
+ @page = mock_model(Page)
11
+ Page.stub!(:find_by_url).and_return(@page)
12
+ end
13
+
14
+ it "should pull the page" do
15
+ @controller = TestController.new
16
+ @controller.page_content.should == @page
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Page do
4
+
5
+ describe "#robots" do
6
+
7
+ before do
8
+ @page = Page.make_unsaved
9
+ end
10
+
11
+ it "should have no robots" do
12
+ @page.robots.should be_blank
13
+ end
14
+
15
+ it "should have nofollow by itself" do
16
+ @page.nofollow = true
17
+ @page.robots.should == 'nofollow'
18
+ end
19
+
20
+ it "should have both nofollow and noindex" do
21
+ @page.nofollow = true
22
+ @page.noindex = true
23
+ @page.robots.should == 'noindex, nofollow'
24
+ end
25
+
26
+ end
27
+
28
+ end
data/spec/schema.rb ADDED
@@ -0,0 +1,16 @@
1
+ ActiveRecord::Schema.define(:version => 0) do
2
+ create_table "pages", :force => true do |t|
3
+ t.string "title"
4
+ t.string "url"
5
+ t.text "keywords"
6
+ t.text "description"
7
+ t.text "content"
8
+ t.datetime "created_at"
9
+ t.datetime "updated_at"
10
+ t.boolean "noindex"
11
+ t.boolean "nofollow"
12
+ t.string "canonical"
13
+ t.boolean "enable_canonical"
14
+ t.boolean "enable_keywords"
15
+ end
16
+ end
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'rails_generator'
3
+ require 'rails_generator/scripts/generate'
4
+
5
+ describe ShakespeareGenerator do
6
+
7
+ before do
8
+ @dirs = {}
9
+ @dirs['migration'] = fake_rails_root + '/db/migrate'
10
+ @dirs.each do |key, dir|
11
+ FileUtils.mkdir_p(dir)
12
+ end
13
+ @original_files = {}
14
+ @original_files['migration'] = file_list(@dirs['migration'])
15
+ Rails::Generator::Scripts::Generate.new.run(["shakespeare"], :destination => fake_rails_root, :backtrace => true)
16
+ end
17
+
18
+ it "should create the migration file" do
19
+ new_migration_file = (file_list(@dirs['migration']) - @original_files['migration']).first
20
+ "20091230095600_create_pages.rb".should == File.basename(new_migration_file)
21
+ end
22
+
23
+ after do
24
+ FileUtils.rm_r(fake_rails_root)
25
+ end
26
+
27
+
28
+ def fake_rails_root
29
+ File.join(File.dirname(__FILE__), 'spec', 'rails_root')
30
+ end
31
+
32
+ def file_list(dir)
33
+ Dir.glob(File.join(dir, "*"))
34
+ end
35
+
36
+ end
@@ -0,0 +1,3 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ load_schema
@@ -0,0 +1,41 @@
1
+ begin
2
+ require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
3
+ rescue LoadError
4
+ puts "You need to install rspec in your base app"
5
+ exit
6
+ end
7
+
8
+ plugin_spec_dir = File.dirname(__FILE__)
9
+ ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log")
10
+
11
+ require File.expand_path(File.join(Rails.root, 'config/environment.rb')) unless defined?(ActiveRecord::Base)
12
+ require 'spec/blueprints'
13
+
14
+ def load_schema
15
+ config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
16
+ # ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
17
+ #
18
+ # db_adapter = ENV['DB']
19
+ #
20
+ # # no db passed, try one of these fine config-free DBs before bombing.
21
+ # db_adapter ||=
22
+ # begin
23
+ # require 'rubygems'
24
+ # require 'sqlite'
25
+ # 'sqlite'
26
+ # rescue MissingSourceFile
27
+ # begin
28
+ # require 'sqlite3'
29
+ # 'sqlite3'
30
+ # rescue MissingSourceFile
31
+ # end
32
+ # end
33
+ #
34
+ # if db_adapter.nil?
35
+ # raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3."
36
+ # end
37
+
38
+ ActiveRecord::Base.establish_connection(config[:mysql])
39
+ load(File.dirname(__FILE__) + "/schema.rb")
40
+ require File.dirname(__FILE__) + '/../rails/init.rb'
41
+ end
@@ -0,0 +1,103 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Shakespeare::ViewHelpers do
4
+ include Shakespeare::Helpers
5
+ include Shakespeare::ViewHelpers
6
+
7
+ def controller_name; end
8
+
9
+ def action_name; end
10
+
11
+ before(:all) do
12
+ @page = Page.make_unsaved(
13
+ :title => "Made Up",
14
+ :description => "A description",
15
+ :keywords => "awesome, code",
16
+ :canonical => "http://pabcas.com",
17
+ :nofollow => true
18
+ )
19
+ end
20
+
21
+ context "no page" do
22
+ describe "#page_title" do
23
+ it "should be nil" do
24
+ page_title.should be_nil
25
+ end
26
+ end
27
+
28
+
29
+ describe "#description_meta_tag" do
30
+ it "should be nil" do
31
+ description_meta_tag.should be_nil
32
+ end
33
+ end
34
+
35
+ describe "#keywords_meta_tag" do
36
+ it "should be nil" do
37
+ keywords_meta_tag.should be_nil
38
+ end
39
+ end
40
+
41
+ describe "#robots_meta_tag" do
42
+ it "should be nil" do
43
+ robots_meta_tag.should be_nil
44
+ end
45
+ end
46
+
47
+ describe "#canonical_link_tag" do
48
+ it "should be nil" do
49
+ canonical_link_tag.should be_nil
50
+ end
51
+ end
52
+ end
53
+
54
+
55
+ context "with a page" do
56
+
57
+ before(:all) do
58
+ Page.stub!(:find_by_url).and_return(@page)
59
+ end
60
+
61
+ describe "#page_title" do
62
+ it "should be the page title" do
63
+ page_title.should == "Made Up"
64
+ end
65
+ end
66
+
67
+ describe "#description_meta_tag" do
68
+ it "should generate the tag" do
69
+ description_meta_tag.should == %Q[<meta name="description" content="A description">]
70
+ end
71
+ end
72
+
73
+ describe "#keywords_meta_tag" do
74
+ it "should generate the tag" do
75
+ keywords_meta_tag.should == %Q[<meta name="keywords" content="awesome, code">]
76
+ end
77
+ end
78
+
79
+ describe "#robots_meta_tag" do
80
+ it "should generate the tag" do
81
+ robots_meta_tag.should == %Q[<meta name="robots" content="nofollow">]
82
+ end
83
+ end
84
+
85
+ describe "#canonical_link_tag" do
86
+ context "active" do
87
+ it "should generate the tag" do
88
+ @page.stub!(:enable_canonical?).and_return(true)
89
+
90
+ canonical_link_tag.should == %Q[<link href="http://pabcas.com" rel="canonical" />]
91
+ end
92
+ end
93
+
94
+ context "inactive" do
95
+ it "should not generate the tag" do
96
+ canonical_link_tag.should be_nil
97
+ end
98
+ end
99
+ end
100
+
101
+ end
102
+
103
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shakespeare
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Paul Campbell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-04 00:00:00 +00:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: paul@rslw.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.md
24
+ files:
25
+ - README.md
26
+ - Rakefile
27
+ - app/controllers/admin/pages_controller.rb
28
+ - app/controllers/pages_controller.rb
29
+ - app/models/page.rb
30
+ - app/views/admin/pages/_form.html.erb
31
+ - app/views/admin/pages/edit.html.erb
32
+ - app/views/admin/pages/index.html.erb
33
+ - app/views/admin/pages/new.html.erb
34
+ - app/views/layouts/admin.html.erb
35
+ - app/views/pages/show.html.erb
36
+ - config/cucumber.yml
37
+ - config/routes.rb
38
+ - features/admin_pages.feature
39
+ - features/public_pages.feature
40
+ - features/step_definitions/page_steps.rb
41
+ - features/step_definitions/web_steps.rb
42
+ - features/support/env.rb
43
+ - features/support/paths.rb
44
+ - features/support/shakespeare_env.rb
45
+ - generators/definition.txt
46
+ - generators/shakespeare/USAGE
47
+ - generators/shakespeare/shakespeare_generator.rb
48
+ - generators/shakespeare/templates/20091230095600_create_pages.rb
49
+ - lib/shakespeare.rb
50
+ - lib/shakespeare/helpers.rb
51
+ - lib/shakespeare/settings.rb
52
+ - lib/shakespeare/shakespeare.rb
53
+ - lib/shakespeare/view_helpers.rb
54
+ - rails/init.rb
55
+ - rerun.txt
56
+ - spec/blueprints.rb
57
+ - spec/controllers/admin/pages_controller_spec.rb
58
+ - spec/database.yml
59
+ - spec/debug.log
60
+ - spec/helpers_spec.rb
61
+ - spec/models/page_spec.rb
62
+ - spec/schema.rb
63
+ - spec/shakespeare_generator_spec.rb
64
+ - spec/shakespeare_spec.rb
65
+ - spec/spec_helper.rb
66
+ - spec/view_helpers_spec.rb
67
+ has_rdoc: true
68
+ homepage: http://www.github.com/paulca/shakespeare
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options:
73
+ - --charset=UTF-8
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ requirements: []
89
+
90
+ rubyforge_project:
91
+ rubygems_version: 1.3.5
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: A Rails drop in CMS.
95
+ test_files:
96
+ - spec/blueprints.rb
97
+ - spec/controllers/admin/pages_controller_spec.rb
98
+ - spec/helpers_spec.rb
99
+ - spec/models/page_spec.rb
100
+ - spec/schema.rb
101
+ - spec/shakespeare_generator_spec.rb
102
+ - spec/shakespeare_spec.rb
103
+ - spec/spec_helper.rb
104
+ - spec/view_helpers_spec.rb