Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jnicklas/capybara
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed Apr 2, 2011
2 parents 3e5d923 + 7fb5a1d commit 123cd3b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/capybara/rspec/features.rb
Expand Up @@ -9,10 +9,11 @@ def self.included(base)
end
end

def feature(*args, &block)
def self.feature(*args, &block)
options = if args.last.is_a?(Hash) then args.pop else {} end
options[:capybara_feature] = true
options[:type] = :request
options[:caller] ||= caller
args.push(options)

describe(*args, &block)
Expand Down
20 changes: 13 additions & 7 deletions lib/capybara/session.rb
Expand Up @@ -27,15 +27,21 @@ module Capybara
#
class Session
NODE_METHODS = [
:all, :first, :attach_file, :text, :check, :choose, :click_link_or_button, :click_button, :click_link,
:field_labeled, :fill_in, :find, :find_button, :find_by_id, :find_field, :find_link, :has_content?, :has_css?,
:has_no_content?, :has_no_css?, :has_no_xpath?, :has_xpath?, :save_page, :save_and_open_page, :select, :uncheck,
:has_link?, :has_no_link?, :has_button?,
:has_no_button?, :has_field?, :has_no_field?, :has_checked_field?, :has_unchecked_field?, :has_no_table?, :has_table?,
:unselect, :has_select?, :has_no_select?, :has_selector?, :has_no_selector?, :click_on, :has_no_checked_field?, :has_no_unchecked_field?
:all, :first, :attach_file, :text, :check, :choose,
:click_link_or_button, :click_button, :click_link, :field_labeled,
:fill_in, :find, :find_button, :find_by_id, :find_field, :find_link,
:has_content?, :has_css?, :has_no_content?, :has_no_css?, :has_no_xpath?,
:has_xpath?, :select, :uncheck, :has_link?, :has_no_link?, :has_button?,
:has_no_button?, :has_field?, :has_no_field?, :has_checked_field?,
:has_unchecked_field?, :has_no_table?, :has_table?, :unselect,
:has_select?, :has_no_select?, :has_selector?, :has_no_selector?,
:click_on, :has_no_checked_field?, :has_no_unchecked_field?
]
SESSION_METHODS = [
:body, :html, :current_url, :current_host, :evaluate_script, :source, :visit, :wait_until, :within, :within_fieldset, :within_table, :within_frame, :within_window, :current_path
:body, :html, :current_url, :current_host, :evaluate_script, :source,
:visit, :wait_until, :within, :within_fieldset, :within_table,
:within_frame, :within_window, :current_path, :save_page,
:save_and_open_page
]
DSL_METHODS = NODE_METHODS + SESSION_METHODS

Expand Down
12 changes: 12 additions & 0 deletions spec/rspec/features_spec.rb
Expand Up @@ -3,6 +3,10 @@

Capybara.app = TestApp

RSpec.configuration.before(:each, :example_group => {:file_path => __FILE__}) do
@in_filtered_hook = true
end

feature "Capybara's feature DSL" do
background do
@in_background = true
Expand All @@ -24,6 +28,14 @@
scenario "runs background" do
@in_background.should be_true
end

scenario "runs hooks filtered by file path" do
@in_filtered_hook.should be_true
end

scenario "doesn't pollute the Object namespace" do
Object.new.respond_to?(:feature, true).should be_false
end
end

feature "Capybara's feature DSL with driver", :driver => :culerity do
Expand Down

0 comments on commit 123cd3b

Please sign in to comment.