This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "something" do | |
# ... | |
it "works like something" do | |
text_field(:id => "something").set "text" | |
checkbox(:id => "works").clear | |
button(:id => "like").click | |
div(:id => "error").should be_visible | |
end | |
# ... | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SpecHelper | |
def text_field(*args) | |
@browser.text_field(*args) | |
end | |
def checkbox(*args) | |
@browser.checkbox(*args) | |
end | |
def button(*args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SpecHelper | |
def method_missing(name, *args) | |
@browser.respond_to?(name) ? @browser.send(name, *args) : super | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "something" do | |
before :all do | |
@browser = Watir::Browser.new | |
end | |
it "should allow something" do | |
# ... | |
end | |
after :all do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spec::Runner.configure do |config| | |
config.before(:all) {@browser = Watir::Browser.new} | |
config.after(:all) {@browser.close} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spec::Runner.configure do |config| | |
config.include(SpecHelper) | |
config.before(:all) {@browser = Watir::Browser.new} | |
config.after(:all) {@browser.close} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "require_all" | |
require "watir" | |
require "spec" | |
# require some other gem | |
# load all non-spec ruby files | |
spec_dir = File.join(File.dirname(__FILE__), "spec/**/*.rb") | |
filtered_ruby_files = Dir.glob(spec_dir).delete_if do |file| | |
File.basename(file) =~ /.*_spec\.rb$/ | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/../some_dir/some_file' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/^(\s*\d{1}\s*\d{1}\s*\d{1}\s*\d{1}\s*\d{1}\s*\d{1}\s*\d{1}\s*\d{0,1}\s*)?$/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PhoneNumber | |
def initialize number | |
@number = number | |
end | |
def valid? | |
@number =~ /^(\s*\d{1}\s*\d{1}\s*\d{1}\s*\d{1}\s*\d{1}\s*\d{1}\s*\d{1}\s*\d{0,1}\s*)?$/ | |
end | |
end |