muck-raker 0.3.18 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/.gitignore +2 -1
  2. data/MIT-LICENSE +1 -1
  3. data/README.rdoc +3 -7
  4. data/Rakefile +2 -4
  5. data/VERSION +1 -1
  6. data/config/initializers/muck_raker.rb +1 -1
  7. data/lib/muck-raker.rb +2 -0
  8. data/lib/muck-raker/config.rb +22 -0
  9. data/lib/muck-raker/engine.rb +12 -0
  10. data/lib/tasks/muck_raker.rake +152 -0
  11. data/muck-raker.gemspec +207 -191
  12. data/test/rails_test/app/controllers/application_controller.rb +21 -0
  13. data/test/rails_test/app/controllers/default_controller.rb +7 -0
  14. data/test/rails_test/app/helpers/application_helper.rb +3 -0
  15. data/test/rails_test/app/models/comment.rb +3 -0
  16. data/test/rails_test/app/models/profile.rb +3 -0
  17. data/test/rails_test/app/models/user.rb +9 -0
  18. data/test/rails_test/app/models/user_session.rb +2 -0
  19. data/test/rails_test/config/application.rb +42 -0
  20. data/test/rails_test/config/boot.rb +13 -0
  21. data/test/rails_test/config/environment.rb +5 -0
  22. data/test/rails_test/config/environments/development.rb +26 -0
  23. data/test/rails_test/config/environments/production.rb +49 -0
  24. data/test/rails_test/config/environments/test.rb +35 -0
  25. data/test/rails_test/config/initializers/backtrace_silencers.rb +7 -0
  26. data/test/{rails_root → rails_test}/config/initializers/inflections.rb +2 -2
  27. data/test/{rails_root → rails_test}/config/initializers/mime_types.rb +0 -0
  28. data/test/rails_test/config/initializers/muck_raker.rb +13 -0
  29. data/test/rails_test/config/initializers/secret_token.rb +7 -0
  30. data/test/rails_test/config/initializers/session_store.rb +8 -0
  31. data/test/rails_test/config/routes.rb +5 -0
  32. data/test/{rails_root → rails_test}/db/migrate/20090320174818_create_muck_permissions_and_roles.rb +0 -0
  33. data/test/{rails_root → rails_test}/db/migrate/20090402033319_add_muck_activities.rb +0 -0
  34. data/test/{rails_root → rails_test}/db/migrate/20090402234137_create_languages.rb +0 -0
  35. data/test/{rails_root → rails_test}/db/migrate/20090426041056_create_countries.rb +0 -0
  36. data/test/{rails_root → rails_test}/db/migrate/20090426041103_create_states.rb +0 -0
  37. data/test/{rails_root → rails_test}/db/migrate/20090602041838_create_users.rb +0 -0
  38. data/test/{rails_root → rails_test}/db/migrate/20090602191243_create_muck_raker.rb +0 -0
  39. data/test/{rails_root → rails_test}/db/migrate/20090613173314_create_comments.rb +0 -0
  40. data/test/{rails_root → rails_test}/db/migrate/20090619211125_create_tag_clouds.rb +0 -0
  41. data/test/{rails_root → rails_test}/db/migrate/20090623181458_add_grain_size_to_entries.rb +0 -0
  42. data/test/{rails_root → rails_test}/db/migrate/20090623193525_add_grain_size_to_tag_clouds.rb +0 -0
  43. data/test/{rails_root → rails_test}/db/migrate/20090703175825_denormalize_entries_subjects.rb +0 -0
  44. data/test/{rails_root → rails_test}/db/migrate/20090704220055_create_slugs.rb +0 -0
  45. data/test/{rails_root → rails_test}/db/migrate/20090704220120_acts_as_taggable_on_migration.rb +0 -0
  46. data/test/{rails_root → rails_test}/db/migrate/20090716035935_change_tag_cloud_grain_sizes.rb +0 -0
  47. data/test/{rails_root → rails_test}/db/migrate/20090717173900_add_contributor_to_feeds.rb +0 -0
  48. data/test/{rails_root → rails_test}/db/migrate/20090717175825_normalize_entries_subjects.rb +0 -0
  49. data/test/{rails_root → rails_test}/db/migrate/20090721043213_change_services_title_to_name.rb +0 -0
  50. data/test/{rails_root → rails_test}/db/migrate/20090721054927_remove_services_not_null_from_feeds.rb +0 -0
  51. data/test/{rails_root → rails_test}/db/migrate/20090723050510_create_feed_parents.rb +0 -0
  52. data/test/{rails_root → rails_test}/db/migrate/20090728165716_add_etag_to_feeds.rb +0 -0
  53. data/test/{rails_root → rails_test}/db/migrate/20090730044139_add_comment_cache.rb +0 -0
  54. data/test/{rails_root → rails_test}/db/migrate/20090730045848_add_comment_cache_to_entries.rb +0 -0
  55. data/test/{rails_root → rails_test}/db/migrate/20090730154102_allow_null_user.rb +0 -0
  56. data/test/{rails_root → rails_test}/db/migrate/20090803185323_create_shares.rb +0 -0
  57. data/test/{rails_root → rails_test}/db/migrate/20090804184247_add_comment_count_to_shares.rb +0 -0
  58. data/test/{rails_root → rails_test}/db/migrate/20090804211240_add_entry_id_to_shares.rb +0 -0
  59. data/test/{rails_root → rails_test}/db/migrate/20090804231857_add_shares_uri_index.rb +0 -0
  60. data/test/{rails_root → rails_test}/db/migrate/20090818204527_add_activity_indexes.rb +0 -0
  61. data/test/{rails_root → rails_test}/db/migrate/20090819030523_add_attachable_to_activities.rb +0 -0
  62. data/test/{rails_root → rails_test}/db/migrate/20090826220530_change_services_sequence_to_sort.rb +0 -0
  63. data/test/{rails_root → rails_test}/db/migrate/20090826225652_create_identity_feeds.rb +0 -0
  64. data/test/{rails_root → rails_test}/db/migrate/20090827005105_add_identity_fields_to_services.rb +0 -0
  65. data/test/{rails_root → rails_test}/db/migrate/20090827015308_create_service_categories.rb +0 -0
  66. data/test/{rails_root → rails_test}/db/migrate/20090827221502_add_prompt_and_template_to_services.rb +0 -0
  67. data/test/{rails_root → rails_test}/db/migrate/20090915041650_aggregations_to_polymorphic.rb +0 -0
  68. data/test/{rails_root → rails_test}/db/migrate/20090922174200_update_oai_endpoints.rb +0 -0
  69. data/test/{rails_root → rails_test}/db/migrate/20090922231552_add_dates_to_oai_endpoints.rb +0 -0
  70. data/test/{rails_root → rails_test}/db/migrate/20090923150807_rename_name_in_aggregation.rb +0 -0
  71. data/test/{rails_root → rails_test}/db/migrate/20090924200750_add_uri_data_template_to_services.rb +0 -0
  72. data/test/{rails_root → rails_test}/db/migrate/20091006183742_add_feed_count_to_aggregation.rb +0 -0
  73. data/test/{rails_root → rails_test}/db/migrate/20091022150615_add_uri_key_to_services.rb +0 -0
  74. data/test/rails_test/features/step_definitions/comment_steps.rb +11 -0
  75. data/test/rails_test/features/step_definitions/common_steps.rb +93 -0
  76. data/test/rails_test/features/step_definitions/web_steps.rb +219 -0
  77. data/test/rails_test/features/step_definitions/webrat_steps.rb +128 -0
  78. data/test/rails_test/features/support/custom_env.rb +19 -0
  79. data/test/rails_test/features/support/env.rb +58 -0
  80. data/test/rails_test/features/support/paths.rb +33 -0
  81. data/test/rails_test/public/dispatch.rb +10 -0
  82. data/test/rails_test/spec/spec_helper.rb +5 -0
  83. metadata +151 -117
  84. data/install.rb +0 -1
  85. data/lib/muck_raker.rb +0 -0
  86. data/lib/muck_raker/tasks.rb +0 -167
  87. data/rails/init.rb +0 -2
  88. data/tasks/muck_raker_tasks.rake +0 -1
  89. data/test/rails_root/config/boot.rb +0 -109
  90. data/test/rails_root/config/environment.rb +0 -20
  91. data/test/rails_root/config/environments/development.rb +0 -21
  92. data/test/rails_root/config/environments/production.rb +0 -1
  93. data/test/rails_root/config/environments/test.rb +0 -24
  94. data/test/rails_root/config/initializers/requires.rb +0 -13
  95. data/test/rails_root/config/initializers/session_store.rb +0 -8
  96. data/test/rails_root/config/routes.rb +0 -3
  97. data/test/rails_root/script/create_project.rb +0 -52
  98. data/uninstall.rb +0 -1
