Skip to content

Commit

Permalink
Moved shared specs into lib directory
Browse files Browse the repository at this point in the history
This way, implementations of other drivers can
use the specs to verify that they are working
correctly.
  • Loading branch information
jnicklas committed Apr 9, 2010
1 parent 14e0824 commit cf1aa4d
Show file tree
Hide file tree
Showing 50 changed files with 42 additions and 59 deletions.
6 changes: 5 additions & 1 deletion spec/drivers_spec.rb → lib/capybara/spec/driver.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
require File.expand_path('spec_helper', File.dirname(__FILE__))
require 'capybara/spec/test_app'

Dir[File.dirname(__FILE__)+'/driver/*'].each { |group|
require group
}

shared_examples_for 'driver' do

Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 5 additions & 1 deletion spec/session_spec.rb → lib/capybara/spec/session.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require File.expand_path('spec_helper', File.dirname(__FILE__))
require 'capybara/spec/test_app'
require 'nokogiri'

Dir[File.dirname(__FILE__)+'/session/*'].each { |group|
require group
}

shared_examples_for "session" do
def extract_results(session)
YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.text
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions lib/capybara/spec/session/headers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
shared_examples_for "session with headers support" do
describe '#response_headers' do
it "should return response headers" do
@session.visit('/with_simple_html')
@session.response_headers['Content-Type'].should == 'text/html'
end
end
end

shared_examples_for "session without headers support" do
describe "#response_headers" do
before{ @session.visit('/with_simple_html') }
it "should raise an error" do
running {
@session.response_headers
}.should raise_error(Capybara::NotSupportedByDriverError)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
require File.expand_path('spec_helper', File.dirname(__FILE__))

require 'nokogiri'

shared_examples_for "session with javascript support" do
describe 'all JS specs' do
before do
Expand Down Expand Up @@ -195,3 +191,14 @@

end
end

shared_examples_for "session without javascript support" do
describe "#evaluate_script" do
before{ @session.visit('/with_simple_html') }
it "should raise an error" do
running {
@session.evaluate_script('3 + 3')
}.should raise_error(Capybara::NotSupportedByDriverError)
end
end
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 0 additions & 13 deletions spec/session_with_headers_support_spec.rb

This file was deleted.

15 changes: 0 additions & 15 deletions spec/session_without_headers_support_spec.rb

This file was deleted.

15 changes: 0 additions & 15 deletions spec/session_without_javascript_support_spec.rb

This file was deleted.

12 changes: 2 additions & 10 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,8 @@
require 'spec'
require 'spec/autorun'
require 'capybara'
require 'test_app'
require 'drivers_spec'
require 'session_spec'
Dir[File.dirname(__FILE__)+'/dsl/*'].each { |group|
require group
}
require 'session_with_javascript_support_spec'
require 'session_without_javascript_support_spec'
require 'session_with_headers_support_spec'
require 'session_without_headers_support_spec'
require 'capybara/spec/driver'
require 'capybara/spec/session'

alias :running :lambda

Expand Down

0 comments on commit cf1aa4d

Please sign in to comment.