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.
@@ -55,17 +55,17 @@ A quick overview with examples:
55
55
 
56
56
  * Selecting ...
57
57
 
58
- selection(path).choose(value)
58
+ select value, path
59
59
 
60
60
  e.g.
61
61
 
62
- selection(in_('title')).choose('Mr')
62
+ select 'Mr', in_('title')
63
63
 
64
64
  ...or
65
65
 
66
- selection(:in => 'title').choose 'Mr'
67
- selection('title').choose 'Mr'
68
- selection(:title).choose 'Mr'
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
- selection(path).selected_value
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
- choosable(path).choose
99
+ choose path
100
100
 
101
101
  e.g.
102
102
 
103
- choosable(in_('female')).choose
103
+ choose in_('female')
104
104
 
105
105
  ...or
106
106
 
107
- choosable(:in => 'female').choose
108
- choosable('female').choose
109
- choosable(:female).choose
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
- choosable(path).chosen?
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
- By default Nobbie hooks into test/unit. However, due to a Wx limitation its not possible to launch a new
124
- instance of your application for every test run (this would also be very slow anyway). So, instead Nobbie
125
- will launch your application, run all the tests in your suite and then close down the application. (Note: If
126
- anyone has a better solution to this ... please let me know).
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 has a suite of tests which are installed as part of the gem. Take a look at the 'test' directory.
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 = '--format pretty'
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 a radio button
6
- Then "radio_button" is not chosen
7
- When I choose "radio_button"
8
- Then "radio_button" is chosen
5
+ Scenario Outline: Choosing things
6
+ Given "<control>" is not chosen
7
+ When I choose "<control>"
8
+ Then "<control>" is chosen
9
9
 
10
- Scenario: Choosing a check box
11
- Then "check_box" is not chosen
12
- When I choose "check_box"
13
- Then "check_box" is chosen
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: Type into a combo box
20
- When I type "456" into "combo_box"
21
- Then I should see "456" in "combo_box"
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
- Scenario Outline: Working with selectables
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
- choosable(item).choose
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
- selection(:in => selectable).choose value
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
- choosable(item).should be_chosen
35
+ execute_and_catch_exception { chosen?(item).should be_true }
27
36
  end
28
37
 
29
38
  Then /^"(.*)" is not chosen$/ do |item|
30
- choosable(item).should_not be_chosen
39
+ chosen?(item).should be_false
31
40
  end
32
41
 
33
42
  Then /^"(.*)" on the "(.*)" should be selected$/ do |value, selectable|
34
- selection(:in => selectable).selected_value.should == value
43
+ execute_and_catch_exception { selected_value(:in => selectable).should == value }
35
44
  end
36
45
 
37
46
  Then /^"(.*)" includes "(.*)"$/ do |selectable, value|
38
- selection(:in => selectable).options.should include(value)
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
@@ -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
- Nobbie::Wx::ApplicationLauncher.new(ExampleApp.new(false)).run
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
- STDOUT.puts "\n> #{command.describe}"
15
+ @output_stream.puts "\n> #{command.describe}"
12
16
  end
13
17
 
14
18
  def after_executing_command(result)
15
- STDOUT.puts "< #{render(result)}"
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
@@ -1,15 +1,12 @@
1
1
  require 'nobbie/wx/command_factory'
2
2
 
3
- impl = File.dirname(__FILE__) + File::SEPARATOR + 'impl'
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
- # Returns a SelectionOperations[link:classes/Nobbie/Wx/SelectOperations.html] for interacting with
40
- # the component specified in the path
41
- def selection(path)
42
- SelectOperations.new(self, coerce_path(path))
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
- # Returns a ChoosableOperations[link:classes/Nobbie/Wx/ChoosableOperations.html] for interacting with
46
- # the component specified in the path
47
- def choosable(path)
48
- ChoosableOperations.new(self, coerce_path((path)))
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
- EXECUTOR.execute(command)
86
+ Command::Executor.execute(command)
72
87
  end
73
88
 
74
89
  private
@@ -1,31 +1,46 @@
1
1
  require 'rubygems'
2
2
  require 'wx'
3
3
 
