cucumber-rails 0.3.2 → 0.4.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +2 -0
- data/History.txt +7 -0
- data/README.rdoc +2 -2
- data/Rakefile +3 -19
- data/cucumber-rails.gemspec +25 -106
- data/dev_tasks/rspec.rake +6 -11
- data/features/rails2.feature +5 -24
- data/features/rails3.feature +82 -56
- data/features/step_definitions/cucumber_rails_steps.rb +3 -25
- data/features/support/env.rb +3 -1
- data/generators/cucumber/cucumber_generator.rb +1 -17
- data/lib/cucumber/rails.rb +29 -0
- data/lib/cucumber/rails/capybara/javascript_emulation.rb +83 -0
- data/lib/cucumber/rails/capybara/select_dates_and_times.rb +43 -0
- data/lib/cucumber/rails/hooks/allow_rescue.rb +8 -0
- data/lib/cucumber/rails/hooks/database_cleaner.rb +25 -0
- data/lib/cucumber/rails/hooks/mail.rb +5 -0
- data/lib/cucumber/rails/rspec.rb +0 -3
- data/lib/cucumber/rails/version.rb +15 -0
- data/lib/cucumber/rails/world.rb +2 -36
- data/lib/cucumber/rails2.rb +16 -0
- data/lib/cucumber/rails2/action_controller.rb +29 -0
- data/lib/cucumber/rails3.rb +16 -0
- data/lib/cucumber/rails3/action_controller.rb +12 -0
- data/lib/cucumber/rails3/application.rb +17 -0
- data/lib/generators/cucumber/feature/feature_generator.rb +1 -1
- data/lib/generators/cucumber/install/install_base.rb +40 -53
- data/lib/generators/cucumber/install/install_generator.rb +10 -22
- data/spec/cucumber/web/tableish_spec.rb +47 -0
- data/spec/generators/cucumber/install/install_base_spec.rb +0 -9
- data/spec/spec_helper.rb +1 -4
- data/templates/install/step_definitions/capybara_steps.rb.erb +1 -1
- data/templates/install/step_definitions/web_steps_da.rb.erb +1 -1
- data/templates/install/step_definitions/web_steps_no.rb.erb +1 -1
- data/templates/install/step_definitions/web_steps_pt-BR.rb.erb +2 -1
- data/templates/install/support/_rails_each_run.rb.erb +16 -15
- data/templates/install/support/_rails_prefork.rb.erb +1 -12
- data/templates/install/support/capybara.rb +0 -4
- metadata +137 -30
- data/lib/cucumber/rails/action_controller.rb +0 -65
- data/lib/cucumber/rails/active_record.rb +0 -34
- data/lib/cucumber/rails/capybara_javascript_emulation.rb +0 -72
- data/lib/cucumber/rails/test_unit.rb +0 -7
- data/spec/spec.opts +0 -2
@@ -1,65 +0,0 @@
|
|
1
|
-
if Rails.version.to_f >= 3.0
|
2
|
-
module ActionController #:nodoc:
|
3
|
-
module AllowRescueException
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
include ActiveSupport::Rescuable
|
6
|
-
|
7
|
-
private
|
8
|
-
def process_action(*args)
|
9
|
-
if ActionController::Base.allow_rescue
|
10
|
-
super
|
11
|
-
else
|
12
|
-
begin
|
13
|
-
super
|
14
|
-
rescue Exception => exception
|
15
|
-
raise(exception)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
ActionController::Base.class_eval do
|
23
|
-
cattr_accessor :allow_rescue
|
24
|
-
include ActionController::AllowRescueException
|
25
|
-
end
|
26
|
-
else
|
27
|
-
ActionController::Base.class_eval do
|
28
|
-
cattr_accessor :allow_rescue
|
29
|
-
|
30
|
-
alias_method :rescue_action_without_bypass, :rescue_action
|
31
|
-
|
32
|
-
def rescue_action(exception)
|
33
|
-
if ActionController::Base.allow_rescue
|
34
|
-
rescue_action_without_bypass(exception)
|
35
|
-
else
|
36
|
-
raise exception
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
begin
|
43
|
-
ActionController::Failsafe.class_eval do
|
44
|
-
alias_method :failsafe_response_without_bypass, :failsafe_response
|
45
|
-
|
46
|
-
def failsafe_response(exception)
|
47
|
-
raise exception
|
48
|
-
end
|
49
|
-
end
|
50
|
-
rescue NameError # Failsafe was introduced in Rails 2.3.2
|
51
|
-
ActionController::Dispatcher.class_eval do
|
52
|
-
def self.failsafe_response(output, status, exception = nil)
|
53
|
-
raise exception
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
Before('@allow-rescue') do
|
59
|
-
@__orig_allow_rescue = ActionController::Base.allow_rescue
|
60
|
-
ActionController::Base.allow_rescue = true
|
61
|
-
end
|
62
|
-
|
63
|
-
After('@allow-rescue') do
|
64
|
-
ActionController::Base.allow_rescue = @__orig_allow_rescue
|
65
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
if defined?(ActiveRecord::Base)
|
2
|
-
Before do
|
3
|
-
$__cucumber_global_use_txn = !!Cucumber::Rails::World.use_transactional_fixtures if $__cucumber_global_use_txn.nil?
|
4
|
-
end
|
5
|
-
|
6
|
-
Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
7
|
-
Cucumber::Rails::World.use_transactional_fixtures = $__cucumber_global_use_txn
|
8
|
-
end
|
9
|
-
|
10
|
-
Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
11
|
-
Cucumber::Rails::World.use_transactional_fixtures = false
|
12
|
-
end
|
13
|
-
|
14
|
-
Before do
|
15
|
-
if Cucumber::Rails::World.use_transactional_fixtures
|
16
|
-
run_callbacks :setup if respond_to?(:run_callbacks)
|
17
|
-
else
|
18
|
-
DatabaseCleaner.start
|
19
|
-
end
|
20
|
-
ActionMailer::Base.deliveries = [] if defined?(ActionMailer::Base)
|
21
|
-
end
|
22
|
-
|
23
|
-
After do
|
24
|
-
if Cucumber::Rails::World.use_transactional_fixtures
|
25
|
-
run_callbacks :teardown if respond_to?(:run_callbacks)
|
26
|
-
else
|
27
|
-
DatabaseCleaner.clean
|
28
|
-
end
|
29
|
-
end
|
30
|
-
else
|
31
|
-
module Cucumber::Rails
|
32
|
-
def World.fixture_table_names; []; end # Workaround for projects that don't use ActiveRecord
|
33
|
-
end
|
34
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Rails
|
3
|
-
module CapybaraJavascriptEmulation
|
4
|
-
def self.included(base)
|
5
|
-
base.class_eval do
|
6
|
-
alias_method :click_without_javascript_emulation, :click
|
7
|
-
alias_method :click, :click_with_javascript_emulation
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def click_with_javascript_emulation
|
12
|
-
if link_with_non_get_http_method?
|
13
|
-
Capybara::Driver::RackTest::Form.new(driver, js_form(self[:href], emulated_method)).submit(self)
|
14
|
-
else
|
15
|
-
click_without_javascript_emulation
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def js_form(action, emulated_method, method = 'POST')
|
22
|
-
js_form = node.document.create_element('form')
|
23
|
-
js_form['action'] = action
|
24
|
-
js_form['method'] = method
|
25
|
-
|
26
|
-
if emulated_method and emulated_method.downcase != method.downcase
|
27
|
-
input = node.document.create_element('input')
|
28
|
-
input['type'] = 'hidden'
|
29
|
-
input['name'] = '_method'
|
30
|
-
input['value'] = emulated_method
|
31
|
-
js_form.add_child(input)
|
32
|
-
end
|
33
|
-
|
34
|
-
js_form
|
35
|
-
end
|
36
|
-
|
37
|
-
def link_with_non_get_http_method?
|
38
|
-
if ::Rails.version.to_f >= 3.0
|
39
|
-
tag_name == 'a' && node['data-method'] && node['data-method'] =~ /(?:delete|put|post)/
|
40
|
-
else
|
41
|
-
tag_name == 'a' && node['onclick'] && node['onclick'] =~ /var f = document\.createElement\('form'\); f\.style\.display = 'none';/
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def emulated_method
|
46
|
-
if ::Rails.version.to_f >= 3.0
|
47
|
-
node['data-method']
|
48
|
-
else
|
49
|
-
node['onclick'][/m\.setAttribute\('value', '([^']*)'\)/, 1]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
class Capybara::Driver::RackTest::Node
|
57
|
-
include Cucumber::Rails::CapybaraJavascriptEmulation
|
58
|
-
end
|
59
|
-
|
60
|
-
Before('~@no-js-emulation') do
|
61
|
-
# Enable javascript emulation
|
62
|
-
Capybara::Driver::RackTest::Node.class_eval do
|
63
|
-
alias_method :click, :click_with_javascript_emulation
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
Before('@no-js-emulation') do
|
68
|
-
# Disable javascript emulation
|
69
|
-
Capybara::Driver::RackTest::Node.class_eval do
|
70
|
-
alias_method :click, :click_without_javascript_emulation
|
71
|
-
end
|
72
|
-
end
|
data/spec/spec.opts
DELETED