trendi18n 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/app/models/translation.rb +125 -0
- data/generators/trendi18n/templates/migrations/create_translations.rb +22 -0
- data/generators/trendi18n/trendi18n_generator.rb +8 -0
- data/lib/commands.rb +39 -0
- data/lib/file.rb +8 -0
- data/lib/trendi18n.rb +78 -0
- data/rails/init.rb +5 -0
- data/spec/test_application/README +243 -0
- data/spec/test_application/Rakefile +10 -0
- data/spec/test_application/app/controllers/application_controller.rb +10 -0
- data/spec/test_application/app/controllers/translations_controller.rb +41 -0
- data/spec/test_application/app/views/layouts/application.rhtml +15 -0
- data/spec/test_application/app/views/translations/_form.html.erb +11 -0
- data/spec/test_application/app/views/translations/edit.html.erb +6 -0
- data/spec/test_application/app/views/translations/index.html.erb +32 -0
- data/spec/test_application/app/views/translations/new.html.erb +7 -0
- data/spec/test_application/app/views/translations/show.html.erb +5 -0
- data/spec/test_application/config/boot.rb +110 -0
- data/spec/test_application/config/database.yml +25 -0
- data/spec/test_application/config/environment.rb +44 -0
- data/spec/test_application/config/environments/cucumber.rb +28 -0
- data/spec/test_application/config/environments/development.rb +17 -0
- data/spec/test_application/config/environments/production.rb +28 -0
- data/spec/test_application/config/environments/test.rb +34 -0
- data/spec/test_application/config/initializers/new_rails_defaults.rb +21 -0
- data/spec/test_application/config/initializers/session_store.rb +15 -0
- data/spec/test_application/config/locales/en.yml +5 -0
- data/spec/test_application/config/routes.rb +46 -0
- data/spec/test_application/db/migrate/20091208195455_create_translations.rb +22 -0
- data/spec/test_application/db/schema.rb +31 -0
- data/spec/test_application/db/seeds.rb +7 -0
- data/spec/test_application/features/dynamic_translation.feature +5 -0
- data/spec/test_application/features/managing_translations.feature +62 -0
- data/spec/test_application/features/static_translation.feature +13 -0
- data/spec/test_application/features/step_definitions/translations_steps.rb +12 -0
- data/spec/test_application/features/step_definitions/webrat_steps.rb +189 -0
- data/spec/test_application/features/support/env.rb +47 -0
- data/spec/test_application/features/support/paths.rb +42 -0
- data/spec/test_application/features/support/version_check.rb +31 -0
- data/spec/test_application/lib/tasks/cucumber.rake +46 -0
- data/spec/test_application/lib/tasks/rspec.rake +146 -0
- data/spec/test_application/public/404.html +30 -0
- data/spec/test_application/public/422.html +30 -0
- data/spec/test_application/public/500.html +30 -0
- data/spec/test_application/public/favicon.ico +0 -0
- data/spec/test_application/public/robots.txt +5 -0
- data/spec/test_application/script/about +4 -0
- data/spec/test_application/script/autospec +6 -0
- data/spec/test_application/script/console +3 -0
- data/spec/test_application/script/cucumber +17 -0
- data/spec/test_application/script/dbconsole +3 -0
- data/spec/test_application/script/destroy +3 -0
- data/spec/test_application/script/generate +3 -0
- data/spec/test_application/script/performance/benchmarker +3 -0
- data/spec/test_application/script/performance/profiler +3 -0
- data/spec/test_application/script/plugin +3 -0
- data/spec/test_application/script/runner +3 -0
- data/spec/test_application/script/server +3 -0
- data/spec/test_application/script/spec +10 -0
- data/spec/test_application/spec/backend_spec.rb +158 -0
- data/spec/test_application/spec/models/translation_spec.rb +109 -0
- data/spec/test_application/spec/rcov.opts +3 -0
- data/spec/test_application/spec/spec.opts +4 -0
- data/spec/test_application/spec/spec_helper.rb +54 -0
- metadata +156 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
Given /^I have translated "([^\"]*)" to "([^\"]*)" in "([^\"]*)" locale$/ do |key, translation, locale|
|
2
|
+
Translation.create!(:key => key, :translation => translation, :locale => locale)
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^I have tranlated "([^\"]*)" to "([^\"]*)" with scope "([^\"]*)" in "([^\"]*)" locale$/ do |key, translation, scope, locale|
|
6
|
+
Translation.create!(:key => key, :translation => translation, :locale => locale, :scope => scope)
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
@@ -0,0 +1,189 @@
|
|
1
|
+
# IMPORTANT: This file was generated by Cucumber 0.4.4
|
2
|
+
# Edit at your own peril - it's recommended to regenerate this file
|
3
|
+
# in the future when you upgrade to a newer version of Cucumber.
|
4
|
+
# Consider adding your own code to a new file instead of editing this one.
|
5
|
+
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
7
|
+
|
8
|
+
# Commonly used webrat steps
|
9
|
+
# http://github.com/brynary/webrat
|
10
|
+
|
11
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
12
|
+
visit path_to(page_name)
|
13
|
+
end
|
14
|
+
|
15
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
16
|
+
visit path_to(page_name)
|
17
|
+
end
|
18
|
+
|
19
|
+
When /^(?:|I )press "([^\"]*)"$/ do |button|
|
20
|
+
click_button(button)
|
21
|
+
end
|
22
|
+
|
23
|
+
When /^(?:|I )follow "([^\"]*)"$/ do |link|
|
24
|
+
click_link(link)
|
25
|
+
end
|
26
|
+
|
27
|
+
When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
|
28
|
+
click_link_within(parent, link)
|
29
|
+
end
|
30
|
+
|
31
|
+
When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
|
32
|
+
fill_in(field, :with => value)
|
33
|
+
end
|
34
|
+
|
35
|
+
When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
|
36
|
+
fill_in(field, :with => value)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Use this to fill in an entire form with data from a table. Example:
|
40
|
+
#
|
41
|
+
# When I fill in the following:
|
42
|
+
# | Account Number | 5002 |
|
43
|
+
# | Expiry date | 2009-11-01 |
|
44
|
+
# | Note | Nice guy |
|
45
|
+
# | Wants Email? | |
|
46
|
+
#
|
47
|
+
# TODO: Add support for checkbox, select og option
|
48
|
+
# based on naming conventions.
|
49
|
+
#
|
50
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
51
|
+
fields.rows_hash.each do |name, value|
|
52
|
+
When %{I fill in "#{name}" with "#{value}"}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
|
57
|
+
select(value, :from => field)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
61
|
+
# When I select "December 25, 2008 10:00" as the date and time
|
62
|
+
When /^(?:|I )select "([^\"]*)" as the date and time$/ do |time|
|
63
|
+
select_datetime(time)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Use this step when using multiple datetime_select helpers on a page or
|
67
|
+
# you want to specify which datetime to select. Given the following view:
|
68
|
+
# <%= f.label :preferred %><br />
|
69
|
+
# <%= f.datetime_select :preferred %>
|
70
|
+
# <%= f.label :alternative %><br />
|
71
|
+
# <%= f.datetime_select :alternative %>
|
72
|
+
# The following steps would fill out the form:
|
73
|
+
# When I select "November 23, 2004 11:20" as the "Preferred" date and time
|
74
|
+
# And I select "November 25, 2004 10:30" as the "Alternative" date and time
|
75
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
|
76
|
+
select_datetime(datetime, :from => datetime_label)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Use this step in conjunction with Rail's time_select helper. For example:
|
80
|
+
# When I select "2:20PM" as the time
|
81
|
+
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
82
|
+
# will convert the 2:20PM to 14:20 and then select it.
|
83
|
+
When /^(?:|I )select "([^\"]*)" as the time$/ do |time|
|
84
|
+
select_time(time)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Use this step when using multiple time_select helpers on a page or you want to
|
88
|
+
# specify the name of the time on the form. For example:
|
89
|
+
# When I select "7:30AM" as the "Gym" time
|
90
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
|
91
|
+
select_time(time, :from => time_label)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Use this step in conjunction with Rail's date_select helper. For example:
|
95
|
+
# When I select "February 20, 1981" as the date
|
96
|
+
When /^(?:|I )select "([^\"]*)" as the date$/ do |date|
|
97
|
+
select_date(date)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Use this step when using multiple date_select helpers on one page or
|
101
|
+
# you want to specify the name of the date on the form. For example:
|
102
|
+
# When I select "April 26, 1982" as the "Date of Birth" date
|
103
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
|
104
|
+
select_date(date, :from => date_label)
|
105
|
+
end
|
106
|
+
|
107
|
+
When /^(?:|I )check "([^\"]*)"$/ do |field|
|
108
|
+
check(field)
|
109
|
+
end
|
110
|
+
|
111
|
+
When /^(?:|I )uncheck "([^\"]*)"$/ do |field|
|
112
|
+
uncheck(field)
|
113
|
+
end
|
114
|
+
|
115
|
+
When /^(?:|I )choose "([^\"]*)"$/ do |field|
|
116
|
+
choose(field)
|
117
|
+
end
|
118
|
+
|
119
|
+
When /^(?:|I )attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field|
|
120
|
+
attach_file(field, path)
|
121
|
+
end
|
122
|
+
|
123
|
+
Then /^(?:|I )should see "([^\"]*)"$/ do |text|
|
124
|
+
response.should contain(text)
|
125
|
+
end
|
126
|
+
|
127
|
+
Then /^(?:|I )should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
|
128
|
+
within(selector) do |content|
|
129
|
+
content.should contain(text)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
134
|
+
regexp = Regexp.new(regexp)
|
135
|
+
response.should contain(regexp)
|
136
|
+
end
|
137
|
+
|
138
|
+
Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
|
139
|
+
within(selector) do |content|
|
140
|
+
regexp = Regexp.new(regexp)
|
141
|
+
content.should contain(regexp)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
Then /^(?:|I )should not see "([^\"]*)"$/ do |text|
|
146
|
+
response.should_not contain(text)
|
147
|
+
end
|
148
|
+
|
149
|
+
Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
|
150
|
+
within(selector) do |content|
|
151
|
+
content.should_not contain(text)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
156
|
+
regexp = Regexp.new(regexp)
|
157
|
+
response.should_not contain(regexp)
|
158
|
+
end
|
159
|
+
|
160
|
+
Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
|
161
|
+
within(selector) do |content|
|
162
|
+
regexp = Regexp.new(regexp)
|
163
|
+
content.should_not contain(regexp)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
|
168
|
+
field_labeled(field).value.should =~ /#{value}/
|
169
|
+
end
|
170
|
+
|
171
|
+
Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
|
172
|
+
field_labeled(field).value.should_not =~ /#{value}/
|
173
|
+
end
|
174
|
+
|
175
|
+
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
176
|
+
field_labeled(label).should be_checked
|
177
|
+
end
|
178
|
+
|
179
|
+
Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
|
180
|
+
field_labeled(label).should_not be_checked
|
181
|
+
end
|
182
|
+
|
183
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
184
|
+
URI.parse(current_url).path.should == path_to(page_name)
|
185
|
+
end
|
186
|
+
|
187
|
+
Then /^show me the page$/ do
|
188
|
+
save_and_open_page
|
189
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# IMPORTANT: This file was generated by Cucumber 0.4.4
|
2
|
+
# Edit at your own peril - it's recommended to regenerate this file
|
3
|
+
# in the future when you upgrade to a newer version of Cucumber.
|
4
|
+
# Consider adding your own code to a new file instead of editing this one.
|
5
|
+
|
6
|
+
# Sets up the Rails environment for Cucumber
|
7
|
+
ENV["RAILS_ENV"] ||= "cucumber"
|
8
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
9
|
+
require 'cucumber/rails/world'
|
10
|
+
|
11
|
+
# If you set this to true, each scenario will run in a database transaction.
|
12
|
+
# You can still turn off transactions on a per-scenario basis, simply tagging
|
13
|
+
# a feature or scenario with the @no-txn tag.
|
14
|
+
#
|
15
|
+
# If you set this to false, transactions will be off for all scenarios,
|
16
|
+
# regardless of whether you use @no-txn or not.
|
17
|
+
#
|
18
|
+
# Beware that turning transactions off will leave data in your database
|
19
|
+
# after each scenario, which can lead to hard-to-debug failures in
|
20
|
+
# subsequent scenarios. If you do this, we recommend you create a Before
|
21
|
+
# block that will explicitly put your database in a known state.
|
22
|
+
Cucumber::Rails::World.use_transactional_fixtures = true
|
23
|
+
|
24
|
+
# If you set this to false, any error raised from within your app will bubble
|
25
|
+
# up to your step definition and out to cucumber unless you catch it somewhere
|
26
|
+
# on the way. You can make Rails rescue errors and render error pages on a
|
27
|
+
# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
|
28
|
+
#
|
29
|
+
# If you set this to true, Rails will rescue all errors and render error
|
30
|
+
# pages, more or less in the same way your application would behave in the
|
31
|
+
# default production environment. It's not recommended to do this for all
|
32
|
+
# of your scenarios, as this makes it hard to discover errors in your application.
|
33
|
+
ActionController::Base.allow_rescue = false
|
34
|
+
|
35
|
+
require 'cucumber'
|
36
|
+
# Comment out the next line if you don't want Cucumber Unicode support
|
37
|
+
require 'cucumber/formatter/unicode'
|
38
|
+
require 'cucumber/webrat/element_locator' # Lets you do table.diff!(element_at('#my_table_or_dl_or_ul_or_ol').to_table)
|
39
|
+
require 'cucumber/rails/rspec'
|
40
|
+
|
41
|
+
require 'webrat'
|
42
|
+
require 'webrat/core/matchers'
|
43
|
+
Webrat.configure do |config|
|
44
|
+
config.mode = :rails
|
45
|
+
config.open_error_files = false # Set to true if you want error pages to pop up in the browser
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,42 @@
|
|
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 webrat_steps.rb
|
7
|
+
#
|
8
|
+
def path_to(page_name)
|
9
|
+
case page_name
|
10
|
+
|
11
|
+
when /the home\s?page/
|
12
|
+
'/'
|
13
|
+
when /the list of translations/
|
14
|
+
translations_path
|
15
|
+
|
16
|
+
when /the list of unfinished translations/
|
17
|
+
translations_path :condition => "untranslated"
|
18
|
+
when /the list of finished translations/
|
19
|
+
translations_path :condition => "translated"
|
20
|
+
when /the list of polish translations/
|
21
|
+
translations_path :localization => "pl"
|
22
|
+
when /the new translation form/
|
23
|
+
new_translation_path
|
24
|
+
when /the edit translation form/
|
25
|
+
edit_translation_path
|
26
|
+
when /the translations test page/
|
27
|
+
translation_path :id => 1
|
28
|
+
|
29
|
+
# Add more mappings here.
|
30
|
+
# Here is a more fancy example:
|
31
|
+
#
|
32
|
+
# when /^(.*)'s profile page$/i
|
33
|
+
# user_profile_path(User.find_by_login($1))
|
34
|
+
|
35
|
+
else
|
36
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
37
|
+
"Now, go and add a mapping in #{__FILE__}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
World(NavigationHelpers)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'cucumber/formatter/ansicolor'
|
2
|
+
extend Cucumber::Formatter::ANSIColor
|
3
|
+
if Cucumber::VERSION != '0.4.4'
|
4
|
+
warning = <<-WARNING
|
5
|
+
#{red_cukes(15)}
|
6
|
+
|
7
|
+
#{red_cukes(1)} R O T T E N C U C U M B E R A L E R T #{red_cukes(1)}
|
8
|
+
|
9
|
+
Your #{__FILE__.gsub(/version_check.rb$/, 'env.rb')} file was generated with Cucumber 0.4.4,
|
10
|
+
but you seem to be running Cucumber #{Cucumber::VERSION}. If you're running an older
|
11
|
+
version than #{Cucumber::VERSION}, just upgrade your gem. If you're running a newer
|
12
|
+
version than #{Cucumber::VERSION} you should:
|
13
|
+
|
14
|
+
1) Read http://wiki.github.com/aslakhellesoy/cucumber/upgrading
|
15
|
+
|
16
|
+
2) Regenerate your cucumber environment with the following command:
|
17
|
+
|
18
|
+
ruby script/generate cucumber
|
19
|
+
|
20
|
+
If you get prompted to replace a file, hit 'd' to see the difference.
|
21
|
+
When you're sure you have captured any personal edits, confirm that you
|
22
|
+
want to overwrite #{__FILE__.gsub(/version_check.rb$/, 'env.rb')} by pressing 'y'. Then reapply any
|
23
|
+
personal changes that may have been overwritten, preferably in separate files.
|
24
|
+
|
25
|
+
This message will then self destruct.
|
26
|
+
|
27
|
+
#{red_cukes(15)}
|
28
|
+
WARNING
|
29
|
+
warn(warning)
|
30
|
+
at_exit {warn(warning)}
|
31
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# This file was generated by
|
2
|
+
# Find vendored gem or plugin of cucumber
|
3
|
+
vendored_cucumber_dir = Dir["#{RAILS_ROOT}/vendor/{gems,plugins}/cucumber*"].first
|
4
|
+
$LOAD_PATH.unshift("#{vendored_cucumber_dir}/lib") unless vendored_cucumber_dir.nil?
|
5
|
+
|
6
|
+
unless ARGV.any? {|a| a =~ /^gems/}
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'cucumber/rake/task'
|
10
|
+
|
11
|
+
# Use vendored cucumber binary if possible. If it's not vendored,
|
12
|
+
# Cucumber::Rake::Task will automatically use installed gem's cucumber binary
|
13
|
+
vendored_cucumber_binary = "#{vendored_cucumber_dir}/bin/cucumber" unless vendored_cucumber_dir.nil?
|
14
|
+
ENV['FEATURE'] = "#{RAILS_ROOT}/features"
|
15
|
+
namespace :cucumber do
|
16
|
+
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
|
17
|
+
t.binary = vendored_cucumber_binary
|
18
|
+
t.fork = true # You may get faster startup if you set this to false
|
19
|
+
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
|
20
|
+
end
|
21
|
+
|
22
|
+
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
23
|
+
t.binary = vendored_cucumber_binary
|
24
|
+
t.fork = true # You may get faster startup if you set this to false
|
25
|
+
t.cucumber_opts = "--color --tags @wip:2 --wip --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'Run all features'
|
29
|
+
task :all => [:ok, :wip]
|
30
|
+
end
|
31
|
+
desc 'Alias for cucumber:ok'
|
32
|
+
task :cucumber => 'cucumber:ok'
|
33
|
+
|
34
|
+
task :default => :cucumber
|
35
|
+
|
36
|
+
task :features => :cucumber do
|
37
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
38
|
+
end
|
39
|
+
rescue LoadError
|
40
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
41
|
+
task :cucumber do
|
42
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
|
2
|
+
rspec_gem_dir = nil
|
3
|
+
Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir|
|
4
|
+
rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
|
5
|
+
end
|
6
|
+
rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec')
|
7
|
+
|
8
|
+
if rspec_gem_dir && (test ?d, rspec_plugin_dir)
|
9
|
+
raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n"
|
10
|
+
end
|
11
|
+
|
12
|
+
if rspec_gem_dir
|
13
|
+
$LOAD_PATH.unshift("#{rspec_gem_dir}/lib")
|
14
|
+
elsif File.exist?(rspec_plugin_dir)
|
15
|
+
$LOAD_PATH.unshift("#{rspec_plugin_dir}/lib")
|
16
|
+
end
|
17
|
+
|
18
|
+
# Don't load rspec if running "rake gems:*"
|
19
|
+
unless ARGV.any? {|a| a =~ /^gems/}
|
20
|
+
|
21
|
+
begin
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
rescue MissingSourceFile
|
24
|
+
module Spec
|
25
|
+
module Rake
|
26
|
+
class SpecTask
|
27
|
+
def initialize(name)
|
28
|
+
task name do
|
29
|
+
# if rspec-rails is a configured gem, this will output helpful material and exit ...
|
30
|
+
require File.expand_path(File.join(File.dirname(__FILE__),"..","..","config","environment"))
|
31
|
+
|
32
|
+
# ... otherwise, do this:
|
33
|
+
raise <<-MSG
|
34
|
+
|
35
|
+
#{"*" * 80}
|
36
|
+
* You are trying to run an rspec rake task defined in
|
37
|
+
* #{__FILE__},
|
38
|
+
* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
|
39
|
+
#{"*" * 80}
|
40
|
+
MSG
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Rake.application.instance_variable_get('@tasks').delete('default')
|
49
|
+
|
50
|
+
spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
|
51
|
+
task :noop do
|
52
|
+
end
|
53
|
+
|
54
|
+
task :default => :spec
|
55
|
+
task :stats => "spec:statsetup"
|
56
|
+
|
57
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
58
|
+
Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
|
59
|
+
t.libs << "#{RAILS_ROOT}/spec" << "#{RAILS_ROOT}/lib"
|
60
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
61
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
62
|
+
end
|
63
|
+
|
64
|
+
namespace :spec do
|
65
|
+
desc "Run all specs in spec directory with RCov (excluding plugin specs)"
|
66
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
67
|
+
t.libs << "#{RAILS_ROOT}/spec" << "#{RAILS_ROOT}/lib"
|
68
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
69
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
70
|
+
t.rcov = true
|
71
|
+
t.rcov_opts = lambda do
|
72
|
+
IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
desc "Print Specdoc for all specs (excluding plugin specs)"
|
77
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
78
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
79
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "Print Specdoc for all plugin examples"
|
83
|
+
Spec::Rake::SpecTask.new(:plugin_doc) do |t|
|
84
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
85
|
+
t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*')
|
86
|
+
end
|
87
|
+
|
88
|
+
[:models, :controllers, :views, :helpers, :lib, :integration].each do |sub|
|
89
|
+
desc "Run the code examples in spec/#{sub}"
|
90
|
+
Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
|
91
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
92
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
desc "Run the code examples in vendor/plugins (except RSpec's own)"
|
97
|
+
Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
|
98
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
99
|
+
t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
|
100
|
+
end
|
101
|
+
|
102
|
+
namespace :plugins do
|
103
|
+
desc "Runs the examples for rspec_on_rails"
|
104
|
+
Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
|
105
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
106
|
+
t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb']
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Setup specs for stats
|
111
|
+
task :statsetup do
|
112
|
+
require 'code_statistics'
|
113
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
|
114
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
|
115
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
|
116
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
|
117
|
+
::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
|
118
|
+
::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing')
|
119
|
+
::STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?('spec/integration')
|
120
|
+
::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
|
121
|
+
::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
|
122
|
+
::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
|
123
|
+
::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
|
124
|
+
::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
|
125
|
+
::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
|
126
|
+
::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?('spec/integration')
|
127
|
+
end
|
128
|
+
|
129
|
+
namespace :db do
|
130
|
+
namespace :fixtures do
|
131
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z."
|
132
|
+
task :load => :environment do
|
133
|
+
ActiveRecord::Base.establish_connection(Rails.env)
|
134
|
+
base_dir = File.join(Rails.root, 'spec', 'fixtures')
|
135
|
+
fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
|
136
|
+
|
137
|
+
require 'active_record/fixtures'
|
138
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
|
139
|
+
Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
8
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
9
|
+
<style type="text/css">
|
10
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
11
|
+
div.dialog {
|
12
|
+
width: 25em;
|
13
|
+
padding: 0 4em;
|
14
|
+
margin: 4em auto 0 auto;
|
15
|
+
border: 1px solid #ccc;
|
16
|
+
border-right-color: #999;
|
17
|
+
border-bottom-color: #999;
|
18
|
+
}
|
19
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
20
|
+
</style>
|
21
|
+
</head>
|
22
|
+
|
23
|
+
<body>
|
24
|
+
<!-- This file lives in public/404.html -->
|
25
|
+
<div class="dialog">
|
26
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
27
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
28
|
+
</div>
|
29
|
+
</body>
|
30
|
+
</html>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
8
|
+
<title>The change you wanted was rejected (422)</title>
|
9
|
+
<style type="text/css">
|
10
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
11
|
+
div.dialog {
|
12
|
+
width: 25em;
|
13
|
+
padding: 0 4em;
|
14
|
+
margin: 4em auto 0 auto;
|
15
|
+
border: 1px solid #ccc;
|
16
|
+
border-right-color: #999;
|
17
|
+
border-bottom-color: #999;
|
18
|
+
}
|
19
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
20
|
+
</style>
|
21
|
+
</head>
|
22
|
+
|
23
|
+
<body>
|
24
|
+
<!-- This file lives in public/422.html -->
|
25
|
+
<div class="dialog">
|
26
|
+
<h1>The change you wanted was rejected.</h1>
|
27
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
28
|
+
</div>
|
29
|
+
</body>
|
30
|
+
</html>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
8
|
+
<title>We're sorry, but something went wrong (500)</title>
|
9
|
+
<style type="text/css">
|
10
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
11
|
+
div.dialog {
|
12
|
+
width: 25em;
|
13
|
+
padding: 0 4em;
|
14
|
+
margin: 4em auto 0 auto;
|
15
|
+
border: 1px solid #ccc;
|
16
|
+
border-right-color: #999;
|
17
|
+
border-bottom-color: #999;
|
18
|
+
}
|
19
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
20
|
+
</style>
|
21
|
+
</head>
|
22
|
+
|
23
|
+
<body>
|
24
|
+
<!-- This file lives in public/500.html -->
|
25
|
+
<div class="dialog">
|
26
|
+
<h1>We're sorry, but something went wrong.</h1>
|
27
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
28
|
+
</div>
|
29
|
+
</body>
|
30
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
|
3
|
+
ENV['RSPEC'] = 'true' # allows autotest to discover rspec
|
4
|
+
ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux
|
5
|
+
system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) ||
|
6
|
+
$stderr.puts("Unable to find autotest. Please install ZenTest or fix your PATH")
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
vendored_cucumber_binary = Dir[File.join(File.dirname(__FILE__),
|
4
|
+
'..',
|
5
|
+
'vendor',
|
6
|
+
'{gems,plugins}',
|
7
|
+
'cucumber*',
|
8
|
+
'bin',
|
9
|
+
'cucumber')].first
|
10
|
+
|
11
|
+
if vendored_cucumber_binary
|
12
|
+
load File.expand_path(vendored_cucumber_binary)
|
13
|
+
else
|
14
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
15
|
+
require 'cucumber'
|
16
|
+
load Cucumber::BINARY
|
17
|
+
end
|