4
- #todo: move this into Nobbie::Wx namespace ... once name clash is fixed
5
- class Platform #:nodoc:
6
- include Wx
7
-
8
- WINDOWS = 'WXMSW'
9
- MAC = 'WXMAC'
10
- SUPPORTED_PLATFORMS = [WINDOWS, MAC]
11
-
12
- def self.windows?
13
- name == WINDOWS
14
- end
15
-
16
- def self.ensure_supported
17
- Kernel.raise "Sorry '#{name}' is not currently supported, Nobbie-Wx is only available for the following platforms: [#{SUPPORTED_PLATFORMS.join(',')}]" unless supported?
18
- end
19
-
20
- private
21
-
22
- def self.supported?
23
- SUPPORTED_PLATFORMS.include?(name)
24
- end
25
-
26
- def self.name
27
- Wx::PLATFORM
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
- it "outputs to STDOUT by default" do
16
- command = mock('command')
17
- command.should_receive(:describe).and_return('description')
18
- command.should_receive(:execute).and_return('result')
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
@@ -16,9 +16,7 @@ module Nobbie
16
16
  it "executes a command" do
17
17
  @command.should_receive(:execute)
18
18
 
19
- @executor = Nobbie::Wx::Command::Executor.new
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
- @executor = Nobbie::Wx::Command::Executor.new
30
+ executor = Nobbie::Wx::Command::Executor.new
33
31
 
34
- @executor.execute(@command)
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
- @executor = Nobbie::Wx::Command::Executor.new(reporter)
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
@@ -9,7 +9,6 @@ require 'test/unit'
9
9
 
10
10
  Dir.glob("#{TEST}/suite/**/*.rb") { |file| require file }
11
11
 
12
- Nobbie::Wx::Operations::EXECUTOR =
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
- selection(:in => 'test_notebook').choose tab
16
- assert_equal tab, selection(:in => 'test_notebook').selected_value
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
@@ -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 !choosable('radio_button').chosen?
8
- choosable('radio_button').choose
9
- assert choosable('radio_button').chosen?
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 !choosable('check_box').chosen?
15
- choosable('check_box').choose
16
- assert choosable('check_box').chosen?
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 choosable('disabled_radio_button').choose end
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 choosable('disabled_check_box').choose end
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 choosable('button').choose end
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 choosable('missing').choose end
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 choosable('button').chosen? end
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 choosable('missing').chosen? end
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 !choosable('disabled_radio_button').chosen?
45
+ assert !chosen?('disabled_radio_button')
46
46
  end
47
47
 
48
48
  def test_chosen_with_component_disabled_check_box
49
- assert !choosable('disabled_check_box').chosen?
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', selection('notebook').selected_value
6
- selection('notebook').choose 'notebook_page2'
7
- assert_equal 'notebook_page2', selection('notebook').selected_value
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
- selection('&File').choose '&New...'
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 '', selection('combo_box_with_items').selected_value
20
- selection('combo_box_with_items').choose 'combo_box_item'
21
- assert_equal 'combo_box_item', selection('combo_box_with_items').selected_value
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 '', selection('list_box_with_items').selected_value
27
- selection('list_box_with_items').choose 'list_box_item'
28
- assert_equal 'list_box_item', selection('list_box_with_items').selected_value
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 '', selection('choice_with_items').selected_value
34
- selection('choice_with_items').choose 'choice_item'
35
- assert_equal 'choice_item', selection('choice_with_items').selected_value
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'] , selection('notebook').options
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"], selection('combo_box_with_items').options
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"], selection('list_box_with_items').options
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"], selection('choice_with_items').options
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 selection('notebook').choose 'missing' end
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 selection('&File').choose 'missing' end
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 selection('list_box_with_items').choose 'missing' end
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 selection('combo_box_with_items').choose 'missing' end
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 selection('choice_with_items').choose 'missing' end
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 selection('&File').choose '&disabled' end
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', selection('disabled_notebook').selected_value
88
- assert_exception ComponentDisabledException do selection('disabled_notebook').choose 'disabled_notebook_page2' end
89
- assert_equal 'disabled_notebook_page1', selection('disabled_notebook').selected_value
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 selection('disabled_list_box_with_items').choose 'disabled_list_box_item2' end
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 selection('disabled_combo_box_with_items').choose 'disabled_combo_box_item2' end
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 selection('disabled_choice_with_items').choose 'disabled_choice_item2' end
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 selection('missing').choose 'missing' end
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 selection('button').choose 'value' end
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 selection('&File').selected_value end
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 selection('button').selected_value end
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 selection('missing').selected_value end
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 selection('missing').options end
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 selection('&File').options end
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 selection('button').options end
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
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.txt
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