bryan-ash-wx-nobbie 0.0.3.4 → 0.0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/features/acceptance_test.feature +8 -0
- data/features/step_definitions/acceptance_test_steps.rb +11 -0
- data/features/support/env.rb +12 -0
- data/lib/nobbie/wx/acceptance_test.rb +1 -1
- data/lib/nobbie/wx/{launcher.rb → application_launcher.rb} +7 -19
- data/lib/nobbie/wx/operations.rb +4 -4
- data/spec/application_launcher_spec.rb +13 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +6 -0
- data/test/all_tests.rb +1 -1
- data/test/suite/{app.rb → example_app.rb} +3 -3
- data/test/suite/test_launcher.rb +3 -13
- metadata +11 -3
@@ -0,0 +1,8 @@
|
|
1
|
+
In order to test drive a WxRuby application
|
2
|
+
As a developer
|
3
|
+
I want Nobbie to provide acceptance test access to the application
|
4
|
+
|
5
|
+
Scenario: An application is provided
|
6
|
+
Given a test application exists
|
7
|
+
When a Nobbie acceptance test is started on the application
|
8
|
+
Then the application is running
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Given /^a test application exists$/ do
|
2
|
+
@app = ExampleApp.new
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^a Nobbie acceptance test is started on the application$/ do
|
6
|
+
Nobbie::Wx::ApplicationLauncher.new(@app).start
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^the application is running$/ do
|
10
|
+
@app.is_main_loop_running.should be_true
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../../lib"
|
4
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../../test/suite"
|
5
|
+
|
6
|
+
require 'example_app'
|
7
|
+
|
8
|
+
require 'nobbie/wx/application_launcher'
|
9
|
+
|
10
|
+
After do
|
11
|
+
@app.exit_main_loop unless @app.nil?
|
12
|
+
end
|
@@ -14,6 +14,6 @@ Test::Unit.run = false
|
|
14
14
|
#todo: how the hell does this work(/not work as expected) on OSX?
|
15
15
|
at_exit do
|
16
16
|
unless $! || Test::Unit.run?
|
17
|
-
exit = Nobbie::Wx::ApplicationLauncher.new.with_application { Thread.pass }
|
17
|
+
exit = Nobbie::Wx::ApplicationLauncher.new(APPLICATION_UNDER_TEST).with_application { Thread.pass }
|
18
18
|
end
|
19
19
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'wx'
|
4
|
+
|
1
5
|
module Nobbie
|
2
6
|
module Wx
|
3
7
|
|
@@ -14,18 +18,10 @@ module Nobbie
|
|
14
18
|
class ApplicationLauncher #:nodoc:
|
15
19
|
|
16
20
|
AUT_NOT_WX_APP = "APPLICATION_UNDER_TEST must be an instance of a Wx::App"
|
17
|
-
AUT_NOT_DEFINED = "APPLICATION_UNDER_TEST must be set to be an instance of the application you wish to test"
|
18
21
|
|
19
|
-
def initialize
|
20
|
-
|
21
|
-
|
22
|
-
unless app.is_a?(Wxruby2::App)
|
23
|
-
handle(AUT_NOT_WX_APP)
|
24
|
-
end
|
25
|
-
rescue NameError => e
|
26
|
-
handle(AUT_NOT_DEFINED)
|
27
|
-
end
|
28
|
-
@app = app
|
22
|
+
def initialize(application_under_test)
|
23
|
+
@app = application_under_test
|
24
|
+
Kernel.raise(AUT_NOT_WX_APP) unless @app.is_a?(Wxruby2::App)
|
29
25
|
end
|
30
26
|
|
31
27
|
def with_application
|
@@ -61,14 +57,6 @@ module Nobbie
|
|
61
57
|
#@app.exit_main_loop
|
62
58
|
#@app = nil
|
63
59
|
end
|
64
|
-
|
65
|
-
def handle(message)
|
66
|
-
Kernel.raise message
|
67
|
-
end
|
68
|
-
|
69
|
-
def get_application
|
70
|
-
APPLICATION_UNDER_TEST
|
71
|
-
end
|
72
60
|
end
|
73
61
|
|
74
62
|
end
|
data/lib/nobbie/wx/operations.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'nobbie/wx/platform'
|
2
2
|
require 'nobbie/wx/command_factory'
|
3
|
-
require 'nobbie/wx/
|
3
|
+
require 'nobbie/wx/application_launcher'
|
4
4
|
|
5
5
|
impl = File.dirname(__FILE__) + File::SEPARATOR + 'impl'
|
6
6
|
Dir.glob("#{impl}/**/*.rb") {|f| require "#{f}" }
|
@@ -61,7 +61,7 @@ module Nobbie
|
|
61
61
|
end
|
62
62
|
|
63
63
|
private
|
64
|
-
|
64
|
+
|
65
65
|
def coerce_path(path)
|
66
66
|
return path if path.respond_to?(:find_component)
|
67
67
|
|
@@ -74,12 +74,12 @@ module Nobbie
|
|
74
74
|
|
75
75
|
Kernel.raise("Unable to coerce path: #{path}")
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
#todo: pull up
|
79
79
|
def execute(command)
|
80
80
|
Command::Executor.new.execute(command)
|
81
81
|
end
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
end
|
85
85
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
3
|
+
require 'nobbie/wx/application_launcher'
|
4
|
+
|
5
|
+
describe Nobbie::Wx::ApplicationLauncher do
|
6
|
+
|
7
|
+
it "raises an exception if initialized with something other than a Wx::App" do
|
8
|
+
lambda {
|
9
|
+
Nobbie::Wx::ApplicationLauncher.new("this is not a Wx::App")
|
10
|
+
}.should raise_error(RuntimeError, /.*be a.*Wx::App.*/)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
data/test/all_tests.rb
CHANGED
@@ -135,10 +135,10 @@ class TestFrame < Frame
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
-
class
|
138
|
+
class ExampleApp < App
|
139
139
|
def on_init
|
140
|
-
TestFrame.new(nil, :title => 'test', :size => [1024, 768])
|
140
|
+
TestFrame.new(nil, :title => 'test', :size => [1024, 768])
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
|
144
|
+
ExampleApp.new.main_loop if __FILE__ == $0
|
data/test/suite/test_launcher.rb
CHANGED
@@ -1,22 +1,12 @@
|
|
1
1
|
class TestLauncher < Test::Unit::TestCase
|
2
|
-
|
3
|
-
def test_application_under_test_is_not_defined
|
4
|
-
begin
|
5
|
-
Nobbie::Wx::ApplicationLauncher.module_eval('def get_application; raise NameError.new; end;')
|
6
|
-
Nobbie::Wx::ApplicationLauncher.new
|
7
|
-
fail
|
8
|
-
rescue RuntimeError => e
|
9
|
-
assert_equal Nobbie::Wx::ApplicationLauncher::AUT_NOT_DEFINED, e.message
|
10
|
-
end
|
11
|
-
end
|
12
2
|
|
13
3
|
def test_application_under_test_is_not_a_wx_app
|
14
4
|
begin
|
15
|
-
Nobbie::Wx::ApplicationLauncher.
|
16
|
-
Nobbie::Wx::ApplicationLauncher.new
|
5
|
+
Nobbie::Wx::ApplicationLauncher.new("this is not a Wx::App")
|
17
6
|
fail
|
18
7
|
rescue RuntimeError => e
|
19
|
-
assert_equal Nobbie::Wx::ApplicationLauncher::AUT_NOT_WX_APP, e.message
|
8
|
+
assert_equal Nobbie::Wx::ApplicationLauncher::AUT_NOT_WX_APP, e.message
|
20
9
|
end
|
21
10
|
end
|
11
|
+
|
22
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bryan-ash-wx-nobbie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.3.
|
4
|
+
version: 0.0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Alton
|
@@ -43,11 +43,11 @@ files:
|
|
43
43
|
- KNOWN_ISSUES
|
44
44
|
- README.txt
|
45
45
|
- lib/nobbie/wx/acceptance_test.rb
|
46
|
+
- lib/nobbie/wx/application_launcher.rb
|
46
47
|
- lib/nobbie/wx/command.rb
|
47
48
|
- lib/nobbie/wx/command_executor.rb
|
48
49
|
- lib/nobbie/wx/command_factory.rb
|
49
50
|
- lib/nobbie/wx/driven.rb
|
50
|
-
- lib/nobbie/wx/launcher.rb
|
51
51
|
- lib/nobbie/wx/operations.rb
|
52
52
|
- lib/nobbie/wx/platform.rb
|
53
53
|
- lib/nobbie/wx/command/choose.rb
|
@@ -62,8 +62,16 @@ files:
|
|
62
62
|
- lib/nobbie/wx/impl/element/element_path_builder.rb
|
63
63
|
- lib/nobbie/wx/impl/operation/choosable.rb
|
64
64
|
- lib/nobbie/wx/impl/operation/select.rb
|
65
|
+
- features/step_definitions
|
66
|
+
- features/support
|
67
|
+
- features/acceptance_test.feature
|
68
|
+
- features/step_definitions/acceptance_test_steps.rb
|
69
|
+
- features/support/env.rb
|
70
|
+
- spec/application_launcher_spec.rb
|
71
|
+
- spec/spec.opts
|
72
|
+
- spec/spec_helper.rb
|
65
73
|
- test/all_tests.rb
|
66
|
-
- test/suite/
|
74
|
+
- test/suite/example_app.rb
|
67
75
|
- test/suite/nobbie_test_case.rb
|
68
76
|
- test/suite/test_choose.rb
|
69
77
|
- test/suite/test_click.rb
|