shakespeare 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. data/README.md +88 -84
  2. data/Rakefile +42 -42
  3. data/app/controllers/admin/pages_controller.rb +46 -46
  4. data/app/controllers/pages_controller.rb +4 -4
  5. data/app/models/page.rb +9 -9
  6. data/app/views/admin/pages/_form.html.erb +37 -37
  7. data/app/views/admin/pages/edit.html.erb +2 -2
  8. data/app/views/admin/pages/index.html.erb +23 -23
  9. data/app/views/admin/pages/new.html.erb +2 -2
  10. data/app/views/layouts/admin.html.erb +8 -8
  11. data/app/views/pages/show.html.erb +2 -2
  12. data/config/cucumber.yml +7 -7
  13. data/config/routes.rb +7 -7
  14. data/features/admin_pages.feature +37 -37
  15. data/features/public_pages.feature +11 -11
  16. data/features/step_definitions/page_steps.rb +6 -6
  17. data/features/step_definitions/web_steps.rb +258 -258
  18. data/features/support/env.rb +55 -55
  19. data/features/support/paths.rb +32 -32
  20. data/features/support/shakespeare_env.rb +2 -2
  21. data/generators/shakespeare/USAGE +4 -4
  22. data/generators/shakespeare/shakespeare_generator.rb +7 -7
  23. data/generators/shakespeare/templates/20091230095600_create_pages.rb +25 -25
  24. data/lib/shakespeare.rb +6 -6
  25. data/lib/shakespeare/helpers.rb +15 -15
  26. data/lib/shakespeare/settings.rb +29 -29
  27. data/lib/shakespeare/shakespeare.rb +7 -7
  28. data/lib/shakespeare/view_helpers.rb +28 -28
  29. data/rerun.txt +1 -1
  30. data/shakespeare.gemspec +89 -0
  31. data/spec/blueprints.rb +8 -8
  32. data/spec/controllers/admin/pages_controller_spec.rb +34 -34
  33. data/spec/database.yml +20 -20
  34. data/spec/helpers_spec.rb +19 -19
  35. data/spec/models/page_spec.rb +27 -27
  36. data/spec/schema.rb +15 -15
  37. data/spec/shakespeare_generator_spec.rb +35 -35
  38. data/spec/shakespeare_spec.rb +2 -2
  39. data/spec/spec_helper.rb +40 -40
  40. data/spec/view_helpers_spec.rb +102 -102
  41. metadata +2 -1
