bryan-ash-wx-nobbie 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +18 -20
- data/Rakefile +7 -1
- data/features/acceptance_test.feature +88 -17
- data/features/step_definitions/acceptance_test_steps.rb +24 -12
- data/features/support/env.rb +8 -2
- data/lib/nobbie/wx/command/console_reporter.rb +6 -2
- data/lib/nobbie/wx/command/executor.rb +16 -0
- data/lib/nobbie/wx/operations.rb +28 -13
- data/lib/nobbie/wx/platform.rb +40 -25
- data/spec/console_reporter_spec.rb +28 -11
- data/spec/executor_spec.rb +5 -8
- data/spec/platform_spec.rb +24 -0
- data/test/all_tests.rb +1 -2
- data/test/suite/nobbie_test_case.rb +2 -2
- data/test/suite/test_choose.rb +14 -14
- data/test/suite/test_selection.rb +37 -37
- metadata +3 -4
- data/lib/nobbie/wx/impl/operation/choosable.rb +0 -24
- data/lib/nobbie/wx/impl/operation/select.rb +0 -30
data/README.rdoc
CHANGED
@@ -55,17 +55,17 @@ A quick overview with examples:
|
|
55
55
|
|
56
56
|
* Selecting ...
|
57
57
|
|
58
|
-
|
58
|
+
select value, path
|
59
59
|
|
60
60
|
e.g.
|
61
61
|
|
62
|
-
|
62
|
+
select 'Mr', in_('title')
|
63
63
|
|
64
64
|
...or
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
select 'Mr', :in => 'title'
|
67
|
+
select 'Mr', 'title'
|
68
|
+
select 'Mr', :title
|
69
69
|
|
70
70
|
This will find the component named 'title' and select 'Mr'.
|
71
71
|
...this works for anything where you can make a selection from a number of options
|
@@ -73,7 +73,7 @@ A quick overview with examples:
|
|
73
73
|
|
74
74
|
You can get the value of the current selection using:
|
75
75
|
|
76
|
-
|
76
|
+
selected_value path
|
77
77
|
|
78
78
|
|
79
79
|
* Clicking ...
|
@@ -96,34 +96,34 @@ A quick overview with examples:
|
|
96
96
|
|
97
97
|
* Choosing ...
|
98
98
|
|
99
|
-
|
99
|
+
choose path
|
100
100
|
|
101
101
|
e.g.
|
102
102
|
|
103
|
-
|
103
|
+
choose in_('female')
|
104
104
|
|
105
105
|
...or
|
106
106
|
|
107
|
-
|
108
|
-
|
109
|
-
|
107
|
+
choose :in => 'female'
|
108
|
+
choose 'female'
|
109
|
+
choose :female
|
110
110
|
|
111
111
|
This will find the component named 'female' and choose it
|
112
112
|
...this works for anything that has a chosen/non-chosen state.
|
113
113
|
|
114
114
|
You can determine if a component is currently chosen using:
|
115
115
|
|
116
|
-
|
116
|
+
chosen? path
|
117
117
|
|
118
118
|
Hopefully that makes some degree of sense, there are a few other operations available, that should be self
|
119
119
|
explanatory from the documentation.
|
120
120
|
|
121
121
|
* Writing that first test ...
|
122
122
|
|
123
|
-
|
124
|
-
instance of your application for every test run (this would also be very slow
|
125
|
-
will launch your application, run all the tests in your suite and then close
|
126
|
-
anyone has a better solution to this ... please let
|
123
|
+
Nobbie can drive a Wx application from Cucumber or test/unit. However, due to a Wx limitation its not
|
124
|
+
possible to launch a new instance of your application for every test run (this would also be very slow
|
125
|
+
anyway). So, instead Nobbie will launch your application, run all the tests in your suite and then close
|
126
|
+
down the application. (Note: If anyone has a better solution to this ... please let us know).
|
127
127
|
|
128
128
|
In order for this to happen, you must advise Nobbie which application you wish to test by setting the constant
|
129
129
|
APPLICATION_UNDER_TEST to an instance of your application, i.e.:
|
@@ -143,7 +143,5 @@ explanatory from the documentation.
|
|
143
143
|
|
144
144
|
* More examples ...
|
145
145
|
|
146
|
-
Nobbie
|
147
|
-
|
148
|
-
|
149
|
-
|
146
|
+
Nobbie's features are described by a set of Cucumber features which are installed as part of the gem. Take a look at the 'features' directory.
|
147
|
+
There's also a Test::Unit suite to be found in the 'test' directory.
|
data/Rakefile
CHANGED
@@ -18,20 +18,26 @@ Spec::Rake::SpecTask.new do |t|
|
|
18
18
|
t.rcov = true
|
19
19
|
t.rcov_opts << '--text-report'
|
20
20
|
t.rcov_opts << '--exclude features\/,spec\/'
|
21
|
+
t.rcov_opts << '--aggregate coverage\coverage.data'
|
21
22
|
t.rcov_opts << '--sort coverage'
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
26
|
desc "Run Cucumber features"
|
26
27
|
Cucumber::Rake::Task.new do |t|
|
27
|
-
t.cucumber_opts = '--
|
28
|
+
t.cucumber_opts = '--no-source'
|
28
29
|
t.rcov = true
|
29
30
|
t.rcov_opts << '-o coverage'
|
30
31
|
t.rcov_opts << '--text-report'
|
31
32
|
t.rcov_opts << '--exclude features\/,spec\/'
|
33
|
+
t.rcov_opts << '--aggregate coverage\coverage.data'
|
32
34
|
t.rcov_opts << '--sort coverage'
|
33
35
|
end
|
34
36
|
|
37
|
+
directory 'coverage'
|
38
|
+
task :features => 'coverage'
|
39
|
+
task :spec => 'coverage'
|
40
|
+
|
35
41
|
desc "Run unit tests"
|
36
42
|
Rcov::RcovTask.new(:test) do |t|
|
37
43
|
t.pattern = FileList['test/all_tests.rb']
|
@@ -2,28 +2,73 @@ In order to test drive a WxRuby application
|
|
2
2
|
As a developer
|
3
3
|
I want Nobbie to provide acceptance test access to the application
|
4
4
|
|
5
|
-
Scenario: Choosing
|
6
|
-
|
7
|
-
When
|
8
|
-
Then
|
5
|
+
Scenario Outline: Choosing things
|
6
|
+
Given "<control>" is not chosen
|
7
|
+
When I choose "<control>"
|
8
|
+
Then "<control>" is chosen
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
Examples:
|
11
|
+
| control |
|
12
|
+
| check_box |
|
13
|
+
| radio_button |
|
14
14
|
|
15
|
-
Scenario: Type into a text control
|
16
|
-
When I type "123" into "text_ctrl"
|
17
|
-
Then I should see "123" in "text_ctrl"
|
18
15
|
|
19
|
-
Scenario:
|
20
|
-
When I
|
21
|
-
Then I
|
16
|
+
Scenario Outline: Things that can't be chosen
|
17
|
+
When I choose "<control>"
|
18
|
+
Then I expect an exception with the message "cannot: Choose '<control>'"
|
19
|
+
When "<control>" is chosen
|
20
|
+
Then I expect an exception with the message "cannot: Is chosen '<control>'"
|
21
|
+
|
22
|
+
Examples:
|
23
|
+
| control |
|
24
|
+
| button |
|
25
|
+
| combo_box |
|
26
|
+
| text_ctrl |
|
27
|
+
|
28
|
+
|
29
|
+
Scenario Outline: Typing into things
|
30
|
+
When I type "<something>" into "<control>"
|
31
|
+
Then I should see "<something>" in "<control>"
|
32
|
+
|
33
|
+
Examples:
|
34
|
+
| something | control |
|
35
|
+
| 123 | combo_box |
|
36
|
+
| 456 | text_ctrl |
|
37
|
+
|
38
|
+
|
39
|
+
Scenario Outline: Things that can't be typed into
|
40
|
+
When I type "<something>" into "<control>"
|
41
|
+
Then I expect an exception with the message "cannot: Type '<something>' into '<control>'"
|
42
|
+
|
43
|
+
Examples:
|
44
|
+
| something | control |
|
45
|
+
| 123 | button |
|
46
|
+
| 456 | check_box |
|
47
|
+
| 789 | radio_button |
|
48
|
+
| 012 | test_notebook |
|
49
|
+
|
22
50
|
|
23
51
|
Scenario: Click on a button
|
24
52
|
When I click on "button"
|
25
53
|
|
26
|
-
|
54
|
+
|
55
|
+
Scenario: Invalid path format
|
56
|
+
When I use an invalid path
|
57
|
+
Then I expect an exception with the message "Unable to coerce path"
|
58
|
+
|
59
|
+
|
60
|
+
Scenario Outline: Things that can't be clicked
|
61
|
+
When I click on "<control>"
|
62
|
+
Then I expect an exception with the message "cannot: Click on '<control>'"
|
63
|
+
|
64
|
+
Examples:
|
65
|
+
| control |
|
66
|
+
| combo_box |
|
67
|
+
| text_ctrl |
|
68
|
+
| test_notebook |
|
69
|
+
|
70
|
+
|
71
|
+
Scenario Outline: Selecting things
|
27
72
|
Given "<selectable>" includes "<value>"
|
28
73
|
When I select "<value>" on the "<selectable>"
|
29
74
|
Then "<value>" on the "<selectable>" should be selected
|
@@ -33,11 +78,37 @@ I want Nobbie to provide acceptance test access to the application
|
|
33
78
|
| combo_box_with_items | combo_box_item |
|
34
79
|
| list_box_with_items | list_box_item |
|
35
80
|
| test_notebook | click |
|
81
|
+
| &File | &New... |
|
82
|
+
|
83
|
+
|
84
|
+
Scenario Outline: Selecting things that aren't there
|
85
|
+
When I select "<value>" on the "<selectable>"
|
86
|
+
Then I expect an exception with the message "cannot: Select '<value>' in '<selectable>'"
|
87
|
+
|
88
|
+
Examples:
|
89
|
+
| selectable | value |
|
90
|
+
| combo_box_with_items | Ghost |
|
91
|
+
| list_box_with_items | Tooth Fairy |
|
92
|
+
| test_notebook | Easter Bunny |
|
93
|
+
|
94
|
+
|
95
|
+
Scenario Outline: Things that can't be selected
|
96
|
+
Given "<control>" includes "<value>"
|
97
|
+
Then I expect an exception with the message "cannot: Get options '<control>'"
|
98
|
+
When I select "<value>" on the "<control>"
|
99
|
+
Then I expect an exception with the message "cannot: Select '<value>' in '<control>'"
|
100
|
+
When "<value>" on the "<control>" should be selected
|
101
|
+
Then I expect an exception with the message "cannot: Get selected values '<control>'"
|
102
|
+
|
103
|
+
Examples:
|
104
|
+
| value | control |
|
105
|
+
| 123 | button |
|
106
|
+
| 456 | check_box |
|
107
|
+
| 789 | radio_button |
|
108
|
+
|
36
109
|
|
37
110
|
Scenario: Enabled controls
|
38
111
|
Then "text_ctrl" is enabled
|
39
112
|
Then "disabled_text_ctrl" is not enabled
|
40
113
|
|
41
|
-
Scenario: Working with menus
|
42
|
-
When I select "&New..." on the "&File"
|
43
114
|
|
@@ -1,41 +1,50 @@
|
|
1
|
+
def execute_and_catch_exception
|
2
|
+
@raised_exception = nil
|
3
|
+
begin
|
4
|
+
yield
|
5
|
+
rescue StandardError => exception
|
6
|
+
@raised_exception = exception
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
1
10
|
When /^I choose "(.*)"$/ do |item|
|
2
|
-
|
11
|
+
execute_and_catch_exception { choose item }
|
3
12
|
end
|
4
13
|
|
5
14
|
When /^I type "(.*)" into "(.*)"$/ do |value, item|
|
6
|
-
type value, :in => item
|
15
|
+
execute_and_catch_exception { type value, :in => item }
|
7
16
|
end
|
8
17
|
|
9
18
|
When /^I click on "(.*)"$/ do |item|
|
10
|
-
click item
|
19
|
+
execute_and_catch_exception { click item }
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^I use an invalid path$/ do
|
23
|
+
execute_and_catch_exception { click ["Array is not a valid path"] }
|
11
24
|
end
|
12
25
|
|
13
26
|
When /^I select "(.*)" on the "(.*)"$/ do |value, selectable|
|
14
|
-
|
27
|
+
execute_and_catch_exception { select value, :in => selectable }
|
15
28
|
end
|
16
29
|
|
17
30
|
Then /^I should see "(.*)" in "(.*)"$/ do |value, item|
|
18
31
|
text(item).should == value
|
19
32
|
end
|
20
33
|
|
21
|
-
Then /^the application is running$/ do
|
22
|
-
@app.is_main_loop_running.should be_true
|
23
|
-
end
|
24
|
-
|
25
34
|
Then /^"(.*)" is chosen$/ do |item|
|
26
|
-
|
35
|
+
execute_and_catch_exception { chosen?(item).should be_true }
|
27
36
|
end
|
28
37
|
|
29
38
|
Then /^"(.*)" is not chosen$/ do |item|
|
30
|
-
|
39
|
+
chosen?(item).should be_false
|
31
40
|
end
|
32
41
|
|
33
42
|
Then /^"(.*)" on the "(.*)" should be selected$/ do |value, selectable|
|
34
|
-
|
43
|
+
execute_and_catch_exception { selected_value(:in => selectable).should == value }
|
35
44
|
end
|
36
45
|
|
37
46
|
Then /^"(.*)" includes "(.*)"$/ do |selectable, value|
|
38
|
-
|
47
|
+
execute_and_catch_exception { options(:in => selectable).should include(value) }
|
39
48
|
end
|
40
49
|
|
41
50
|
Then /^"(.*)" is enabled$/ do |item|
|
@@ -46,3 +55,6 @@ Then /^"(.*)" is not enabled$/ do |item|
|
|
46
55
|
enabled?(item).should_not be_true
|
47
56
|
end
|
48
57
|
|
58
|
+
Then /^I expect an exception with the message "(.*)"$/ do |message|
|
59
|
+
@raised_exception.to_s.should =~ Regexp.new(message)
|
60
|
+
end
|
data/features/support/env.rb
CHANGED
@@ -2,8 +2,14 @@ require 'rubygems'
|
|
2
2
|
require 'spec'
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
|
5
|
-
require 'nobbie/wx'
|
6
5
|
|
7
6
|
require File.dirname(__FILE__) + '/../../test/suite/example_app'
|
8
7
|
|
9
|
-
|
8
|
+
require 'nobbie/wx'
|
9
|
+
include Nobbie::Wx
|
10
|
+
|
11
|
+
silent_reporter = Command::ConsoleReporter.new(StringIO.new)
|
12
|
+
|
13
|
+
Command::Executor.reporter = silent_reporter
|
14
|
+
|
15
|
+
ApplicationLauncher.new(ExampleApp.new(false)).run
|
@@ -7,12 +7,16 @@ module Nobbie
|
|
7
7
|
|
8
8
|
class ConsoleReporter < Reporter #:nodoc:
|
9
9
|
|
10
|
+
def initialize(output_stream = STDOUT)
|
11
|
+
@output_stream = output_stream
|
12
|
+
end
|
13
|
+
|
10
14
|
def before_executing_command(command)
|
11
|
-
|
15
|
+
@output_stream.puts "\n> #{command.describe}"
|
12
16
|
end
|
13
17
|
|
14
18
|
def after_executing_command(result)
|
15
|
-
|
19
|
+
@output_stream.puts "< #{render(result)}"
|
16
20
|
end
|
17
21
|
|
18
22
|
private
|
@@ -7,6 +7,18 @@ module Nobbie
|
|
7
7
|
|
8
8
|
class Executor #:nodoc:
|
9
9
|
|
10
|
+
def self.execute(command)
|
11
|
+
executor.execute(command)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.executor
|
15
|
+
@executor ||= new
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.reporter= reporter
|
19
|
+
executor.reporter = reporter
|
20
|
+
end
|
21
|
+
|
10
22
|
def initialize(reporter = Reporter.new)
|
11
23
|
@reporter = reporter
|
12
24
|
end
|
@@ -18,6 +30,10 @@ module Nobbie
|
|
18
30
|
result
|
19
31
|
end
|
20
32
|
|
33
|
+
def reporter= reporter
|
34
|
+
@reporter = reporter
|
35
|
+
end
|
36
|
+
|
21
37
|
end
|
22
38
|
|
23
39
|
end
|
data/lib/nobbie/wx/operations.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'nobbie/wx/command_factory'
|
2
2
|
|
3
|
-
|
4
|
-
Dir.glob("#{impl}/**/*.rb") {|f| require "#{f}" }
|
3
|
+
require "nobbie/wx/impl/element/element_path_builder"
|
5
4
|
|
6
5
|
module Nobbie
|
7
6
|
module Wx
|
8
7
|
|
9
8
|
module Operations
|
10
9
|
|
11
|
-
EXECUTOR = Command::Executor.new
|
12
|
-
|
13
10
|
# Types text into the component specified in the path.
|
14
11
|
# Supported components: TextCtrl, ComboBox
|
15
12
|
def type(text, path)
|
@@ -36,16 +33,34 @@ module Nobbie
|
|
36
33
|
execute(command_factory.create_get_component_command(coerce_path(path)))
|
37
34
|
end
|
38
35
|
|
39
|
-
#
|
40
|
-
#
|
41
|
-
def
|
42
|
-
|
36
|
+
# Selects the given value for the component specified in the path.
|
37
|
+
# Supported components: Notebook, Menu, ComboBox, ListBox, Choice
|
38
|
+
def select(value, path)
|
39
|
+
execute(command_factory.create_select_command(coerce_path(path), value))
|
40
|
+
end
|
41
|
+
|
42
|
+
# Retrieves the currently selected value for the component specified in the path.
|
43
|
+
# Supported components: Notebook, ComboBox, ListBox, Choice
|
44
|
+
def selected_value(path)
|
45
|
+
execute(command_factory.create_get_selected_values_command(coerce_path(path)))
|
46
|
+
end
|
47
|
+
|
48
|
+
# Retrieves available options for the component specified in the path.
|
49
|
+
# Supported components: Notebook, ComboBox, ListBox, Choice
|
50
|
+
def options(path)
|
51
|
+
execute(command_factory.create_get_options_command(coerce_path(path)))
|
52
|
+
end
|
53
|
+
|
54
|
+
# Chooses the component specified in the path.
|
55
|
+
# Supported components: RadioButton, CheckBox
|
56
|
+
def choose(path)
|
57
|
+
execute(command_factory.create_choose_command(coerce_path(path)))
|
43
58
|
end
|
44
59
|
|
45
|
-
#
|
46
|
-
#
|
47
|
-
def
|
48
|
-
|
60
|
+
# Determines if the component specified in the path is chosen.
|
61
|
+
# Supported components: RadioButton, CheckBox
|
62
|
+
def chosen?(path)
|
63
|
+
execute(command_factory.create_is_chosen_command(coerce_path(path)))
|
49
64
|
end
|
50
65
|
|
51
66
|
# Determines if the component specified in the path is currently enabled.
|
@@ -68,7 +83,7 @@ module Nobbie
|
|
68
83
|
end
|
69
84
|
|
70
85
|
def execute(command)
|
71
|
-
|
86
|
+
Command::Executor.execute(command)
|
72
87
|
end
|
73
88
|
|
74
89
|
private
|
data/lib/nobbie/wx/platform.rb
CHANGED
@@ -1,31 +1,46 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'wx'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
4
|
+
module Nobbie
|
5
|
+
|
6
|
+
module Wx
|
7
|
+
|
8
|
+
class Platform #:nodoc:
|
9
|
+
|
10
|
+
include Wx
|
11
|
+
|
12
|
+
WINDOWS = 'WXMSW'
|
13
|
+
MAC = 'WXMAC'
|
14
|
+
SUPPORTED_PLATFORMS = [WINDOWS, MAC]
|
15
|
+
|
16
|
+
def self.windows?
|
17
|
+
name == WINDOWS
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.ensure_supported
|
21
|
+
raise unsupported_message unless supported?
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def self.supported?
|
27
|
+
SUPPORTED_PLATFORMS.include?(name)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.unsupported_message
|
31
|
+
"Sorry '#{name}' is not currently supported, " +
|
32
|
+
"Nobbie-Wx is only available for the following platforms: " +
|
33
|
+
"[#{SUPPORTED_PLATFORMS.join(',')}]"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.name
|
37
|
+
Wxruby2::PLATFORM
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
28
42
|
end
|
43
|
+
|
29
44
|
end
|
30
45
|
|
31
|
-
Platform.ensure_supported
|
46
|
+
Nobbie::Wx::Platform.ensure_supported
|
@@ -12,19 +12,36 @@ module Nobbie
|
|
12
12
|
ConsoleReporter.new.should be_kind_of(Reporter)
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
describe "outputs" do
|
16
|
+
|
17
|
+
before :each do
|
18
|
+
@command = mock('command')
|
19
|
+
@command.should_receive(:describe).and_return('description')
|
20
|
+
@command.should_receive(:execute).and_return('result')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "to STDOUT by default" do
|
24
|
+
STDOUT.should_receive(:puts).with(/description/)
|
25
|
+
STDOUT.should_receive(:puts).with(/result/)
|
26
|
+
|
27
|
+
reporter = ConsoleReporter.new
|
28
|
+
executor = Executor.new(reporter)
|
29
|
+
executor.execute(@command)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "to a specified IO stream" do
|
33
|
+
@io = StringIO.new
|
34
|
+
|
35
|
+
@io.should_receive(:puts).with(/description/)
|
36
|
+
@io.should_receive(:puts).with(/result/)
|
37
|
+
|
38
|
+
reporter = ConsoleReporter.new(@io)
|
39
|
+
executor = Executor.new(reporter)
|
40
|
+
executor.execute(@command)
|
41
|
+
end
|
19
42
|
|
20
|
-
STDOUT.should_receive(:puts).with(/.*description.*/)
|
21
|
-
STDOUT.should_receive(:puts).with(/.*result.*/)
|
22
|
-
|
23
|
-
reporter = ConsoleReporter.new
|
24
|
-
executor = Executor.new(reporter)
|
25
|
-
executor.execute(command)
|
26
43
|
end
|
27
|
-
|
44
|
+
|
28
45
|
end
|
29
46
|
|
30
47
|
end
|
data/spec/executor_spec.rb
CHANGED
@@ -16,9 +16,7 @@ module Nobbie
|
|
16
16
|
it "executes a command" do
|
17
17
|
@command.should_receive(:execute)
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
@executor.execute(@command)
|
19
|
+
Nobbie::Wx::Command::Executor.execute(@command)
|
22
20
|
end
|
23
21
|
|
24
22
|
it "calls 'before' and 'after' hooks" do
|
@@ -29,9 +27,9 @@ module Nobbie
|
|
29
27
|
|
30
28
|
@command.should_receive(:execute)
|
31
29
|
|
32
|
-
|
30
|
+
executor = Nobbie::Wx::Command::Executor.new
|
33
31
|
|
34
|
-
|
32
|
+
executor.execute(@command)
|
35
33
|
end
|
36
34
|
|
37
35
|
it "calls 'before' and 'after' hooks on supplied Reporter" do
|
@@ -41,9 +39,8 @@ module Nobbie
|
|
41
39
|
|
42
40
|
@command.should_receive(:execute)
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
@executor.execute(@command)
|
42
|
+
Nobbie::Wx::Command::Executor.reporter = reporter
|
43
|
+
Nobbie::Wx::Command::Executor.execute(@command)
|
47
44
|
end
|
48
45
|
|
49
46
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
require 'nobbie/wx/platform'
|
3
|
+
|
4
|
+
module Nobbie
|
5
|
+
module Wx
|
6
|
+
|
7
|
+
describe "Platform" do
|
8
|
+
|
9
|
+
describe "basic execution" do
|
10
|
+
|
11
|
+
it "Raises a pleasant exception on unsupported platform" do
|
12
|
+
Wxruby2.send(:remove_const, :PLATFORM)
|
13
|
+
Wxruby2::PLATFORM = "unsupported"
|
14
|
+
|
15
|
+
lambda{ Nobbie::Wx::Platform.ensure_supported }.
|
16
|
+
should raise_error("Sorry 'unsupported' is not currently supported, Nobbie-Wx is only available for the following platforms: [WXMSW,WXMAC]")
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/test/all_tests.rb
CHANGED
@@ -9,7 +9,6 @@ require 'test/unit'
|
|
9
9
|
|
10
10
|
Dir.glob("#{TEST}/suite/**/*.rb") { |file| require file }
|
11
11
|
|
12
|
-
Nobbie::Wx::
|
13
|
-
Nobbie::Wx::Command::Executor.new(Nobbie::Wx::Command::ConsoleReporter.new)
|
12
|
+
Nobbie::Wx::Command::Executor.reporter = Nobbie::Wx::Command::ConsoleReporter.new
|
14
13
|
|
15
14
|
Nobbie::Wx::ApplicationLauncher.new(ExampleApp.new).run
|
@@ -12,8 +12,8 @@ module NobbieTestCase
|
|
12
12
|
def select_tab_for_test
|
13
13
|
clear_events
|
14
14
|
tab = self.class.name.gsub('Test', '').downcase
|
15
|
-
|
16
|
-
assert_equal tab,
|
15
|
+
select tab,:in => 'test_notebook'
|
16
|
+
assert_equal tab, selected_value(:in => 'test_notebook')
|
17
17
|
end
|
18
18
|
|
19
19
|
def clear_events
|
data/test/suite/test_choose.rb
CHANGED
@@ -4,49 +4,49 @@ class TestChoose < Test::Unit::TestCase
|
|
4
4
|
#todo: rename file to choosable
|
5
5
|
#todo: should be TestChoosable
|
6
6
|
def test_choose_with_radio_button
|
7
|
-
assert !
|
8
|
-
|
9
|
-
assert
|
7
|
+
assert !chosen?('radio_button')
|
8
|
+
choose('radio_button')
|
9
|
+
assert chosen?('radio_button')
|
10
10
|
assert_events 'radio_button: '
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_choose_with_check_box
|
14
|
-
assert !
|
15
|
-
|
16
|
-
assert
|
14
|
+
assert !chosen?('check_box')
|
15
|
+
choose('check_box')
|
16
|
+
assert chosen?('check_box')
|
17
17
|
assert_events 'check_box: '
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_choose_with_component_disabled_radio_button
|
21
|
-
assert_exception ComponentDisabledException do
|
21
|
+
assert_exception ComponentDisabledException do choose('disabled_radio_button') end
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_choose_with_component_disabled_check_box
|
25
|
-
assert_exception ComponentDisabledException do
|
25
|
+
assert_exception ComponentDisabledException do choose('disabled_check_box') end
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_choose_with_unsupported_operation_for_component
|
29
|
-
assert_exception UnsupportedOperationForComponentException do
|
29
|
+
assert_exception UnsupportedOperationForComponentException do choose('button') end
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_choose_with_component_not_found
|
33
|
-
assert_exception ComponentNotFoundException do
|
33
|
+
assert_exception ComponentNotFoundException do choose('missing') end
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_chosen_with_unsupported_operation_for_component
|
37
|
-
assert_exception UnsupportedOperationForComponentException do
|
37
|
+
assert_exception UnsupportedOperationForComponentException do chosen?('button') end
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_chosen_with_component_not_found
|
41
|
-
assert_exception ComponentNotFoundException do
|
41
|
+
assert_exception ComponentNotFoundException do chosen?('missing') end
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_chosen_with_component_disabled_radio_button
|
45
|
-
assert !
|
45
|
+
assert !chosen?('disabled_radio_button')
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_chosen_with_component_disabled_check_box
|
49
|
-
assert !
|
49
|
+
assert !chosen?('disabled_check_box')
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -2,54 +2,54 @@ class TestSelection < Test::Unit::TestCase
|
|
2
2
|
include NobbieTestCase
|
3
3
|
|
4
4
|
def test_choose_with_notebook_page
|
5
|
-
assert_equal 'notebook_page1',
|
6
|
-
|
7
|
-
assert_equal 'notebook_page2',
|
5
|
+
assert_equal 'notebook_page1', selected_value('notebook')
|
6
|
+
select 'notebook_page2', :in => 'notebook'
|
7
|
+
assert_equal 'notebook_page2', selected_value('notebook')
|
8
8
|
#todo: improve event detail
|
9
9
|
assert_events 'notebook: '
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_choose_with_menu_item
|
13
|
-
|
13
|
+
select '&New...', :in => '&File'
|
14
14
|
#todo: improve event detail
|
15
15
|
assert_events 'file_new'
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_choose_with_combo_box
|
19
|
-
assert_equal '',
|
20
|
-
|
21
|
-
assert_equal 'combo_box_item',
|
19
|
+
assert_equal '', selected_value('combo_box_with_items')
|
20
|
+
select 'combo_box_item', :in => 'combo_box_with_items'
|
21
|
+
assert_equal 'combo_box_item', selected_value('combo_box_with_items')
|
22
22
|
assert_events 'combo_box_with_items: '
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_choose_with_list_box
|
26
|
-
assert_equal '',
|
27
|
-
|
28
|
-
assert_equal 'list_box_item',
|
26
|
+
assert_equal '', selected_value('list_box_with_items')
|
27
|
+
select 'list_box_item', :in => 'list_box_with_items'
|
28
|
+
assert_equal 'list_box_item', selected_value('list_box_with_items')
|
29
29
|
assert_events 'list_box_with_items: list_box_item'
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_choose_with_choice
|
33
|
-
assert_equal '',
|
34
|
-
|
35
|
-
assert_equal 'choice_item',
|
33
|
+
assert_equal '', selected_value('choice_with_items')
|
34
|
+
select 'choice_item', :in => 'choice_with_items'
|
35
|
+
assert_equal 'choice_item', selected_value('choice_with_items')
|
36
36
|
assert_events 'choice_with_items: choice_item'
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_options_with_notebook
|
40
|
-
assert_equal ['notebook_page1', 'notebook_page2'] ,
|
40
|
+
assert_equal ['notebook_page1', 'notebook_page2'] , options('notebook')
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_options_with_combo_box
|
44
|
-
assert_equal ["combo_box_item"],
|
44
|
+
assert_equal ["combo_box_item"], options('combo_box_with_items')
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_options_with_list_box
|
48
|
-
assert_equal ["list_box_item"],
|
48
|
+
assert_equal ["list_box_item"], options('list_box_with_items')
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_options_with_choice
|
52
|
-
assert_equal ["choice_item"],
|
52
|
+
assert_equal ["choice_item"], options('choice_with_items')
|
53
53
|
end
|
54
54
|
|
55
55
|
#todo: options with component not found
|
@@ -58,81 +58,81 @@ class TestSelection < Test::Unit::TestCase
|
|
58
58
|
#not found
|
59
59
|
|
60
60
|
def test_choose_with_value_not_found_notebook
|
61
|
-
assert_exception ValueNotFoundException do
|
61
|
+
assert_exception ValueNotFoundException do select('missing', :in => 'notebook') end
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_choose_with_value_not_found_menu
|
65
|
-
assert_exception ValueNotFoundException do
|
65
|
+
assert_exception ValueNotFoundException do select('missing', :in => '&File') end
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_choose_with_value_not_found_list_box
|
69
|
-
assert_exception ValueNotFoundException do
|
69
|
+
assert_exception ValueNotFoundException do select('missing', :in => 'list_box_with_items') end
|
70
70
|
end
|
71
71
|
|
72
72
|
def test_choose_with_value_not_found_combo_box
|
73
|
-
assert_exception ValueNotFoundException do
|
73
|
+
assert_exception ValueNotFoundException do select('missing', :in => 'combo_box_with_items') end
|
74
74
|
end
|
75
75
|
|
76
76
|
def test_choose_with_value_not_found_combo_box
|
77
|
-
assert_exception ValueNotFoundException do
|
77
|
+
assert_exception ValueNotFoundException do select('missing', :in => 'choice_with_items') end
|
78
78
|
end
|
79
79
|
|
80
80
|
#disabled
|
81
81
|
|
82
82
|
def test_choose_with_component_disabled_menu
|
83
|
-
assert_exception ComponentDisabledException do
|
83
|
+
assert_exception ComponentDisabledException do select('&disabled', :in => '&File') end
|
84
84
|
end
|
85
85
|
|
86
86
|
def test_choose_with_component_disabled_notebook
|
87
|
-
assert_equal 'disabled_notebook_page1',
|
88
|
-
assert_exception ComponentDisabledException do
|
89
|
-
assert_equal 'disabled_notebook_page1',
|
87
|
+
assert_equal 'disabled_notebook_page1', selected_value('disabled_notebook')
|
88
|
+
assert_exception ComponentDisabledException do select('disabled_notebook_page2', :in => 'disabled_notebook') end
|
89
|
+
assert_equal 'disabled_notebook_page1', selected_value('disabled_notebook')
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_choose_with_component_disabled_list_box
|
93
|
-
assert_exception ComponentDisabledException do
|
93
|
+
assert_exception ComponentDisabledException do select('disabled_list_box_item2', :in => 'disabled_list_box_with_items') end
|
94
94
|
end
|
95
95
|
|
96
96
|
def test_choose_with_component_disabled_combo_box
|
97
|
-
assert_exception ComponentDisabledException do
|
97
|
+
assert_exception ComponentDisabledException do select('disabled_combo_box_item2', :in => 'disabled_combo_box_with_items') end
|
98
98
|
end
|
99
99
|
|
100
100
|
def test_choose_with_component_disabled_choice
|
101
|
-
assert_exception ComponentDisabledException do
|
101
|
+
assert_exception ComponentDisabledException do select('disabled_choice_item2', :in => 'disabled_choice_with_items') end
|
102
102
|
end
|
103
103
|
|
104
104
|
#not found etc ...
|
105
105
|
|
106
106
|
def test_choose_with_component_not_found
|
107
|
-
assert_exception ComponentNotFoundException do
|
107
|
+
assert_exception ComponentNotFoundException do select('missing', :in => 'missing') end
|
108
108
|
end
|
109
109
|
|
110
110
|
def test_choose_with_unsupported_operation_for_component
|
111
|
-
assert_exception UnsupportedOperationForComponentException do
|
111
|
+
assert_exception UnsupportedOperationForComponentException do select('value', :in => 'button') end
|
112
112
|
end
|
113
113
|
|
114
114
|
def test_selected_value_unsupported_operation_for_menu
|
115
|
-
assert_exception UnsupportedOperationForComponentException do
|
115
|
+
assert_exception UnsupportedOperationForComponentException do selected_value('&File') end
|
116
116
|
end
|
117
117
|
|
118
118
|
def test_selected_value_with_unsupported_operation_for_component
|
119
|
-
assert_exception UnsupportedOperationForComponentException do
|
119
|
+
assert_exception UnsupportedOperationForComponentException do selected_value('button') end
|
120
120
|
end
|
121
121
|
|
122
122
|
def test_selected_value_with_component_not_found
|
123
|
-
assert_exception ComponentNotFoundException do
|
123
|
+
assert_exception ComponentNotFoundException do selected_value('missing') end
|
124
124
|
end
|
125
125
|
|
126
126
|
def test_options_with_component_not_found
|
127
|
-
assert_exception ComponentNotFoundException do
|
127
|
+
assert_exception ComponentNotFoundException do options('missing') end
|
128
128
|
end
|
129
129
|
|
130
130
|
def test_options_unsupported_operation_for_menu
|
131
|
-
assert_exception UnsupportedOperationForComponentException do
|
131
|
+
assert_exception UnsupportedOperationForComponentException do options('&File') end
|
132
132
|
end
|
133
133
|
|
134
134
|
def test_options_with_unsupported_operation_for_component
|
135
|
-
assert_exception UnsupportedOperationForComponentException do
|
135
|
+
assert_exception UnsupportedOperationForComponentException do options('button') end
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
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
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Alton
|
@@ -64,8 +64,6 @@ files:
|
|
64
64
|
- lib/nobbie/wx/command/select.rb
|
65
65
|
- lib/nobbie/wx/command/type_into.rb
|
66
66
|
- lib/nobbie/wx/impl/element/element_path_builder.rb
|
67
|
-
- lib/nobbie/wx/impl/operation/choosable.rb
|
68
|
-
- lib/nobbie/wx/impl/operation/select.rb
|
69
67
|
- features/step_definitions
|
70
68
|
- features/support
|
71
69
|
- features/acceptance_test.feature
|
@@ -74,6 +72,7 @@ files:
|
|
74
72
|
- spec/application_launcher_spec.rb
|
75
73
|
- spec/console_reporter_spec.rb
|
76
74
|
- spec/executor_spec.rb
|
75
|
+
- spec/platform_spec.rb
|
77
76
|
- spec/reporter_spec.rb
|
78
77
|
- spec/spec.opts
|
79
78
|
- spec/spec_helper.rb
|
@@ -92,7 +91,7 @@ homepage: http://github.com/bryan-ash/wx-nobbie
|
|
92
91
|
post_install_message:
|
93
92
|
rdoc_options:
|
94
93
|
- --main
|
95
|
-
- README.
|
94
|
+
- README.rdoc
|
96
95
|
- --inline-source
|
97
96
|
- --charset=UTF-8
|
98
97
|
require_paths:
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Nobbie
|
2
|
-
module Wx
|
3
|
-
|
4
|
-
class ChoosableOperations
|
5
|
-
def initialize(operations, path)
|
6
|
-
@operations = operations
|
7
|
-
@path = path
|
8
|
-
end
|
9
|
-
|
10
|
-
# Chooses the component specified in the path.
|
11
|
-
# Supported components: RadioButton, CheckBox
|
12
|
-
def choose
|
13
|
-
execute(@operations.command_factory.create_choose_command(@path))
|
14
|
-
end
|
15
|
-
|
16
|
-
# Determines if the component specified in the path is chosen.
|
17
|
-
# Supported components: RadioButton, CheckBox
|
18
|
-
def chosen?
|
19
|
-
execute(@operations.command_factory.create_is_chosen_command(@path))
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Nobbie
|
2
|
-
module Wx
|
3
|
-
|
4
|
-
class SelectOperations
|
5
|
-
def initialize(operations, path)
|
6
|
-
@operations = operations
|
7
|
-
@path = path
|
8
|
-
end
|
9
|
-
|
10
|
-
# Retrieves the currently selected value for the component specified in the path.
|
11
|
-
# Supported components: Notebook, ComboBox, ListBox, Choice
|
12
|
-
def selected_value
|
13
|
-
execute(@operations.command_factory.create_get_selected_values_command(@path))
|
14
|
-
end
|
15
|
-
|
16
|
-
# Selects the given value for the component specified in the path.
|
17
|
-
# Supported components: Notebook, Menu, ComboBox, ListBox, Choice
|
18
|
-
def choose(value)
|
19
|
-
execute(@operations.command_factory.create_select_command(@path, value))
|
20
|
-
end
|
21
|
-
|
22
|
-
# Retrieves available options for the component specified in the path.
|
23
|
-
# Supported components: Notebook, ComboBox, ListBox, Choice
|
24
|
-
def options
|
25
|
-
execute(@operations.command_factory.create_get_options_command(@path))
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|