Permalink
Browse files

Test runner with both selenium and poltergeist

  • Loading branch information...
1 parent a01866f commit 7ddecb87e34af632202da1cbd5fc8c5b1c3d88df @jfirebaugh committed Dec 11, 2012
Showing with 104 additions and 85 deletions.
  1. +2 −0 Gemfile
  2. +101 −85 spec/runner_spec.rb
  3. +1 −0 spec/spec_helper.rb
View
2 Gemfile
@@ -1,2 +1,4 @@
source 'https://rubygems.org'
gemspec
+
+gem 'poltergeist'
View
186 spec/runner_spec.rb
@@ -26,99 +26,115 @@ def initialize(io)
end
end
- describe "#run" do
- let(:suite) do
- {'event' => 'suite',
- 'type' => 'suite',
- 'data' => {
- 'title' => 'failure',
- 'fullTitle' => 'failure',
- 'path' => 'failing_spec.js'
- }}
+ shared_examples_for "Konacha::Runner" do |driver|
+ before do
+ Konacha.configure do |config|
+ config.driver = driver
+ end
end
- let(:suite_end) do
- {'event' => 'suite end',
- 'type' => 'suite',
- 'data' => {
- 'title' => 'failure',
- 'fullTitle' => 'failure',
- 'path' => 'failing_spec.js'
- }}
- end
+ describe "#run" do
+ let(:suite) do
+ {'event' => 'suite',
+ 'type' => 'suite',
+ 'data' => {
+ 'title' => 'failure',
+ 'fullTitle' => 'failure',
+ 'path' => 'failing_spec.js'
+ }}
+ end
- let(:test) do
- {'event' => 'test',
- 'type' => 'test',
- 'data' => {
- 'title' => 'fails',
- 'fullTitle' => 'failure fails',
- 'parentFullTitle' => 'failure',
- 'path' => 'failing_spec.js'}}
- end
+ let(:suite_end) do
+ {'event' => 'suite end',
+ 'type' => 'suite',
+ 'data' => {
+ 'title' => 'failure',
+ 'fullTitle' => 'failure',
+ 'path' => 'failing_spec.js'
+ }}
+ end
- let(:failure) do
- {'event' => 'fail',
- 'type' => 'test',
- 'data' => {
- 'title' => 'fails',
- 'fullTitle' => 'failure fails',
- 'parentFullTitle' => 'failure',
- 'status' => 'failed',
- 'path' => 'failing_spec.js',
- 'error' => {'message' => 'expected 4 to equal 5', 'name' => 'AssertionError'}}}
- end
+ let(:test) do
+ {'event' => 'test',
+ 'type' => 'test',
+ 'data' => {
+ 'title' => 'fails',
+ 'fullTitle' => 'failure fails',
+ 'parentFullTitle' => 'failure',
+ 'path' => 'failing_spec.js'}}
+ end
- let(:error) do
- {'event' => 'fail',
- 'type' => 'test',
- 'data' => {
- 'title' => 'errors',
- 'fullTitle' => 'failure errors',
- 'parentFullTitle' => 'failure',
- 'status' => 'failed',
- 'path' => 'failing_spec.js',
- 'error' => {'message' => 'this one errors out', 'name' => 'Error'}}}
- end
+ let(:failure) do
+ {'event' => 'fail',
+ 'type' => 'test',
+ 'data' => {
+ 'title' => 'fails',
+ 'fullTitle' => 'failure fails',
+ 'parentFullTitle' => 'failure',
+ 'status' => 'failed',
+ 'path' => 'failing_spec.js',
+ 'error' => {'message' => 'expected 4 to equal 5', 'name' => 'AssertionError'}}}
+ end
- let(:pass) do
- {'event' => 'pass',
- 'type' => 'test',
- 'data' => {
- 'title' => 'is empty',
- 'fullTitle' => 'the body#konacha element is empty',
- 'parentFullTitle' => 'the body#konacha element',
- 'status' => 'passed',
- 'path' => 'body_spec.js.coffee',
- 'duration' => anything}}
- end
+ let(:error) do
+ {'event' => 'fail',
+ 'type' => 'test',
+ 'data' => {
+ 'title' => 'errors',
+ 'fullTitle' => 'failure errors',
+ 'parentFullTitle' => 'failure',
+ 'status' => 'failed',
+ 'path' => 'failing_spec.js',
+ 'error' => {'message' => 'this one errors out', 'name' => 'Error'}}}
+ end
- let(:pending) do
- {'event' => 'pending',
- 'type' => 'test',
- 'data' => {
- 'title' => 'is pending',
- 'fullTitle' => 'pending test is pending',
- 'parentFullTitle' => 'pending test',
- 'path' => 'pending_spec.js',
- 'status' => 'pending'}}
- end
+ let(:pass) do
+ {'event' => 'pass',
+ 'type' => 'test',
+ 'data' => {
+ 'title' => 'is empty',
+ 'fullTitle' => 'the body#konacha element is empty',
+ 'parentFullTitle' => 'the body#konacha element',
+ 'status' => 'passed',
+ 'path' => 'body_spec.js.coffee',
+ 'duration' => anything}}
+ end
+
+ let(:pending) do
+ {'event' => 'pending',
+ 'type' => 'test',
+ 'data' => {
+ 'title' => 'is pending',
+ 'fullTitle' => 'pending test is pending',
+ 'parentFullTitle' => 'pending test',
+ 'path' => 'pending_spec.js',
+ 'status' => 'pending'}}
+ end
+
+ let(:start) { {'event' => 'start', 'testCount' => kind_of(Integer), 'data' => {} } }
+ let(:end_event) { {'event' => 'end', 'data' => {} } }
- let(:start) { {'event' => 'start', 'testCount' => kind_of(Integer), 'data' => {} } }
- let(:end_event) { {'event' => 'end', 'data' => {} } }
-
- it "passes along the right events" do
- subject.reporter.should_receive(:process_mocha_event).with(start)
- subject.reporter.should_receive(:process_mocha_event).with(suite)
- subject.reporter.should_receive(:process_mocha_event).with(suite_end)
- subject.reporter.should_receive(:process_mocha_event).with(test)
- subject.reporter.should_receive(:process_mocha_event).with(failure)
- subject.reporter.should_receive(:process_mocha_event).with(error)
- subject.reporter.should_receive(:process_mocha_event).with(pass)
- subject.reporter.should_receive(:process_mocha_event).with(pending)
- subject.reporter.should_receive(:process_mocha_event).with(end_event)
- subject.reporter.should_receive(:process_mocha_event).any_number_of_times
- subject.run
+ it "passes along the right events" do
+ subject.reporter.should_receive(:process_mocha_event).with(start)
+ subject.reporter.should_receive(:process_mocha_event).with(suite)
+ subject.reporter.should_receive(:process_mocha_event).with(suite_end)
+ subject.reporter.should_receive(:process_mocha_event).with(test)
+ subject.reporter.should_receive(:process_mocha_event).with(failure)
+ subject.reporter.should_receive(:process_mocha_event).with(error)
+ subject.reporter.should_receive(:process_mocha_event).with(pass)
+ subject.reporter.should_receive(:process_mocha_event).with(pending)
+ subject.reporter.should_receive(:process_mocha_event).with(end_event)
+ subject.reporter.should_receive(:process_mocha_event).any_number_of_times
+ subject.run
+ end
end
end
+
+ describe "with selenium" do
+ it_behaves_like "Konacha::Runner", :selenium
+ end
+
+ describe "with poltergeist" do
+ it_behaves_like "Konacha::Runner", :poltergeist
+ end
end
View
1 spec/spec_helper.rb
@@ -13,6 +13,7 @@
require "capybara/rails"
require "capybara/firebug"
+require "capybara/poltergeist"
Capybara.configure do |config|
config.default_selector = :css

0 comments on commit 7ddecb8

Please sign in to comment.