Created
April 16, 2011 17:05
-
-
Save mattheworiordan/923298 to your computer and use it in GitHub Desktop.
gemfile for RSpec
This file contains 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 "the signup process", :type => :request do | |
it "signs me in", :js => true, :driver => :selenium do | |
visit calculator_path | |
within("#calculator") do | |
click_button '1' | |
end | |
end | |
end |
This file contains 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 "the calculator", :type => :request do | |
it "has buttons added by Javascript", :js => true do | |
visit calculator_path | |
within("#calculator") do | |
click_button '1' | |
end | |
end | |
it "has a calculator object in the global space", :driver => :selenium do | |
visit calculator_path | |
within("#calculator") do | |
click_button '1' | |
end | |
page.evaluate_script('$("#calculator").data("engine").sum(1,2)').should eql(3) | |
end | |
end |
This file contains 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 "the calculator", :type => :request do | |
it "has buttons added by Javascript", :js => true, :driver => :selenium do | |
Capybara.current_driver = :selenium # Force Capybara to switch drivers at this point | |
visit calculator_path | |
within("#calculator") do | |
click_button '1' | |
end | |
end | |
end |
This file contains 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
@javascript | |
Scenario: Use the Javascript based functions | |
Given I am on the calculator page | |
When I press "2" | |
And I press "5" | |
And I press "+" | |
Then I should see "25" within ".value" | |
When I press "√" | |
Then I should see "5" within ".value" | |
@selenium | |
Scenario: Test a JQuery UI dialog | |
Given I am on the calculator page | |
When I press "2" | |
And I press "+" | |
Then I should see "2" within ".value" | |
When I press "C" | |
Then I should see "Are you sure you want to clear the calculator and history?" within "#dialog-confirm" | |
When I press "Yes" | |
Then I should see "0" within ".value" | |
And I should not see "2" within ".history" |
This file contains 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 'selenium/client' | |
Capybara.javascript_driver = :akephalos |
This file contains 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
gem 'spork', '~> 0.9.0.rc' |
This file contains 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
gem 'akephalos' | |
gem 'selenium' | |
gem 'selenium-client' |
This file contains 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 JavascriptTestController < ApplicationController | |
layout 'javascript_test' | |
before_filter :ensure_suitable_environment | |
def render_test | |
render :layout => 'javascript_test', :template => "../../spec/javascript/#{params[:script].gsub(/[^A-Za-z0-9_-]/,'')}_spec.js", :content_type => 'text/html' | |
end | |
private | |
def ensure_suitable_environment | |
render :status => :forbidden unless ['development','test'].include?(Rails.env) | |
end | |
end |
This file contains 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
page.evaluate_script('$("#calculator").data("engine").sum(1,2)').should eql(3) |
This file contains 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_cmd = "rspec --tty --drb --colour --format nested" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment