shakespeare 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/Rakefile +42 -42
- data/app/controllers/admin/pages_controller.rb +46 -46
- data/app/controllers/pages_controller.rb +4 -4
- data/app/models/page.rb +26 -9
- data/app/views/admin/pages/_form.html.erb +37 -37
- data/config/routes.rb +7 -7
- data/features/admin_pages.feature +38 -37
- data/features/public_pages.feature +11 -11
- data/features/step_definitions/page_steps.rb +6 -6
- data/features/step_definitions/web_steps.rb +192 -259
- data/features/support/env.rb +55 -55
- data/features/support/paths.rb +32 -32
- data/lib/shakespeare.rb +6 -6
- data/rerun.txt +1 -1
- data/shakespeare.gemspec +5 -3
- data/spec/blueprints.rb +10 -8
- data/spec/debug.log +457 -0
- data/spec/models/page_spec.rb +43 -27
- metadata +4 -3
data/CHANGELOG
ADDED
data/Rakefile
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'spec/rake/spectask'
|
3
|
-
|
4
|
-
desc 'Default: run specs.'
|
5
|
-
task :default => :spec
|
6
|
-
|
7
|
-
desc 'Run the specs'
|
8
|
-
Spec::Rake::SpecTask.new(:spec) do |t|
|
9
|
-
t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
|
10
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
11
|
-
end
|
12
|
-
|
13
|
-
PKG_FILES = FileList[
|
14
|
-
'[a-zA-Z]*',
|
15
|
-
'app/**/*',
|
16
|
-
'generators/**/*',
|
17
|
-
'config/*',
|
18
|
-
'lib/**/*',
|
19
|
-
'rails/**/*',
|
20
|
-
'spec/**/*',
|
21
|
-
'features/**/*'
|
22
|
-
]
|
23
|
-
|
24
|
-
begin
|
25
|
-
require 'jeweler'
|
26
|
-
Jeweler::Tasks.new do |s|
|
27
|
-
s.name = "shakespeare"
|
28
|
-
s.version = "0.
|
29
|
-
s.author = "Paul Campbell"
|
30
|
-
s.email = "paul@rslw.com"
|
31
|
-
s.homepage = "http://www.github.com/paulca/shakespeare"
|
32
|
-
s.platform = Gem::Platform::RUBY
|
33
|
-
s.summary = "A Rails drop in CMS."
|
34
|
-
s.files = PKG_FILES.to_a
|
35
|
-
s.require_path = "lib"
|
36
|
-
s.has_rdoc = false
|
37
|
-
s.extra_rdoc_files = ["README.md"]
|
38
|
-
end
|
39
|
-
rescue LoadError
|
40
|
-
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
41
|
-
end
|
42
|
-
|
1
|
+
require 'rake'
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
desc 'Default: run specs.'
|
5
|
+
task :default => :spec
|
6
|
+
|
7
|
+
desc 'Run the specs'
|
8
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
9
|
+
t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
|
10
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
11
|
+
end
|
12
|
+
|
13
|
+
PKG_FILES = FileList[
|
14
|
+
'[a-zA-Z]*',
|
15
|
+
'app/**/*',
|
16
|
+
'generators/**/*',
|
17
|
+
'config/*',
|
18
|
+
'lib/**/*',
|
19
|
+
'rails/**/*',
|
20
|
+
'spec/**/*',
|
21
|
+
'features/**/*'
|
22
|
+
]
|
23
|
+
|
24
|
+
begin
|
25
|
+
require 'jeweler'
|
26
|
+
Jeweler::Tasks.new do |s|
|
27
|
+
s.name = "shakespeare"
|
28
|
+
s.version = "0.2.0"
|
29
|
+
s.author = "Paul Campbell"
|
30
|
+
s.email = "paul@rslw.com"
|
31
|
+
s.homepage = "http://www.github.com/paulca/shakespeare"
|
32
|
+
s.platform = Gem::Platform::RUBY
|
33
|
+
s.summary = "A Rails drop in CMS."
|
34
|
+
s.files = PKG_FILES.to_a
|
35
|
+
s.require_path = "lib"
|
36
|
+
s.has_rdoc = false
|
37
|
+
s.extra_rdoc_files = ["README.md"]
|
38
|
+
end
|
39
|
+
rescue LoadError
|
40
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
41
|
+
end
|
42
|
+
|
43
43
|
Jeweler::GemcutterTasks.new
|
@@ -1,47 +1,47 @@
|
|
1
|
-
class Admin::PagesController < ApplicationController
|
2
|
-
|
3
|
-
|
4
|
-
Shakespeare::Settings.before_filters.each do |filter|
|
5
|
-
before_filter filter
|
6
|
-
end
|
7
|
-
before_filter :protect_in_production if Shakespeare::Settings.before_filters.empty?
|
8
|
-
|
9
|
-
layout Shakespeare::Settings.layout
|
10
|
-
|
11
|
-
def index
|
12
|
-
@pages = Page.all
|
13
|
-
end
|
14
|
-
|
15
|
-
def new
|
16
|
-
@page = Page.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def create
|
20
|
-
@page = Page.new(params[:page])
|
21
|
-
if @page.save
|
22
|
-
redirect_to admin_pages_path
|
23
|
-
else
|
24
|
-
render :new
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def edit
|
29
|
-
@page = Page.
|
30
|
-
end
|
31
|
-
|
32
|
-
def update
|
33
|
-
@page = Page.
|
34
|
-
if @page.update_attributes(params[:page])
|
35
|
-
redirect_to admin_pages_path
|
36
|
-
else
|
37
|
-
render :edit
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def destroy
|
42
|
-
@page = Page.
|
43
|
-
@page.destroy
|
44
|
-
redirect_to admin_pages_path
|
45
|
-
end
|
46
|
-
|
1
|
+
class Admin::PagesController < ApplicationController
|
2
|
+
|
3
|
+
|
4
|
+
Shakespeare::Settings.before_filters.each do |filter|
|
5
|
+
before_filter filter
|
6
|
+
end
|
7
|
+
before_filter :protect_in_production if Shakespeare::Settings.before_filters.empty?
|
8
|
+
|
9
|
+
layout Shakespeare::Settings.layout
|
10
|
+
|
11
|
+
def index
|
12
|
+
@pages = Page.all
|
13
|
+
end
|
14
|
+
|
15
|
+
def new
|
16
|
+
@page = Page.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@page = Page.new(params[:page])
|
21
|
+
if @page.save
|
22
|
+
redirect_to admin_pages_path
|
23
|
+
else
|
24
|
+
render :new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def edit
|
29
|
+
@page = Page.find_by_url(params[:id])
|
30
|
+
end
|
31
|
+
|
32
|
+
def update
|
33
|
+
@page = Page.find_by_url(params[:id])
|
34
|
+
if @page.update_attributes(params[:page])
|
35
|
+
redirect_to admin_pages_path
|
36
|
+
else
|
37
|
+
render :edit
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def destroy
|
42
|
+
@page = Page.find_by_url(params[:id])
|
43
|
+
@page.destroy
|
44
|
+
redirect_to admin_pages_path
|
45
|
+
end
|
46
|
+
|
47
47
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
class PagesController < ApplicationController
|
2
|
-
def show
|
3
|
-
@page = Page.
|
4
|
-
end
|
1
|
+
class PagesController < ApplicationController
|
2
|
+
def show
|
3
|
+
@page = Page.find_by_url(params[:id])
|
4
|
+
end
|
5
5
|
end
|
data/app/models/page.rb
CHANGED
@@ -1,10 +1,27 @@
|
|
1
|
-
class Page < ActiveRecord::Base
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
class Page < ActiveRecord::Base
|
2
|
+
|
3
|
+
validates_presence_of :title
|
4
|
+
validates_format_of :url, :with => /\s*/, :if => Proc.new { |p| !p.url.blank? }
|
5
|
+
|
6
|
+
before_validation :set_url
|
7
|
+
|
8
|
+
def robots
|
9
|
+
out = []
|
10
|
+
out << 'noindex' if noindex?
|
11
|
+
out << 'nofollow' if nofollow?
|
12
|
+
out.join(', ')
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_param
|
16
|
+
url
|
17
|
+
end
|
18
|
+
|
19
|
+
def clean_url
|
20
|
+
title.to_s.downcase.gsub(/[^a-z0-9\s]/, '').gsub(/\s/,'-')
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_url
|
24
|
+
self.url ||= clean_url
|
25
|
+
end
|
26
|
+
|
10
27
|
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
<% form_for [:admin, @page] do |f| -%>
|
2
|
-
|
3
|
-
<%= f.error_messages %>
|
4
|
-
|
5
|
-
<fieldset>
|
6
|
-
<%= f.label :url, "URL" %> <%= f.text_field :url %> <em>This can be an existing controller_name/action_name combo, or a completely new URL.</em> <br />
|
7
|
-
</fieldset>
|
8
|
-
|
9
|
-
<fieldset>
|
10
|
-
<%= f.label :title, "Title" %>
|
11
|
-
<%= f.text_field :title %> <br />
|
12
|
-
<fieldset>
|
13
|
-
<legend>Robots</legend>
|
14
|
-
|
15
|
-
<%= f.check_box :noindex %>
|
16
|
-
<%= f.label :noindex, "No-Index", :class => 'inline' %>
|
17
|
-
|
18
|
-
<%= f.check_box :nofollow %>
|
19
|
-
<%= f.label :nofollow, "No-follow", :class => 'inline' %>
|
20
|
-
|
21
|
-
<%= f.check_box :enable_canonical %>
|
22
|
-
<%= f.label :enable_canonical, "Set Canonical Tag?", :class => 'inline' %>
|
23
|
-
|
24
|
-
<%= f.label :canonical, "Canonical URL" %>
|
25
|
-
<%= f.text_field :canonical %> <br />
|
26
|
-
|
27
|
-
|
28
|
-
<%= f.label :description, "Description" %> <%= f.text_area :description, :class => "small-text" %> <br />
|
29
|
-
<%= f.label :keywords, "Keywords" %> <%= f.text_field :keywords %> <br />
|
30
|
-
</fieldset>
|
31
|
-
|
32
|
-
<fieldset>
|
33
|
-
<%= f.label :content, "Content" %> <%= f.text_area :content %> <br />
|
34
|
-
</fieldset>
|
35
|
-
|
36
|
-
|
37
|
-
<%= f.submit "Save" %> or <%= link_to "Cancel", admin_pages_path %>
|
1
|
+
<% form_for [:admin, @page] do |f| -%>
|
2
|
+
|
3
|
+
<%= f.error_messages %>
|
4
|
+
|
5
|
+
<fieldset>
|
6
|
+
<%= f.label :url, "URL" %> <%= f.text_field :url %> <em>This can be an existing controller_name/action_name combo, or a completely new URL.</em> <br />
|
7
|
+
</fieldset>
|
8
|
+
|
9
|
+
<fieldset>
|
10
|
+
<%= f.label :title, "Title" %>
|
11
|
+
<%= f.text_field :title %> <br />
|
12
|
+
<fieldset>
|
13
|
+
<legend>Robots</legend>
|
14
|
+
|
15
|
+
<%= f.check_box :noindex %>
|
16
|
+
<%= f.label :noindex, "No-Index", :class => 'inline' %>
|
17
|
+
|
18
|
+
<%= f.check_box :nofollow %>
|
19
|
+
<%= f.label :nofollow, "No-follow", :class => 'inline' %>
|
20
|
+
|
21
|
+
<%= f.check_box :enable_canonical %>
|
22
|
+
<%= f.label :enable_canonical, "Set Canonical Tag?", :class => 'inline' %>
|
23
|
+
|
24
|
+
<%= f.label :canonical, "Canonical URL" %>
|
25
|
+
<%= f.text_field :canonical %> <br />
|
26
|
+
|
27
|
+
|
28
|
+
<%= f.label :description, "Description" %> <%= f.text_area :description, :class => "small-text" %> <br />
|
29
|
+
<%= f.label :keywords, "Keywords" %> <%= f.text_field :keywords %> <br />
|
30
|
+
</fieldset>
|
31
|
+
|
32
|
+
<fieldset>
|
33
|
+
<%= f.label :content, "Content" %> <%= f.text_area :content %> <br />
|
34
|
+
</fieldset>
|
35
|
+
|
36
|
+
|
37
|
+
<%= f.submit "Save" %> or <%= link_to "Cancel", admin_pages_path %>
|
38
38
|
<% end -%>
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
ActionController::Routing::Routes.draw do |map|
|
2
|
-
|
3
|
-
map.resources :pages
|
4
|
-
|
5
|
-
map.namespace :admin do |admin|
|
6
|
-
admin.resources :pages
|
7
|
-
end
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
2
|
+
|
3
|
+
map.resources :pages, :requirements => {:id => /.*/}
|
4
|
+
|
5
|
+
map.namespace :admin do |admin|
|
6
|
+
admin.resources :pages, :requirements => {:id => /.*/}
|
7
|
+
end
|
8
8
|
end
|
@@ -1,38 +1,39 @@
|
|
1
|
-
Feature: Managing Pages
|
2
|
-
In order to update the site
|
3
|
-
As an admin
|
4
|
-
I want to add, edit and delete pages
|
5
|
-
|
6
|
-
Scenario: I'm on the admin layout
|
7
|
-
When I am on the pages admin page
|
8
|
-
Then I should see "Admin"
|
9
|
-
|
10
|
-
Scenario: New Page
|
11
|
-
Given I am on the pages admin page
|
12
|
-
When I follow "Add a New Page"
|
13
|
-
And I fill in "Title" with "Harry and the Hendersons"
|
14
|
-
And I fill in "Keywords" with "80s, movie"
|
15
|
-
And I check "No-
|
16
|
-
And I check "No-follow"
|
17
|
-
And I check "Set Canonical Tag?"
|
18
|
-
And I fill in "Canonical URL" with "http://hendersons.com"
|
19
|
-
And I press "Save"
|
20
|
-
Then I should see "Harry and the Hendersons"
|
21
|
-
|
22
|
-
Scenario: Edit Page
|
23
|
-
Given a page titled "Harry and the Hendersons"
|
24
|
-
And I am on the pages admin page
|
25
|
-
When I follow "Edit"
|
26
|
-
And I fill in "Title" with "Three Men and a Baby"
|
27
|
-
And I press "Save"
|
28
|
-
Then I should see "Three Men and a Baby"
|
29
|
-
And I should not see "Harry and the Hendersons"
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
1
|
+
Feature: Managing Pages
|
2
|
+
In order to update the site
|
3
|
+
As an admin
|
4
|
+
I want to add, edit and delete pages
|
5
|
+
|
6
|
+
Scenario: I'm on the admin layout
|
7
|
+
When I am on the pages admin page
|
8
|
+
Then I should see "Admin"
|
9
|
+
|
10
|
+
Scenario: New Page
|
11
|
+
Given I am on the pages admin page
|
12
|
+
When I follow "Add a New Page"
|
13
|
+
And I fill in "Title" with "Harry and the Hendersons"
|
14
|
+
And I fill in "Keywords" with "80s, movie"
|
15
|
+
And I check "No-Index"
|
16
|
+
And I check "No-follow"
|
17
|
+
And I check "Set Canonical Tag?"
|
18
|
+
And I fill in "Canonical URL" with "http://hendersons.com"
|
19
|
+
And I press "Save"
|
20
|
+
Then I should see "Harry and the Hendersons"
|
21
|
+
|
22
|
+
Scenario: Edit Page
|
23
|
+
Given a page titled "Harry and the Hendersons"
|
24
|
+
And I am on the pages admin page
|
25
|
+
When I follow "Edit"
|
26
|
+
And I fill in "Title" with "Three Men and a Baby"
|
27
|
+
And I press "Save"
|
28
|
+
Then I should see "Three Men and a Baby"
|
29
|
+
And I should not see "Harry and the Hendersons"
|
30
|
+
|
31
|
+
@emulate_rails_javascript
|
32
|
+
Scenario: Delete Page
|
33
|
+
Given a page titled "The Departed"
|
34
|
+
When I am on the pages admin page
|
35
|
+
Then I should see "The Departed"
|
36
|
+
|
37
|
+
When I follow "Delete"
|
38
|
+
Then I should not see "The Departed"
|
38
39
|
|
@@ -1,12 +1,12 @@
|
|
1
|
-
Feature: Public Pages
|
2
|
-
In order to find out more information
|
3
|
-
As a user
|
4
|
-
I want to be able to see what's on a page
|
5
|
-
|
6
|
-
Scenario: A public page
|
7
|
-
Given a page titled "Mr. MacAllister's Christmas"
|
8
|
-
And page "Mr. MacAllister's Christmas" has content "I was Home Alone"
|
9
|
-
|
10
|
-
When I am on the page for "Mr. MacAllister's Christmas"
|
11
|
-
|
1
|
+
Feature: Public Pages
|
2
|
+
In order to find out more information
|
3
|
+
As a user
|
4
|
+
I want to be able to see what's on a page
|
5
|
+
|
6
|
+
Scenario: A public page
|
7
|
+
Given a page titled "Mr. MacAllister's Christmas"
|
8
|
+
And page "Mr. MacAllister's Christmas" has content "I was Home Alone"
|
9
|
+
|
10
|
+
When I am on the page for "Mr. MacAllister's Christmas"
|
11
|
+
|
12
12
|
Then I should see "I was Home Alone"
|
@@ -1,7 +1,7 @@
|
|
1
|
-
Given /^a page titled "([^\"]*)"$/ do |title|
|
2
|
-
Page.make(:title => title)
|
3
|
-
end
|
4
|
-
|
5
|
-
Given /^page "([^\"]*)" has content "([^\"]*)"$/ do |title, content|
|
6
|
-
Page.find_by_title(title).update_attribute(:content, content)
|
1
|
+
Given /^a page titled "([^\"]*)"$/ do |title|
|
2
|
+
Page.make(:title => title)
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^page "([^\"]*)" has content "([^\"]*)"$/ do |title, content|
|
6
|
+
Page.find_by_title(title).update_attribute(:content, content)
|
7
7
|
end
|
@@ -1,259 +1,192 @@
|
|
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
|
-
|
8
|
-
require
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
#
|
51
|
-
#
|
52
|
-
When
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
When
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
end
|
140
|
-
|
141
|
-
Then /^(
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
end
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
end
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
198
|
-
regexp = Regexp.new(regexp)
|
199
|
-
if defined?(Spec::Rails::Matchers)
|
200
|
-
response.should_not contain(regexp)
|
201
|
-
else
|
202
|
-
assert_not_contain regexp
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
|
207
|
-
within(selector) do |content|
|
208
|
-
regexp = Regexp.new(regexp)
|
209
|
-
if defined?(Spec::Rails::Matchers)
|
210
|
-
content.should_not contain(regexp)
|
211
|
-
else
|
212
|
-
assert content !~ regexp
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
|
218
|
-
if defined?(Spec::Rails::Matchers)
|
219
|
-
field_labeled(field).value.should =~ /#{value}/
|
220
|
-
else
|
221
|
-
assert_match(/#{value}/, field_labeled(field).value)
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
|
226
|
-
if defined?(Spec::Rails::Matchers)
|
227
|
-
field_labeled(field).value.should_not =~ /#{value}/
|
228
|
-
else
|
229
|
-
assert_no_match(/#{value}/, field_labeled(field).value)
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
234
|
-
if defined?(Spec::Rails::Matchers)
|
235
|
-
field_labeled(label).should be_checked
|
236
|
-
else
|
237
|
-
assert field_labeled(label).checked?
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
|
242
|
-
if defined?(Spec::Rails::Matchers)
|
243
|
-
field_labeled(label).should_not be_checked
|
244
|
-
else
|
245
|
-
assert !field_labeled(label).checked?
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
250
|
-
if defined?(Spec::Rails::Matchers)
|
251
|
-
URI.parse(current_url).path.should == path_to(page_name)
|
252
|
-
else
|
253
|
-
assert_equal path_to(page_name), URI.parse(current_url).path
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
Then /^show me the page$/ do
|
258
|
-
save_and_open_page
|
259
|
-
end
|
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
|
+
|
8
|
+
require 'uri'
|
9
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
10
|
+
|
11
|
+
module WithinHelpers
|
12
|
+
def with_scope(locator)
|
13
|
+
locator ? within(locator) { yield } : yield
|
14
|
+
end
|
15
|
+
end
|
16
|
+
World(WithinHelpers)
|
17
|
+
|
18
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
19
|
+
visit path_to(page_name)
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
23
|
+
visit path_to(page_name)
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^(?:|I )press "([^\"]*)"(?: within "([^\"]*)")?$/ do |button, selector|
|
27
|
+
with_scope(selector) do
|
28
|
+
click_button(button)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
When /^(?:|I )follow "([^\"]*)"(?: within "([^\"]*)")?$/ do |link, selector|
|
33
|
+
with_scope(selector) do
|
34
|
+
click_link(link)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, value, selector|
|
39
|
+
with_scope(selector) do
|
40
|
+
fill_in(field, :with => value)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
|
45
|
+
with_scope(selector) do
|
46
|
+
fill_in(field, :with => value)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Use this to fill in an entire form with data from a table. Example:
|
51
|
+
#
|
52
|
+
# When I fill in the following:
|
53
|
+
# | Account Number | 5002 |
|
54
|
+
# | Expiry date | 2009-11-01 |
|
55
|
+
# | Note | Nice guy |
|
56
|
+
# | Wants Email? | |
|
57
|
+
#
|
58
|
+
# TODO: Add support for checkbox, select og option
|
59
|
+
# based on naming conventions.
|
60
|
+
#
|
61
|
+
When /^(?:|I )fill in the following(?: within "([^\"]*)")?:$/ do |selector, fields|
|
62
|
+
with_scope(selector) do
|
63
|
+
fields.rows_hash.each do |name, value|
|
64
|
+
When %{I fill in "#{name}" with "#{value}"}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
When /^(?:|I )select "([^\"]*)" from "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
|
70
|
+
with_scope(selector) do
|
71
|
+
select(value, :from => field)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
When /^(?:|I )check "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
|
76
|
+
with_scope(selector) do
|
77
|
+
check(field)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
When /^(?:|I )uncheck "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
|
82
|
+
with_scope(selector) do
|
83
|
+
uncheck(field)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
When /^(?:|I )choose "([^\"]*)"(?: within "([^\"]*)")?$/ do |field, selector|
|
88
|
+
with_scope(selector) do
|
89
|
+
choose(field)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"(?: within "([^\"]*)")?$/ do |path, field, selector|
|
94
|
+
with_scope(selector) do
|
95
|
+
attach_file(field, path)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
Then /^(?:|I )should see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
|
100
|
+
with_scope(selector) do
|
101
|
+
if defined?(Spec::Rails::Matchers)
|
102
|
+
page.should have_content(text)
|
103
|
+
else
|
104
|
+
assert page.has_content?(text)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^\"]*)")?$/ do |regexp, selector|
|
110
|
+
regexp = Regexp.new(regexp)
|
111
|
+
with_scope(selector) do
|
112
|
+
if defined?(Spec::Rails::Matchers)
|
113
|
+
page.should have_xpath('//*', :text => regexp)
|
114
|
+
else
|
115
|
+
assert page.has_xpath?('//*', :text => regexp)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
Then /^(?:|I )should not see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector|
|
121
|
+
with_scope(selector) do
|
122
|
+
if defined?(Spec::Rails::Matchers)
|
123
|
+
page.should have_no_content(text)
|
124
|
+
else
|
125
|
+
assert page.has_no_content?(text)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^\"]*)")?$/ do |regexp, selector|
|
131
|
+
regexp = Regexp.new(regexp)
|
132
|
+
with_scope(selector) do
|
133
|
+
if defined?(Spec::Rails::Matchers)
|
134
|
+
page.shoul have_not_xpath('//*', :text => regexp)
|
135
|
+
else
|
136
|
+
assert page.has_not_xpath?('//*', :text => regexp)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should contain "([^\"]*)"$/ do |field, selector, value|
|
142
|
+
with_scope(selector) do
|
143
|
+
if defined?(Spec::Rails::Matchers)
|
144
|
+
find_field(field).value.should =~ /#{value}/
|
145
|
+
else
|
146
|
+
assert_match(/#{value}/, field_labeled(field).value)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
Then /^the "([^\"]*)" field(?: within "([^\"]*)")? should not contain "([^\"]*)"$/ do |field, selector, value|
|
152
|
+
with_scope(selector) do
|
153
|
+
if defined?(Spec::Rails::Matchers)
|
154
|
+
find_field(field).value.should_not =~ /#{value}/
|
155
|
+
else
|
156
|
+
assert_no_match(/#{value}/, find_field(field).value)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should be checked$/ do |label, selector|
|
162
|
+
with_scope(selector) do
|
163
|
+
if defined?(Spec::Rails::Matchers)
|
164
|
+
find_field(label)['checked'].should == 'checked'
|
165
|
+
else
|
166
|
+
assert field_labeled(label)['checked'] == 'checked'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should not be checked$/ do |label, selector|
|
172
|
+
with_scope(selector) do
|
173
|
+
if defined?(Spec::Rails::Matchers)
|
174
|
+
find_field(label)['checked'].should_not == 'checked'
|
175
|
+
else
|
176
|
+
assert field_labeled(label)['checked'] != 'checked'
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
182
|
+
current_path = URI.parse(current_url).select(:path, :query).compact.join('?')
|
183
|
+
if defined?(Spec::Rails::Matchers)
|
184
|
+
current_path.should == path_to(page_name)
|
185
|
+
else
|
186
|
+
assert_equal path_to(page_name), current_path
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
Then /^show me the page$/ do
|
191
|
+
save_and_open_page
|
192
|
+
end
|