Skip to content

Commit 59793dc

Browse files
committed
Update Capybara integration to support 0.4 and 1.0
- this adds capybara matchers to view and helper specs - Closes #302.
1 parent 5dcdc62 commit 59793dc

8 files changed

+30
-4
lines changed

features/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Add documentation to the generated spec
88
* Use any_instance to avoid stubbing finders
99
* Use real objects instead of mock_model
10+
* Update capybara integration to work with capy 0.4 and 1.0.0.beta
1011

1112
### 2.6.0.rc2 / 2011-04-18
1213

gemfiles/base.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ def self.extended(host)
1919
gem "aruba", "~> 0.3.6"
2020
gem "growl", "1.0.3"
2121
gem "ZenTest", "~> 4.4.2"
22-
gem "webrat", "0.7.2"
22+
23+
# gem "webrat", "0.7.2"
24+
# gem "capybara", "~> 0.4"
25+
# gem "capybara", "1.0.0.beta1"
2326

2427
unless ENV['CI']
2528
gem "rcov", "0.9.9"

lib/rspec/rails/browser_simulators.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
begin
2+
require 'capybara/rspec'
3+
rescue LoadError
4+
end
5+
16
begin
27
require 'capybara/rails'
38
rescue LoadError

lib/rspec/rails/example/controller_example_group.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ module ControllerExampleGroup
9090
end
9191

9292
capybara do
93-
include Capybara
93+
begin
94+
include Capybara::DSL
95+
include Capybara::RSpecMatchers
96+
rescue
97+
include Capybara
98+
end
9499
end
95100

96101
module ClassMethods

lib/rspec/rails/example/helper_example_group.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ module HelperExampleGroup
3636
include Webrat::Matchers
3737
end
3838

39+
capybara do
40+
include Capybara::RSpecMatchers if defined?(Capybara::RSpecMatchers)
41+
end
42+
3943
module ClassMethods
4044
def determine_default_helper_class(ignore)
4145
describes

lib/rspec/rails/example/mailer_example_group.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ module MailerExampleGroup
1111
end
1212

1313
capybara do
14-
include Capybara
14+
begin
15+
include Capybara::RSpecMatchers
16+
rescue
17+
include Capybara
18+
end
1519
end
1620

1721
included do

lib/rspec/rails/example/request_example_group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def last_response
3737
end
3838

3939
capybara do
40-
include Capybara
40+
include Capybara unless defined?(Capybara::DSL)
4141
end
4242

4343
include RSpec::Rails::Matchers::RedirectTo

lib/rspec/rails/example/view_example_group.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ module ViewExampleGroup
2929
include Webrat::Matchers
3030
end
3131

32+
capybara do
33+
include Capybara::RSpecMatchers if defined?(Capybara::RSpecMatchers)
34+
end
35+
3236
module ClassMethods
3337
def _default_helper
3438
base = metadata[:example_group][:description].split('/').first

0 commit comments

Comments
 (0)