@@ -1,55 +1,55 @@
1
- # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
- # It is recommended to regenerate this file in the future when you upgrade to a
3
- # newer version of cucumber-rails. Consider adding your own code to a new file
4
- # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
- # files.
6
-
7
- ENV["RAILS_ENV"] ||= "cucumber"
8
- require File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
9
-
10
- require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
11
- require 'cucumber/rails/rspec'
12
- require 'cucumber/rails/world'
13
- require 'cucumber/rails/active_record'
14
- require 'cucumber/web/tableish'
15
-
16
- require 'webrat'
17
- require 'webrat/core/matchers'
18
- require 'cucumber/webrat/element_locator' # Deprecated in favor of #tableish - remove this line if you don't use #element_at or #table_at
19
-
20
- Webrat.configure do |config|
21
- config.mode = :rails
22
- config.open_error_files = false # Set to true if you want error pages to pop up in the browser
23
- end
24
-
25
-
26
- # If you set this to false, any error raised from within your app will bubble
27
- # up to your step definition and out to cucumber unless you catch it somewhere
28
- # on the way. You can make Rails rescue errors and render error pages on a
29
- # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
30
- #
31
- # If you set this to true, Rails will rescue all errors and render error
32
- # pages, more or less in the same way your application would behave in the
33
- # default production environment. It's not recommended to do this for all
34
- # of your scenarios, as this makes it hard to discover errors in your application.
35
- ActionController::Base.allow_rescue = false
36
-
37
- # If you set this to true, each scenario will run in a database transaction.
38
- # You can still turn off transactions on a per-scenario basis, simply tagging
39
- # a feature or scenario with the @no-txn tag. If you are using Capybara,
40
- # tagging with @culerity or @javascript will also turn transactions off.
41
- #
42
- # If you set this to false, transactions will be off for all scenarios,
43
- # regardless of whether you use @no-txn or not.
44
- #
45
- # Beware that turning transactions off will leave data in your database
46
- # after each scenario, which can lead to hard-to-debug failures in
47
- # subsequent scenarios. If you do this, we recommend you create a Before
48
- # block that will explicitly put your database in a known state.
49
- Cucumber::Rails::World.use_transactional_fixtures = true
50
-
51
- # How to clean your database when transactions are turned off. See
52
- # http://github.com/bmabey/database_cleaner for more info.
53
- require 'database_cleaner'
54
- DatabaseCleaner.strategy = :truncation
55
-
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+ ENV["RAILS_ENV"] ||= "cucumber"
8
+ require File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
9
+
10
+ require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
11
+ require 'cucumber/rails/rspec'
12
+ require 'cucumber/rails/world'
13
+ require 'cucumber/rails/active_record'
14
+ require 'cucumber/web/tableish'
15
+
16
+ require 'webrat'
17
+ require 'webrat/core/matchers'
18
+ require 'cucumber/webrat/element_locator' # Deprecated in favor of #tableish - remove this line if you don't use #element_at or #table_at
19
+
20
+ Webrat.configure do |config|
21
+ config.mode = :rails
22
+ config.open_error_files = false # Set to true if you want error pages to pop up in the browser
23
+ end
24
+
25
+
26
+ # If you set this to false, any error raised from within your app will bubble
27
+ # up to your step definition and out to cucumber unless you catch it somewhere
28
+ # on the way. You can make Rails rescue errors and render error pages on a
29
+ # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
30
+ #
31
+ # If you set this to true, Rails will rescue all errors and render error
32
+ # pages, more or less in the same way your application would behave in the
33
+ # default production environment. It's not recommended to do this for all
34
+ # of your scenarios, as this makes it hard to discover errors in your application.
35
+ ActionController::Base.allow_rescue = false
36
+
37
+ # If you set this to true, each scenario will run in a database transaction.
38
+ # You can still turn off transactions on a per-scenario basis, simply tagging
39
+ # a feature or scenario with the @no-txn tag. If you are using Capybara,
40
+ # tagging with @culerity or @javascript will also turn transactions off.
41
+ #
42
+ # If you set this to false, transactions will be off for all scenarios,
43
+ # regardless of whether you use @no-txn or not.
44
+ #
45
+ # Beware that turning transactions off will leave data in your database
46
+ # after each scenario, which can lead to hard-to-debug failures in
47
+ # subsequent scenarios. If you do this, we recommend you create a Before
48
+ # block that will explicitly put your database in a known state.
49
+ Cucumber::Rails::World.use_transactional_fixtures = true
50
+
51
+ # How to clean your database when transactions are turned off. See
52
+ # http://github.com/bmabey/database_cleaner for more info.
53
+ require 'database_cleaner'
54
+ DatabaseCleaner.strategy = :truncation
55
+
@@ -1,32 +1,32 @@
1
- module NavigationHelpers
2
- # Maps a name to a path. Used by the
3
- #
4
- # When /^I go to (.+)$/ do |page_name|
5
- #
6
- # step definition in web_steps.rb
7
- #
8
- def path_to(page_name)
9
- case page_name
10
-
11
- when /the home\s?page/
12
- '/'
13
- when /the pages admin page/
14
- admin_pages_path
15
- when /the page for "([^"]*)"/
16
- page = Page.find_by_title($1)
17
- page_path(page)
18
-
19
- # Add more mappings here.
20
- # Here is an example that pulls values out of the Regexp:
21
- #
22
- # when /^(.*)'s profile page$/i
23
- # user_profile_path(User.find_by_login($1))
24
-
25
- else
26
- raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
27
- "Now, go and add a mapping in #{__FILE__}"
28
- end
29
- end
30
- end
31
-
32
- World(NavigationHelpers)
1
+ module NavigationHelpers
2
+ # Maps a name to a path. Used by the
3
+ #
4
+ # When /^I go to (.+)$/ do |page_name|
5
+ #
6
+ # step definition in web_steps.rb
7
+ #
8
+ def path_to(page_name)
9
+ case page_name
10
+
11
+ when /the home\s?page/
12
+ '/'
13
+ when /the pages admin page/
14
+ admin_pages_path
15
+ when /the page for "([^"]*)"/
16
+ page = Page.find_by_title($1)
17
+ page_path(page)
18
+
19
+ # Add more mappings here.
20
+ # Here is an example that pulls values out of the Regexp:
21
+ #
22
+ # when /^(.*)'s profile page$/i
23
+ # user_profile_path(User.find_by_login($1))
24
+
25
+ else
26
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
27
+ "Now, go and add a mapping in #{__FILE__}"
28
+ end
29
+ end
30
+ end
31
+
32
+ World(NavigationHelpers)
@@ -1,3 +1,3 @@
1
- require 'spec/spec_helper'
2
- require 'spec/blueprints'
1
+ require 'spec/spec_helper'
2
+ require 'spec/blueprints'
3
3
  load_schema