@@ -0,0 +1,219 @@
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 'cgi'
10
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
11
+
12
+ module WithinHelpers
13
+ def with_scope(locator)
14
+ locator ? within(locator) { yield } : yield
15
+ end
16
+ end
17
+ World(WithinHelpers)
18
+
19
+ Given /^(?:|I )am on (.+)$/ do |page_name|
20
+ visit path_to(page_name)
21
+ end
22
+
23
+ When /^(?:|I )go to (.+)$/ do |page_name|
24
+ visit path_to(page_name)
25
+ end
26
+
27
+ When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
28
+ with_scope(selector) do
29
+ click_button(button)
30
+ end
31
+ end
32
+
33
+ When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
34
+ with_scope(selector) do
35
+ click_link(link)
36
+ end
37
+ end
38
+
39
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
40
+ with_scope(selector) do
41
+ fill_in(field, :with => value)
42
+ end
43
+ end
44
+
45
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
46
+ with_scope(selector) do
47
+ fill_in(field, :with => value)
48
+ end
49
+ end
50
+
51
+ # Use this to fill in an entire form with data from a table. Example:
52
+ #
53
+ # When I fill in the following:
54
+ # | Account Number | 5002 |
55
+ # | Expiry date | 2009-11-01 |
56
+ # | Note | Nice guy |
57
+ # | Wants Email? | |
58
+ #
59
+ # TODO: Add support for checkbox, select og option
60
+ # based on naming conventions.
61
+ #
62
+ When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
63
+ with_scope(selector) do
64
+ fields.rows_hash.each do |name, value|
65
+ When %{I fill in "#{name}" with "#{value}"}
66
+ end
67
+ end
68
+ end
69
+
70
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
71
+ with_scope(selector) do
72
+ select(value, :from => field)
73
+ end
74
+ end
75
+
76
+ When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
77
+ with_scope(selector) do
78
+ check(field)
79
+ end
80
+ end
81
+
82
+ When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
83
+ with_scope(selector) do
84
+ uncheck(field)
85
+ end
86
+ end
87
+
88
+ When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
89
+ with_scope(selector) do
90
+ choose(field)
91
+ end
92
+ end
93
+
94
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
95
+ with_scope(selector) do
96
+ attach_file(field, path)
97
+ end
98
+ end
99
+
100
+ Then /^(?:|I )should see JSON:$/ do |expected_json|
101
+ require 'json'
102
+ expected = JSON.pretty_generate(JSON.parse(expected_json))
103
+ actual = JSON.pretty_generate(JSON.parse(response.body))
104
+ expected.should == actual
105
+ end
106
+
107
+ Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
108
+ with_scope(selector) do
109
+ if page.respond_to? :should
110
+ page.should have_content(text)
111
+ else
112
+ assert page.has_content?(text)
113
+ end
114
+ end
115
+ end
116
+
117
+ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
118
+ regexp = Regexp.new(regexp)
119
+ with_scope(selector) do
120
+ if page.respond_to? :should
121
+ page.should have_xpath('//*', :text => regexp)
122
+ else
123
+ assert page.has_xpath?('//*', :text => regexp)
124
+ end
125
+ end
126
+ end
127
+
128
+ Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
129
+ with_scope(selector) do
130
+ if page.respond_to? :should
131
+ page.should have_no_content(text)
132
+ else
133
+ assert page.has_no_content?(text)
134
+ end
135
+ end
136
+ end
137
+
138
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
139
+ regexp = Regexp.new(regexp)
140
+ with_scope(selector) do
141
+ if page.respond_to? :should
142
+ page.should have_no_xpath('//*', :text => regexp)
143
+ else
144
+ assert page.has_no_xpath?('//*', :text => regexp)
145
+ end
146
+ end
147
+ end
148
+
149
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
150
+ with_scope(selector) do
151
+ field = find_field(field)
152
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
153
+ if field_value.respond_to? :should
154
+ field_value.should =~ /#{value}/
155
+ else
156
+ assert_match(/#{value}/, field_value)
157
+ end
158
+ end
159
+ end
160
+
161
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
162
+ with_scope(selector) do
163
+ field = find_field(field)
164
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
165
+ if field_value.respond_to? :should_not
166
+ field_value.should_not =~ /#{value}/
167
+ else
168
+ assert_no_match(/#{value}/, field_value)
169
+ end
170
+ end
171
+ end
172
+
173
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
174
+ with_scope(selector) do
175
+ field_checked = find_field(label)['checked']
176
+ if field_checked.respond_to? :should
177
+ field_checked.should be_true
178
+ else
179
+ assert field_checked
180
+ end
181
+ end
182
+ end
183
+
184
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
185
+ with_scope(selector) do
186
+ field_checked = find_field(label)['checked']
187
+ if field_checked.respond_to? :should
188
+ field_checked.should be_false
189
+ else
190
+ assert !field_checked
191
+ end
192
+ end
193
+ end
194
+
195
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
196
+ current_path = URI.parse(current_url).path
197
+ if current_path.respond_to? :should
198
+ current_path.should == path_to(page_name)
199
+ else
200
+ assert_equal path_to(page_name), current_path
201
+ end
202
+ end
203
+
204
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
205
+ query = URI.parse(current_url).query
206
+ actual_params = query ? CGI.parse(query) : {}
207
+ expected_params = {}
208
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
209
+
210
+ if actual_params.respond_to? :should
211
+ actual_params.should == expected_params
212
+ else
213
+ assert_equal expected_params, actual_params
214
+ end
215
+ end
216
+
217
+ Then /^show me the page$/ do
218
+ save_and_open_page
219
+ end
@@ -0,0 +1,128 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
2
+
3
+ # Commonly used webrat steps
4
+ # http://github.com/brynary/webrat
5
+
6
+ Given /^I am on (.+)$/ do |page_name|
7
+ visit path_to(page_name)
8
+ end
9
+
10
+ When /^I go to (.+)$/ do |page_name|
11
+ visit path_to(page_name)
12
+ end
13
+
14
+ When /^I press "([^\"]*)"$/ do |button|
15
+ click_button(button)
16
+ end
17
+
18
+ When /^I follow "([^\"]*)"$/ do |link|
19
+ click_link(link)
20
+ end
21
+
22
+ When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
23
+ fill_in(field, :with => value)
24
+ end
25
+
26
+ When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
27
+ select(value, :from => field)
28
+ end
29
+
30
+ # Use this step in conjunction with Rail's datetime_select helper. For example:
31
+ # When I select "December 25, 2008 10:00" as the date and time
32
+ When /^I select "([^\"]*)" as the date and time$/ do |time|
33
+ select_datetime(time)
34
+ end
35
+
36
+ # Use this step when using multiple datetime_select helpers on a page or
37
+ # you want to specify which datetime to select. Given the following view:
38
+ # <%= f.label :preferred %><br />
39
+ # <%= f.datetime_select :preferred %>
40
+ # <%= f.label :alternative %><br />
41
+ # <%= f.datetime_select :alternative %>
42
+ # The following steps would fill out the form:
43
+ # When I select "November 23, 2004 11:20" as the "Preferred" date and time
44
+ # And I select "November 25, 2004 10:30" as the "Alternative" date and time
45
+ When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
46
+ select_datetime(datetime, :from => datetime_label)
47
+ end
48
+
49
+ # Use this step in conjunction with Rail's time_select helper. For example:
50
+ # When I select "2:20PM" as the time
51
+ # Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
52
+ # will convert the 2:20PM to 14:20 and then select it.
53
+ When /^I select "([^\"]*)" as the time$/ do |time|
54
+ select_time(time)
55
+ end
56
+
57
+ # Use this step when using multiple time_select helpers on a page or you want to
58
+ # specify the name of the time on the form. For example:
59
+ # When I select "7:30AM" as the "Gym" time
60
+ When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
61
+ select_time(time, :from => time_label)
62
+ end
63
+
64
+ # Use this step in conjunction with Rail's date_select helper. For example:
65
+ # When I select "February 20, 1981" as the date
66
+ When /^I select "([^\"]*)" as the date$/ do |date|
67
+ select_date(date)
68
+ end
69
+
70
+ # Use this step when using multiple date_select helpers on one page or
71
+ # you want to specify the name of the date on the form. For example:
72
+ # When I select "April 26, 1982" as the "Date of Birth" date
73
+ When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
74
+ select_date(date, :from => date_label)
75
+ end
76
+
77
+ When /^I check "([^\"]*)"$/ do |field|
78
+ check(field)
79
+ end
80
+
81
+ When /^I uncheck "([^\"]*)"$/ do |field|
82
+ uncheck(field)
83
+ end
84
+
85
+ When /^I choose "([^\"]*)"$/ do |field|
86
+ choose(field)
87
+ end
88
+
89
+ When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field|
90
+ attach_file(field, path)
91
+ end
92
+
93
+ Then /^I should see "([^\"]*)"$/ do |text|
94
+ response.should contain(text)
95
+ end
96
+
97
+ Then /^I should see \/([^\/]*)\/$/ do |regexp|
98
+ regexp = Regexp.new(regexp)
99
+ response.should contain(regexp)
100
+ end
101
+
102
+ Then /^I should not see "([^\"]*)"$/ do |text|
103
+ response.should_not contain(text)
104
+ end
105
+
106
+ Then /^I should not see \/([^\/]*)\/$/ do |regexp|
107
+ response.should_not contain(text)
108
+ end
109
+
110
+ Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
111
+ field_labeled(field).value.should =~ /#{value}/
112
+ end
113
+
114
+ Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
115
+ field_labeled(field).value.should_not =~ /#{value}/
116
+ end
117
+
118
+ Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
119
+ field_labeled(label).should be_checked
120
+ end
121
+
122
+ Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
123
+ field_labeled(label).should_not be_checked
124
+ end
125
+
126
+ Then /^I should be on (.+)$/ do |page_name|
127
+ URI.parse(current_url).path.should == path_to(page_name)
128
+ end
@@ -0,0 +1,19 @@
1
+ require 'capybara/rails'
2
+ require 'capybara/cucumber'
3
+
4
+ Capybara.default_driver = :selenium
5
+ Capybara.app_host = "http://localhost:8888"
6
+ Capybara.default_wait_time = 10
7
+
8
+ require "selenium-webdriver"
9
+ Selenium::WebDriver::Firefox::Binary.path = '/Applications/Firefox.app/Contents/MacOS/firefox-bin'
10
+
11
+ require 'factory_girl'
12
+ require 'muck_test_helper'
13
+
14
+ Before do
15
+ # Create admin user:
16
+ Rake::Task[ 'muck:users:create_admin' ].execute
17
+
18
+ visit "/logout"
19
+ end
@@ -0,0 +1,58 @@
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"] ||= "test"
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 'capybara/rails'
17
+ require 'capybara/cucumber'
18
+ require 'capybara/session'
19
+ require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
20
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
21
+ # order to ease the transition to Capybara we set the default here. If you'd
22
+ # prefer to use XPath just remove this line and adjust any selectors in your
23
+ # steps to use the XPath syntax.
24
+ Capybara.default_selector = :css
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
+ # How to clean your database when transactions are turned off. See
51
+ # http://github.com/bmabey/database_cleaner for more info.
52
+ if defined?(ActiveRecord::Base)
53
+ begin
54
+ require 'database_cleaner'
55
+ DatabaseCleaner.strategy = :truncation
56
+ rescue LoadError => ignore_if_database_cleaner_not_present
57
+ end
58
+ end
@@ -0,0 +1,33 @@
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
+ # Add more mappings here.
15
+ # Here is an example that pulls values out of the Regexp:
16
+ #
17
+ # when /^(.*)'s profile page$/i
18
+ # user_profile_path(User.find_by_login($1))
19
+
20
+ else
21
+ begin
22
+ page_name =~ /the (.*) page/
23
+ path_components = $1.split(/\s+/)
24
+ self.send(path_components.push('path').join('_').to_sym)
25
+ rescue Object => e
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
+ end
32
+
33
+ World(NavigationHelpers)