Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add the RSpec matchers tests

  • Loading branch information...
commit e3b3db4df3e8c3f69271f668b5f6d8beeca6b421 1 parent 90122ae
@ferrous26 ferrous26 authored
Showing with 91 additions and 0 deletions.
  1. +91 −0 test/integration/rspec/expectations/test_ax_elements.rb
View
91 test/integration/rspec/expectations/test_ax_elements.rb
@@ -0,0 +1,91 @@
+require 'rspec/expectations/ax_elements'
+
+class TestRSpecMatchers < MiniTest::Unit::TestCase
+
+ def app
+ @@app ||= AX::Application.new PID
+ end
+
+ def test_have_child_should_failure_message
+ m = Accessibility::HasChildMatcher.new(:window, {}) {}
+ e = app.main_window.slider
+
+ m.matches? e
+ assert_equal "expected #{e.inspect} to have child Window[✔]",
+ m.failure_message_for_should
+ end
+
+ def test_have_child_should_not_failure_message
+ m = Accessibility::HasChildMatcher.new(:window, {})
+ e = app.window
+
+ m.does_not_match? app
+ assert_equal "expected #{app.inspect} to NOT have child #{e.inspect}",
+ m.failure_message_for_should_not
+ end
+
+ def test_have_child_description
+ m = Accessibility::HasChildMatcher.new(:window,{}) {}
+ assert_equal 'should have a child that matches Window[✔]', m.description
+ end
+
+ def test_have_descendent_should_failure_message
+ m = Accessibility::HasDescendentMatcher.new(:button, {}) {}
+ q = Accessibility::Qualifier.new(:Button,{}) {}
+ e = app.main_window.slider
+
+ m.matches? e
+ assert_equal "expected #{e.inspect} to have descendent Button[✔]",
+ m.failure_message_for_should
+ end
+
+ def test_have_descendent_should_not_failure_message
+ m = Accessibility::HasDescendentMatcher.new(:window,{})
+ e = app.window
+
+ m.does_not_match? app
+ assert_equal "expected #{app.inspect} to NOT have descendent #{e.inspect}",
+ m.failure_message_for_should_not
+ end
+
+ def test_have_descendent_description
+ m = Accessibility::HasDescendentMatcher.new(:button,{})
+ assert_equal 'should have a descendent matching Button', m.description
+ end
+
+end
+
+
+begin
+ raise LoadError
+ require 'rspec-core'
+ RSpec::Core::Runner.disable_autorun!
+ RSpec.configuration.mock_with :nothing
+
+ class TestRSpecMatchers
+
+ def test_have_child
+ describe Accessibility::HasChildMatcher do
+ it "should find"
+ it "shoud fail to find"
+ it "should not find"
+ it "should fail to not find"
+ end
+ RSpec.world.example_groups.map { |x| x.run }
+ end
+
+ def test_have_descendent
+ describe Accessibility::HasDescendentMatcher do
+ it "should find"
+ it "shoud fail to find"
+ it "should not find"
+ it "should fail to not find"
+ end
+ RSpec.world.example_groups.map { |x| x.run }
+ end
+
+ end
+
+rescue LoadError
+ $stderr.puts 'You do not have rspec installed, skipping RSpec integration tests'
+end
Please sign in to comment.
Something went wrong with that request. Please try again.