interpreter 0.0.2 → 0.0.3
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.
- data/.gitignore +1 -0
- data/.rvmrc +1 -0
- data/{LICENSE.txt → MIT-LICENSE} +0 -0
- data/Rakefile +14 -0
- data/app/controllers/interpreter/translations_controller.rb +1 -0
- data/app/views/layouts/translations.html.haml +11 -0
- data/interpreter.gemspec +3 -0
- data/lib/interpreter/version.rb +1 -1
- data/test/dummy/.gitignore +4 -0
- data/test/dummy/Gemfile +16 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +42 -0
- data/test/dummy/config/boot.rb +6 -0
- data/test/dummy/config/cucumber.yml +8 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +26 -0
- data/test/dummy/config/environments/production.rb +49 -0
- data/test/dummy/config/environments/test.rb +35 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/interpreter.rb +3 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/db/schema.rb +15 -0
- data/test/dummy/db/seeds.rb +7 -0
- data/test/dummy/doc/README_FOR_APP +2 -0
- data/test/dummy/features/manage_translations.feature +14 -0
- data/test/dummy/features/step_definitions/pickle_steps.rb +100 -0
- data/test/dummy/features/step_definitions/translation_steps.rb +14 -0
- data/test/dummy/features/step_definitions/web_steps.rb +211 -0
- data/test/dummy/features/support/env.rb +47 -0
- data/test/dummy/features/support/factory_girl.rb +3 -0
- data/test/dummy/features/support/paths.rb +50 -0
- data/test/dummy/features/support/pickle.rb +25 -0
- data/test/dummy/features/support/selectors.rb +39 -0
- data/test/dummy/lib/tasks/.gitkeep +0 -0
- data/test/dummy/lib/tasks/cucumber.rake +57 -0
- data/test/dummy/lib/tasks/test.rake +9 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/javascripts/application.js +2 -0
- data/test/dummy/public/javascripts/controls.js +965 -0
- data/test/dummy/public/javascripts/dragdrop.js +974 -0
- data/test/dummy/public/javascripts/effects.js +1123 -0
- data/test/dummy/public/javascripts/prototype.js +6001 -0
- data/test/dummy/public/javascripts/rails.js +191 -0
- data/test/dummy/public/stylesheets/.gitkeep +0 -0
- data/test/dummy/script/cucumber +10 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/vendor/plugins/.gitkeep +0 -0
- metadata +133 -7
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your
|
6
|
+
# database schema. If you need to create the application database on another
|
7
|
+
# system, you should be using db:schema:load, not running all the migrations
|
8
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
|
+
#
|
11
|
+
# It's strongly recommended to check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(:version => 0) do
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
7
|
+
# Mayor.create(:name => 'Daley', :city => cities.first)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: Manage translations
|
2
|
+
In order to manage translations
|
3
|
+
As an user
|
4
|
+
I want to view, add and edit translations
|
5
|
+
|
6
|
+
Scenario: Register new translation
|
7
|
+
Given I am on translations page
|
8
|
+
When I fill in "Locale" with "locale 1"
|
9
|
+
And I fill in "Key" with "key 1"
|
10
|
+
And I fill in "Value" with "value 1"
|
11
|
+
And I press "Save"
|
12
|
+
Then I should see "locale 1"
|
13
|
+
And I should see "key 1"
|
14
|
+
And I should see "value 1"
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# this file generated by script/generate pickle
|
2
|
+
|
3
|
+
# create a model
|
4
|
+
Given(/^#{capture_model} exists?(?: with #{capture_fields})?$/) do |name, fields|
|
5
|
+
create_model(name, fields)
|
6
|
+
end
|
7
|
+
|
8
|
+
# create n models
|
9
|
+
Given(/^(\d+) #{capture_plural_factory} exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
|
10
|
+
count.to_i.times { create_model(plural_factory.singularize, fields) }
|
11
|
+
end
|
12
|
+
|
13
|
+
# create models from a table
|
14
|
+
Given(/^the following #{capture_plural_factory} exists?:?$/) do |plural_factory, table|
|
15
|
+
create_models_from_table(plural_factory, table)
|
16
|
+
end
|
17
|
+
|
18
|
+
# find a model
|
19
|
+
Then(/^#{capture_model} should exist(?: with #{capture_fields})?$/) do |name, fields|
|
20
|
+
find_model!(name, fields)
|
21
|
+
end
|
22
|
+
|
23
|
+
# not find a model
|
24
|
+
Then(/^#{capture_model} should not exist(?: with #{capture_fields})?$/) do |name, fields|
|
25
|
+
find_model(name, fields).should be_nil
|
26
|
+
end
|
27
|
+
|
28
|
+
# find models with a table
|
29
|
+
Then(/^the following #{capture_plural_factory} should exists?:?$/) do |plural_factory, table|
|
30
|
+
find_models_from_table(plural_factory, table).should_not be_any(&:nil?)
|
31
|
+
end
|
32
|
+
|
33
|
+
# find exactly n models
|
34
|
+
Then(/^(\d+) #{capture_plural_factory} should exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
|
35
|
+
find_models(plural_factory.singularize, fields).size.should == count.to_i
|
36
|
+
end
|
37
|
+
|
38
|
+
# assert equality of models
|
39
|
+
Then(/^#{capture_model} should be #{capture_model}$/) do |a, b|
|
40
|
+
model!(a).should == model!(b)
|
41
|
+
end
|
42
|
+
|
43
|
+
# assert model is in another model's has_many assoc
|
44
|
+
Then(/^#{capture_model} should be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
45
|
+
model!(owner).send(association).should include(model!(target))
|
46
|
+
end
|
47
|
+
|
48
|
+
# assert model is not in another model's has_many assoc
|
49
|
+
Then(/^#{capture_model} should not be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
50
|
+
model!(owner).send(association).should_not include(model!(target))
|
51
|
+
end
|
52
|
+
|
53
|
+
# assert model is another model's has_one/belongs_to assoc
|
54
|
+
Then(/^#{capture_model} should be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
55
|
+
model!(owner).send(association).should == model!(target)
|
56
|
+
end
|
57
|
+
|
58
|
+
# assert model is not another model's has_one/belongs_to assoc
|
59
|
+
Then(/^#{capture_model} should not be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
60
|
+
model!(owner).send(association).should_not == model!(target)
|
61
|
+
end
|
62
|
+
|
63
|
+
# assert model.predicate?
|
64
|
+
Then(/^#{capture_model} should (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
|
65
|
+
if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
|
66
|
+
model!(name).should send("have_#{predicate.gsub(' ', '_')}")
|
67
|
+
else
|
68
|
+
model!(name).should send("be_#{predicate.gsub(' ', '_')}")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# assert not model.predicate?
|
73
|
+
Then(/^#{capture_model} should not (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
|
74
|
+
if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
|
75
|
+
model!(name).should_not send("have_#{predicate.gsub(' ', '_')}")
|
76
|
+
else
|
77
|
+
model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# model.attribute.should eql(value)
|
82
|
+
# model.attribute.should_not eql(value)
|
83
|
+
Then(/^#{capture_model}'s (\w+) (should(?: not)?) be #{capture_value}$/) do |name, attribute, expectation, expected|
|
84
|
+
actual_value = model(name).send(attribute)
|
85
|
+
expectation = expectation.gsub(' ', '_')
|
86
|
+
|
87
|
+
case expected
|
88
|
+
when 'nil', 'true', 'false'
|
89
|
+
actual_value.send(expectation, send("be_#{expected}"))
|
90
|
+
when /^[+-]?[0-9_]+(\.\d+)?$/
|
91
|
+
actual_value.send(expectation, eql(expected.to_f))
|
92
|
+
else
|
93
|
+
actual_value.to_s.send(expectation, eql(eval(expected)))
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# assert size of association
|
98
|
+
Then /^#{capture_model} should have (\d+) (\w+)$/ do |name, size, association|
|
99
|
+
model!(name).send(association).size.should == size.to_i
|
100
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Given /^the following translations:$/ do |translations|
|
2
|
+
Translation.create!(translations.hashes)
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^I delete the (\d+)(?:st|nd|rd|th) translation$/ do |pos|
|
6
|
+
visit translations_path
|
7
|
+
within("table tr:nth-child(#{pos.to_i+1})") do
|
8
|
+
click_link "Destroy"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Then /^I should see the following translations:$/ do |expected_translations_table|
|
13
|
+
expected_translations_table.diff!(tableish('table tr', 'td,th'))
|
14
|
+
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
# TL;DR: YOU SHOULD DELETE THIS FILE
|
2
|
+
#
|
3
|
+
# This file was generated by Cucumber-Rails and is only here to get you a head start
|
4
|
+
# These step definitions are thin wrappers around the Capybara/Webrat API that lets you
|
5
|
+
# visit pages, interact with widgets and make assertions about page content.
|
6
|
+
#
|
7
|
+
# If you use these step definitions as basis for your features you will quickly end up
|
8
|
+
# with features that are:
|
9
|
+
#
|
10
|
+
# * Hard to maintain
|
11
|
+
# * Verbose to read
|
12
|
+
#
|
13
|
+
# A much better approach is to write your own higher level step definitions, following
|
14
|
+
# the advice in the following blog posts:
|
15
|
+
#
|
16
|
+
# * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
|
17
|
+
# * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
|
18
|
+
# * http://elabs.se/blog/15-you-re-cuking-it-wrong
|
19
|
+
#
|
20
|
+
|
21
|
+
|
22
|
+
require 'uri'
|
23
|
+
require 'cgi'
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
26
|
+
|
27
|
+
module WithinHelpers
|
28
|
+
def with_scope(locator)
|
29
|
+
locator ? within(*selector_for(locator)) { yield } : yield
|
30
|
+
end
|
31
|
+
end
|
32
|
+
World(WithinHelpers)
|
33
|
+
|
34
|
+
# Single-line step scoper
|
35
|
+
When /^(.*) within ([^:]+)$/ do |step, parent|
|
36
|
+
with_scope(parent) { When step }
|
37
|
+
end
|
38
|
+
|
39
|
+
# Multi-line step scoper
|
40
|
+
When /^(.*) within ([^:]+):$/ do |step, parent, table_or_string|
|
41
|
+
with_scope(parent) { When "#{step}:", table_or_string }
|
42
|
+
end
|
43
|
+
|
44
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
45
|
+
visit path_to(page_name)
|
46
|
+
end
|
47
|
+
|
48
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
49
|
+
visit path_to(page_name)
|
50
|
+
end
|
51
|
+
|
52
|
+
When /^(?:|I )press "([^"]*)"$/ do |button|
|
53
|
+
click_button(button)
|
54
|
+
end
|
55
|
+
|
56
|
+
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
57
|
+
click_link(link)
|
58
|
+
end
|
59
|
+
|
60
|
+
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
61
|
+
fill_in(field, :with => value)
|
62
|
+
end
|
63
|
+
|
64
|
+
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
65
|
+
fill_in(field, :with => value)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Use this to fill in an entire form with data from a table. Example:
|
69
|
+
#
|
70
|
+
# When I fill in the following:
|
71
|
+
# | Account Number | 5002 |
|
72
|
+
# | Expiry date | 2009-11-01 |
|
73
|
+
# | Note | Nice guy |
|
74
|
+
# | Wants Email? | |
|
75
|
+
#
|
76
|
+
# TODO: Add support for checkbox, select og option
|
77
|
+
# based on naming conventions.
|
78
|
+
#
|
79
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
80
|
+
fields.rows_hash.each do |name, value|
|
81
|
+
When %{I fill in "#{name}" with "#{value}"}
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
86
|
+
select(value, :from => field)
|
87
|
+
end
|
88
|
+
|
89
|
+
When /^(?:|I )check "([^"]*)"$/ do |field|
|
90
|
+
check(field)
|
91
|
+
end
|
92
|
+
|
93
|
+
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
94
|
+
uncheck(field)
|
95
|
+
end
|
96
|
+
|
97
|
+
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
98
|
+
choose(field)
|
99
|
+
end
|
100
|
+
|
101
|
+
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
102
|
+
attach_file(field, File.expand_path(path))
|
103
|
+
end
|
104
|
+
|
105
|
+
Then /^(?:|I )should see "([^"]*)"$/ do |text|
|
106
|
+
if page.respond_to? :should
|
107
|
+
page.should have_content(text)
|
108
|
+
else
|
109
|
+
assert page.has_content?(text)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
114
|
+
regexp = Regexp.new(regexp)
|
115
|
+
|
116
|
+
if page.respond_to? :should
|
117
|
+
page.should have_xpath('//*', :text => regexp)
|
118
|
+
else
|
119
|
+
assert page.has_xpath?('//*', :text => regexp)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
124
|
+
if page.respond_to? :should
|
125
|
+
page.should have_no_content(text)
|
126
|
+
else
|
127
|
+
assert page.has_no_content?(text)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
132
|
+
regexp = Regexp.new(regexp)
|
133
|
+
|
134
|
+
if page.respond_to? :should
|
135
|
+
page.should have_no_xpath('//*', :text => regexp)
|
136
|
+
else
|
137
|
+
assert page.has_no_xpath?('//*', :text => regexp)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
|
142
|
+
with_scope(parent) do
|
143
|
+
field = find_field(field)
|
144
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
145
|
+
if field_value.respond_to? :should
|
146
|
+
field_value.should =~ /#{value}/
|
147
|
+
else
|
148
|
+
assert_match(/#{value}/, field_value)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
|
154
|
+
with_scope(parent) do
|
155
|
+
field = find_field(field)
|
156
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
157
|
+
if field_value.respond_to? :should_not
|
158
|
+
field_value.should_not =~ /#{value}/
|
159
|
+
else
|
160
|
+
assert_no_match(/#{value}/, field_value)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
|
166
|
+
with_scope(parent) do
|
167
|
+
field_checked = find_field(label)['checked']
|
168
|
+
if field_checked.respond_to? :should
|
169
|
+
field_checked.should be_true
|
170
|
+
else
|
171
|
+
assert field_checked
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
|
177
|
+
with_scope(parent) do
|
178
|
+
field_checked = find_field(label)['checked']
|
179
|
+
if field_checked.respond_to? :should
|
180
|
+
field_checked.should be_false
|
181
|
+
else
|
182
|
+
assert !field_checked
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
188
|
+
current_path = URI.parse(current_url).path
|
189
|
+
if current_path.respond_to? :should
|
190
|
+
current_path.should == path_to(page_name)
|
191
|
+
else
|
192
|
+
assert_equal path_to(page_name), current_path
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
197
|
+
query = URI.parse(current_url).query
|
198
|
+
actual_params = query ? CGI.parse(query) : {}
|
199
|
+
expected_params = {}
|
200
|
+
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
201
|
+
|
202
|
+
if actual_params.respond_to? :should
|
203
|
+
actual_params.should == expected_params
|
204
|
+
else
|
205
|
+
assert_equal expected_params, actual_params
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
Then /^show me the page$/ do
|
210
|
+
save_and_open_page
|
211
|
+
end
|
@@ -0,0 +1,47 @@
|
|
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
|
+
require 'cucumber/rails'
|
8
|
+
|
9
|
+
require 'capybara/rails'
|
10
|
+
|
11
|
+
ActionMailer::Base.delivery_method = :test
|
12
|
+
ActionMailer::Base.perform_deliveries = true
|
13
|
+
ActionMailer::Base.default_url_options[:host] = "test.com"
|
14
|
+
|
15
|
+
Rails.backtrace_cleaner.remove_silencers!
|
16
|
+
|
17
|
+
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
18
|
+
# order to ease the transition to Capybara we set the default here. If you'd
|
19
|
+
# prefer to use XPath just remove this line and adjust any selectors in your
|
20
|
+
# steps to use the XPath syntax.
|
21
|
+
Capybara.default_selector = :css
|
22
|
+
|
23
|
+
# By default, any exception happening in your Rails application will bubble up
|
24
|
+
# to Cucumber so that your scenario will fail. This is a different from how
|
25
|
+
# your application behaves in the production environment, where an error page will
|
26
|
+
# be rendered instead.
|
27
|
+
#
|
28
|
+
# Sometimes we want to override this default behaviour and allow Rails to rescue
|
29
|
+
# exceptions and display an error page (just like when the app is running in production).
|
30
|
+
# Typical scenarios where you want to do this is when you test your error pages.
|
31
|
+
# There are two ways to allow Rails to rescue exceptions:
|
32
|
+
#
|
33
|
+
# 1) Tag your scenario (or feature) with @allow-rescue
|
34
|
+
#
|
35
|
+
# 2) Set the value below to true. Beware that doing this globally is not
|
36
|
+
# recommended as it will mask a lot of errors for you!
|
37
|
+
#
|
38
|
+
ActionController::Base.allow_rescue = false
|
39
|
+
|
40
|
+
# Remove/comment out the lines below if your app doesn't have a database.
|
41
|
+
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
|
42
|
+
begin
|
43
|
+
DatabaseCleaner.strategy = :transaction
|
44
|
+
rescue NameError
|
45
|
+
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,50 @@
|
|
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
|
+
|
14
|
+
# the following are examples using path_to_pickle
|
15
|
+
|
16
|
+
when /^#{capture_model}(?:'s)? page$/ # eg. the forum's page
|
17
|
+
path_to_pickle $1
|
18
|
+
|
19
|
+
when /^#{capture_model}(?:'s)? #{capture_model}(?:'s)? page$/ # eg. the forum's post's page
|
20
|
+
path_to_pickle $1, $2
|
21
|
+
|
22
|
+
when /^#{capture_model}(?:'s)? #{capture_model}'s (.+?) page$/ # eg. the forum's post's comments page
|
23
|
+
path_to_pickle $1, $2, :extra => $3 # or the forum's post's edit page
|
24
|
+
|
25
|
+
when /^#{capture_model}(?:'s)? (.+?) page$/ # eg. the forum's posts page
|
26
|
+
polymorphic_path(model($1), :action => $2) # or the forum's edit page
|
27
|
+
|
28
|
+
when /translations page/
|
29
|
+
interpreter_translations_path
|
30
|
+
|
31
|
+
# Add more mappings here.
|
32
|
+
# Here is an example that pulls values out of the Regexp:
|
33
|
+
#
|
34
|
+
# when /^(.*)'s profile page$/i
|
35
|
+
# user_profile_path(User.find_by_login($1))
|
36
|
+
|
37
|
+
else
|
38
|
+
begin
|
39
|
+
page_name =~ /the (.*) page/
|
40
|
+
path_components = $1.split(/\s+/)
|
41
|
+
self.send(path_components.push('path').join('_').to_sym)
|
42
|
+
rescue Object => e
|
43
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
44
|
+
"Now, go and add a mapping in #{__FILE__}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
World(NavigationHelpers)
|