@@ -1,5 +1,5 @@
1
- Description:
2
- Creates a migration to create a table to store pages called "pages"
3
-
4
- Examples:
1
+ Description:
2
+ Creates a migration to create a table to store pages called "pages"
3
+
4
+ Examples:
5
5
  `./script/generate shakespeare`
@@ -1,8 +1,8 @@
1
- class ShakespeareGenerator < Rails::Generator::Base
2
- def manifest
3
- record do |m|
4
- m.directory 'db/migrate'
5
- m.file "20091230095600_create_pages.rb", "db/migrate/20091230095600_create_pages.rb"
6
- end
7
- end
1
+ class ShakespeareGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.directory 'db/migrate'
5
+ m.file "20091230095600_create_pages.rb", "db/migrate/20091230095600_create_pages.rb"
6
+ end
7
+ end
8
8
  end
@@ -1,25 +1,25 @@
1
- class CreatePages < ActiveRecord::Migration
2
- def self.up
3
- create_table "pages", :force => true do |t|
4
- t.string "title"
5
- t.string "url"
6
- t.text "keywords"
7
- t.text "description"
8
- t.text "content"
9
- t.datetime "created_at"
10
- t.datetime "updated_at"
11
- t.boolean "noindex"
12
- t.boolean "nofollow"
13
- t.string "canonical"
14
- t.boolean "enable_canonical"
15
- t.boolean "enable_keywords"
16
- end
17
-
18
- add_index :pages, :url
19
- end
20
-
21
- def self.down
22
- remove_index :pages, :url
23
- drop_table :pages
24
- end
25
- end
1
+ class CreatePages < ActiveRecord::Migration
2
+ def self.up
3
+ create_table "pages", :force => true do |t|
4
+ t.string "title"
5
+ t.string "url"
6
+ t.text "keywords"
7
+ t.text "description"
8
+ t.text "content"
9
+ t.datetime "created_at"
10
+ t.datetime "updated_at"
11
+ t.boolean "noindex"
12
+ t.boolean "nofollow"
13
+ t.string "canonical"
14
+ t.boolean "enable_canonical"
15
+ t.boolean "enable_keywords"
16
+ end
17
+
18
+ add_index :pages, :url
19
+ end
20
+
21
+ def self.down
22
+ remove_index :pages, :url
23
+ drop_table :pages
24
+ end
25
+ end
data/lib/shakespeare.rb CHANGED
@@ -1,7 +1,7 @@
1
- require 'shakespeare/settings'
2
- require 'shakespeare/shakespeare'
3
- require 'shakespeare/helpers'
4
- require 'shakespeare/view_helpers'
5
-
6
- ApplicationController.send(:include, Shakespeare::Helpers)
1
+ require 'shakespeare/settings'
2
+ require 'shakespeare/shakespeare'
3
+ require 'shakespeare/helpers'
4
+ require 'shakespeare/view_helpers'
5
+
6
+ ApplicationController.send(:include, Shakespeare::Helpers)
7
7
  ActionView::Base.send(:include, Shakespeare::ViewHelpers)
@@ -1,16 +1,16 @@
1
- module Shakespeare
2
- module Helpers
3
- def self.included(base)
4
- base.send(:helper_method, :page_content) if base.respond_to?(:helper_method)
5
- end
6
-
7
- def page_content
8
- @page_content = Page.find_by_url("#{controller_name}/#{action_name}")
9
- end
10
-
11
- def protect_in_production
12
- return true unless Shakespeare.env == 'production'
13
- render :text => 'Unauthorized' unless Shakespeare::Settings.allow_anonymous
14
- end
15
- end
1
+ module Shakespeare
2
+ module Helpers
3
+ def self.included(base)
4
+ base.send(:helper_method, :page_content) if base.respond_to?(:helper_method)
5
+ end
6
+
7
+ def page_content
8
+ @page_content = Page.find_by_url("#{controller_name}/#{action_name}")
9
+ end
10
+
11
+ def protect_in_production
12
+ return true unless Shakespeare.env == 'production'
13
+ render :text => 'Unauthorized' unless Shakespeare::Settings.allow_anonymous
14
+ end
15
+ end
16
16
  end
@@ -1,30 +1,30 @@
1
- module Shakespeare
2
- class Settings
3
- class << self
4
- def layout
5
- @layout ||= 'admin'
6
- end
7
-
8
- def layout=(layout_choice)
9
- @layout = layout_choice
10
- end
11
-
12
- def before_filters
13
- @before_filters ||= []
14
- end
15
-
16
- def before_filters=(filters)
17
- @before_filters ||= filters
18
- end
19
-
20
- def allow_anonymous
21
- @allow_anonymous ||= false
22
- end
23
-
24
- def allow_anonymous=(boolean)
25
- @allow_anonymous = boolean
26
- end
27
- end
28
- end
29
-
1
+ module Shakespeare
2
+ class Settings
3
+ class << self
4
+ def layout
5
+ @layout ||= 'admin'
6
+ end
7
+
8
+ def layout=(layout_choice)
9
+ @layout = layout_choice
10
+ end
11
+
12
+ def before_filters
13
+ @before_filters ||= []
14
+ end
15
+
16
+ def before_filters=(filters)
17
+ @before_filters ||= filters
18
+ end
19
+
20
+ def allow_anonymous
21
+ @allow_anonymous ||= false
22
+ end
23
+
24
+ def allow_anonymous=(boolean)
25
+ @allow_anonymous = boolean
26
+ end
27
+ end
28
+ end
29
+
30
30
  end
@@ -1,8 +1,8 @@
1
- module Shakespeare
2
-
3
- class << self
4
- def env
5
- Rails.env
6
- end
7
- end
1
+ module Shakespeare
2
+
3
+ class << self
4
+ def env
5
+ Rails.env
6
+ end
7
+ end
8
8
  end
@@ -1,29 +1,29 @@
1
- module Shakespeare
2
- module ViewHelpers
3
- def page_title
4
- return if page_content.nil? or page_content.title.blank?
5
- page_content.title
6
- end
7
-
8
- def description_meta_tag
9
- return if page_content.nil? or page_content.description.blank?
10
- %Q[<meta name="description" content="#{page_content.description}">]
11
- end
12
-
13
- def keywords_meta_tag
14
- return if page_content.nil? or page_content.keywords.blank?
15
- %Q[<meta name="keywords" content="#{page_content.keywords}">]
16
- end
17
-
18
- def robots_meta_tag
19
- return if page_content.nil? or page_content.robots.blank?
20
- %Q[<meta name="robots" content="#{page_content.robots}">]
21
- end
22
-
23
- def canonical_link_tag
24
- return if page_content.nil? or page_content.canonical.blank?
25
- return unless page_content.enable_canonical?
26
- %Q[<link href="#{page_content.canonical}" rel="canonical" />]
27
- end
28
- end
1
+ module Shakespeare
2
+ module ViewHelpers
3
+ def page_title
4
+ return if page_content.nil? or page_content.title.blank?
5
+ page_content.title
6
+ end
7
+
8
+ def description_meta_tag
9
+ return if page_content.nil? or page_content.description.blank?
10
+ %Q[<meta name="description" content="#{page_content.description}">]
11
+ end
12
+
13
+ def keywords_meta_tag
14
+ return if page_content.nil? or page_content.keywords.blank?
15
+ %Q[<meta name="keywords" content="#{page_content.keywords}">]
16
+ end
17
+
18
+ def robots_meta_tag
19
+ return if page_content.nil? or page_content.robots.blank?
20
+ %Q[<meta name="robots" content="#{page_content.robots}">]
21
+ end
22
+
23
+ def canonical_link_tag
24
+ return if page_content.nil? or page_content.canonical.blank?
25
+ return unless page_content.enable_canonical?
26
+ %Q[<link href="#{page_content.canonical}" rel="canonical" />]
27
+ end
28
+ end
29
29
  end