rsel 0.1.1 → 0.1.2

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.
Files changed (48) hide show
  1. data/.gitignore +1 -0
  2. data/Rakefile +22 -8
  3. data/docs/development.md +1 -0
  4. data/docs/history.md +11 -1
  5. data/docs/index.md +1 -0
  6. data/docs/scoping.md +1 -1
  7. data/docs/studying.md +76 -0
  8. data/lib/rsel/selenium_test.rb +505 -90
  9. data/lib/rsel/study_html.rb +198 -0
  10. data/lib/rsel/support.rb +105 -4
  11. data/rsel.gemspec +1 -1
  12. data/spec/spec_helper.rb +4 -22
  13. data/spec/st_alerts.rb +48 -0
  14. data/spec/st_browser_spec.rb +58 -0
  15. data/spec/st_buttons_spec.rb +95 -0
  16. data/spec/st_checkboxes_spec.rb +235 -0
  17. data/spec/st_conditionals_spec.rb +180 -0
  18. data/spec/st_dropdowns_spec.rb +140 -0
  19. data/spec/st_field_equals_among_spec.rb +48 -0
  20. data/spec/st_fields_equal_among_spec.rb +74 -0
  21. data/spec/st_fields_equal_spec.rb +90 -0
  22. data/spec/st_fields_spec.rb +167 -0
  23. data/spec/st_initialization_spec.rb +33 -0
  24. data/spec/st_links_spec.rb +84 -0
  25. data/spec/st_method_missing_spec.rb +59 -0
  26. data/spec/st_navigation_spec.rb +56 -0
  27. data/spec/st_radiobuttons_spec.rb +123 -0
  28. data/spec/st_respond_to_spec.rb +16 -0
  29. data/spec/st_scenario_spec.rb +26 -0
  30. data/spec/st_set_field_among_spec.rb +45 -0
  31. data/spec/st_set_field_spec.rb +842 -0
  32. data/spec/st_set_fields_among_spec.rb +74 -0
  33. data/spec/st_set_fields_spec.rb +97 -0
  34. data/spec/st_spec_helper.rb +43 -0
  35. data/spec/st_stop_on_failure_spec.rb +199 -0
  36. data/spec/st_tables_spec.rb +42 -0
  37. data/spec/st_temporal_visibility_spec.rb +122 -0
  38. data/spec/st_visibility_spec.rb +125 -0
  39. data/spec/st_waiting_spec.rb +37 -0
  40. data/spec/study_html_spec.rb +310 -0
  41. data/spec/support_spec.rb +163 -13
  42. data/test/server/README.txt +3 -0
  43. data/test/views/alert.erb +15 -0
  44. data/test/views/form.erb +6 -1
  45. data/test/views/index.erb +2 -0
  46. data/test/views/slowtext.erb +1 -1
  47. metadata +38 -9
  48. data/spec/selenium_test_spec.rb +0 -2656
@@ -0,0 +1,140 @@
1
+ require 'spec/st_spec_helper'
2
+
3
+ describe 'dropdowns' do
4
+ before(:each) do
5
+ @st.visit("/form").should be_true
6
+ end
7
+
8
+ context "#select_from_dropdown" do
9
+ context "passes when" do
10
+ it "option exists in the dropdown" do
11
+ @st.select_from_dropdown("Tall", "Height").should be_true
12
+ @st.select_from_dropdown("Medium", "Weight").should be_true
13
+ end
14
+
15
+ it "option exists in the dropdown within scope" do
16
+ @st.select_from_dropdown("Tall", "Height", :within => "spouse_form").should be_true
17
+ end
18
+
19
+ it "option exists in the dropdown in table row" do
20
+ @st.visit("/table")
21
+ @st.select_from_dropdown("Male", "Gender", :in_row => "Eric").should be_true
22
+ end
23
+ end
24
+
25
+ context "fails when" do
26
+ it "no such dropdown exists" do
27
+ @st.select_from_dropdown("Over easy", "Eggs").should be_false
28
+ end
29
+
30
+ it "dropdown exists, but the option doesn't" do
31
+ @st.select_from_dropdown("Giant", "Height").should be_false
32
+ @st.select_from_dropdown("Obese", "Weight").should be_false
33
+ end
34
+
35
+ it "dropdown exists, but is read-only" do
36
+ @st.visit("/readonly_form").should be_true
37
+ @st.select_from_dropdown("Tall", "Height").should be_false
38
+ end
39
+
40
+ it "dropdown exists, but not within scope" do
41
+ @st.select_from_dropdown("Medium", "Weight", :within => "spouse_form").should be_false
42
+ end
43
+
44
+ it "dropdown exists, but not in table row" do
45
+ @st.visit("/table")
46
+ @st.select_from_dropdown("Female", "Gender", :in_row => "First name").should be_false
47
+ end
48
+ end
49
+ end
50
+
51
+ context "#dropdown_includes" do
52
+ context "passes when" do
53
+ it "option exists in the dropdown" do
54
+ @st.dropdown_includes("Height", "Tall").should be_true
55
+ @st.dropdown_includes("Weight", "Medium").should be_true
56
+ end
57
+
58
+ it "option exists in a read-only dropdown" do
59
+ @st.visit("/readonly_form").should be_true
60
+ @st.dropdown_includes("Height", "Tall").should be_true
61
+ end
62
+ end
63
+
64
+ context "fails when" do
65
+ it "dropdown exists, but the option doesn't" do
66
+ @st.dropdown_includes("Height", "Giant").should be_false
67
+ @st.dropdown_includes("Weight", "Obese").should be_false
68
+ end
69
+
70
+ it "no such dropdown exists" do
71
+ @st.dropdown_includes("Eggs", "Over easy").should be_false
72
+ end
73
+ end
74
+ end
75
+
76
+ context "#dropdown_equals" do
77
+ context "passes when" do
78
+ it "option is selected in the dropdown" do
79
+ ["Short", "Average", "Tall"].each do |height|
80
+ @st.select_from_dropdown(height, "Height")
81
+ @st.dropdown_equals("Height", height).should be_true
82
+ end
83
+ end
84
+
85
+ it "option is selected in a read-only dropdown" do
86
+ @st.visit("/readonly_form").should be_true
87
+ @st.dropdown_equals("Height", "Average").should be_true
88
+ end
89
+
90
+ it "option is selected in the dropdown, within scope" do
91
+ ["Short", "Average", "Tall"].each do |height|
92
+ @st.select_from_dropdown(height, "Height", :within => "spouse_form")
93
+ @st.dropdown_equals("Height", height, :within => "spouse_form").should be_true
94
+ end
95
+ end
96
+
97
+ it "option is selected in the dropdown, in table row" do
98
+ @st.visit("/table")
99
+ ["Male", "Female"].each do |gender|
100
+ @st.select_from_dropdown(gender, "Gender", :in_row => "Eric")
101
+ @st.dropdown_equals("Gender", gender, :in_row => "Eric")
102
+ end
103
+ end
104
+ end
105
+
106
+ context "fails when" do
107
+ it "no such dropdown exists" do
108
+ @st.dropdown_equals("Eggs", "Over easy").should be_false
109
+ end
110
+
111
+ it "dropdown exists, but the option is not selected" do
112
+ @st.select_from_dropdown("Short", "Height")
113
+ @st.dropdown_equals("Height", "Average").should be_false
114
+ @st.dropdown_equals("Height", "Tall").should be_false
115
+
116
+ @st.select_from_dropdown("Average", "Height")
117
+ @st.dropdown_equals("Height", "Short").should be_false
118
+ @st.dropdown_equals("Height", "Tall").should be_false
119
+
120
+ @st.select_from_dropdown("Tall", "Height")
121
+ @st.dropdown_equals("Height", "Short").should be_false
122
+ @st.dropdown_equals("Height", "Average").should be_false
123
+ end
124
+
125
+ it "dropdown exists, and option is selected, but not within scope" do
126
+ @st.select_from_dropdown("Tall", "Height", :within => "person_form")
127
+ @st.select_from_dropdown("Short", "Height", :within => "spouse_form")
128
+ @st.dropdown_equals("Height", "Tall", :within => "spouse_form").should be_false
129
+ end
130
+
131
+ it "dropdown exists, and option is selected, but not in table row" do
132
+ @st.visit("/table")
133
+ @st.select_from_dropdown("Female", "Gender", :in_row => "Eric")
134
+ @st.select_from_dropdown("Male", "Gender", :in_row => "Marcus")
135
+ @st.dropdown_equals("Gender", "Female", :in_row => "Marcus").should be_false
136
+ end
137
+ end
138
+ end
139
+ end
140
+
@@ -0,0 +1,48 @@
1
+ require 'spec/st_spec_helper'
2
+
3
+ describe "#field_equals_among" do
4
+ before(:each) do
5
+ @st.visit("/form").should be_true
6
+ end
7
+
8
+ context "passes when" do
9
+ context "text field with label" do
10
+ it "equals the page text" do
11
+ @st.set_field_among("First name", "Marcus", "Last name" => "nowhere").should be_true
12
+ @st.field_equals_among("First name", "Marcus", "Last name" => "nowhere").should be_true
13
+ end
14
+
15
+ it "equals the page text and has no ids" do
16
+ @st.set_field_among("First name", "Marcus", "").should be_true
17
+ @st.field_equals_among("First name", "Marcus", "").should be_true
18
+ end
19
+
20
+ it "equals the hash text" do
21
+ @st.set_field_among("Last name", "Marcus", "Last name" => "First name").should be_true
22
+ @st.field_equals_among("Last name", "Marcus", "Last name" => "First name").should be_true
23
+ end
24
+
25
+ it "equals the escaped hash text" do
26
+ @st.set_field_among("Last:name", "Marcus", "Last\\;name" => "First name").should be_true
27
+ @st.field_equals_among("Last:name", "Marcus", "Last\\;name" => "First name").should be_true
28
+ end
29
+ end
30
+ end
31
+
32
+ context "fails when" do
33
+ context "text field with label" do
34
+ it "does not exist" do
35
+ @st.field_equals_among("Third name", "").should be_false
36
+ end
37
+
38
+ it "has a hash value that does not exist" do
39
+ @st.field_equals_among("Last name", "", "Last name" => "Third name").should be_false
40
+ end
41
+
42
+ it "does not equal the expected text" do
43
+ @st.field_equals_among("Last name", "Marcus", "Last name" => "First name").should be_false
44
+ end
45
+ end
46
+ end
47
+ end # field_equals_among
48
+
@@ -0,0 +1,74 @@
1
+ require 'spec/st_spec_helper'
2
+
3
+ describe "#fields_equal_among" do
4
+ before(:each) do
5
+ @st.visit("/form").should be_true
6
+ end
7
+
8
+ context "passes when" do
9
+ context "text fields with labels" do
10
+ it "sets one field" do
11
+ @st.set_fields_among({"First name" => "Marcus"}).should be_true
12
+ @st.fields_equal_among({"First name" => "Marcus"}).should be_true
13
+ end
14
+
15
+ it "sets one field with string ids" do
16
+ @st.set_fields_among({"First name" => "Marcus"}, "").should be_true
17
+ @st.fields_equal_among({"First name" => "Marcus"}, "").should be_true
18
+ end
19
+
20
+ it "does nothing, but has ids" do
21
+ @st.fields_equal_among("", {"First name" => "Marcus"}).should be_true
22
+ end
23
+
24
+ it "sets several fields" do
25
+ @st.set_fields_among({"First name" => "Ken", "Last name" => "Brazier", "Life story" => "My story\\; I get testy a lot."}).should be_true
26
+ @st.fields_equal_among({"First name" => "Ken", "Last name" => "Brazier", "Life story" => "My story\\; I get testy a lot."}).should be_true
27
+ end
28
+ end
29
+ context "text fields with labels in a hash" do
30
+ it "sets one field from a hash" do
31
+ @st.set_fields_among({"Faust name" => "Marcus"}, {"Faust Name" => "First name", "LOST name" => "Last name"}).should be_true
32
+ @st.fields_equal_among({"Faust name" => "Marcus"}, {"Faust Name" => "First name", "LOST name" => "Last name"}).should be_true
33
+ end
34
+
35
+ it "sets many fields, some from a hash" do
36
+ @st.set_fields_among({"Faust\\;name" => "Ken", :Lost => "Brazier", "Life story" => "I get testy a lot."},
37
+ {"Faust\\;Name" => "First name", :LOST => "Last name"}).should be_true
38
+ @st.fields_equal_among({"Faust\\;name" => "Ken", :Lost => "Brazier", "Life story" => "I get testy a lot."},
39
+ {"Faust\\;Name" => "First name", :LOST => "Last name"}).should be_true
40
+ end
41
+ end
42
+ end
43
+
44
+ context "fails when" do
45
+ context "text fields with labels" do
46
+ it "cant find the first field" do
47
+ @st.fields_equal_among({"Faust name" => "Ken", "Last name" => "Brazier"}).should be_false
48
+ end
49
+
50
+ it "cant find the last field" do
51
+ @st.fields_equal_among({"First name" => "Ken", "Lost name" => "Brazier"}).should be_false
52
+ end
53
+ it "does not equal the expected values" do
54
+ @st.fields_equal_among({"First name" => "Ken", "Last name" => "Brazier", "Life story" => "My story\\; I get testy a lot."}).should be_false
55
+ end
56
+ end
57
+ context "text fields with labels in a hash" do
58
+ it "cant find the first field" do
59
+ @st.fields_equal_among({"Faust name" => "Ken", "Lost name" => "Brazier"},
60
+ {"Faust Name" => "Lost name", "Lost name" => "Last name"}).should be_false
61
+ end
62
+
63
+ it "cant find the last field" do
64
+ @st.fields_equal_among({"Faust name" => "Ken", "Lost name" => "Brazier"},
65
+ {"Faust Name" => "First name", "Lost name" => "Faust name"}).should be_false
66
+ end
67
+ it "does not equal the expected values" do
68
+ @st.fields_equal_among({"Faust\\;name" => "Ken", :Lost => "Brazier", "Life story" => "I get testy a lot."},
69
+ {"Faust\\;Name" => "First name", :LOST => "Last name"}).should be_false
70
+ end
71
+ end
72
+ end
73
+ end # fields_equal_among
74
+
@@ -0,0 +1,90 @@
1
+ require 'spec/st_spec_helper'
2
+
3
+ describe "#fields_equal" do
4
+ context "without studying" do
5
+ before(:each) do
6
+ @st.visit("/form").should be_true
7
+ end
8
+
9
+ context "passes when" do
10
+ context "text fields with labels" do
11
+ it "sets one field" do
12
+ @st.set_fields("First name" => "Marcus").should be_true
13
+ @st.fields_equal("First name" => "Marcus").should be_true
14
+ end
15
+
16
+ it "sets zero fields" do
17
+ @st.fields_equal("").should be_true
18
+ end
19
+
20
+ it "sets several fields" do
21
+ @st.set_fields("First name" => "Ken", "Last name" => "Brazier", "Life story" => "My story\\; I get testy a lot.").should be_true
22
+ @st.fields_equal("First name" => "Ken", "Last name" => "Brazier", "Life story" => "My story\\; I get testy a lot.").should be_true
23
+ end
24
+ end
25
+ end
26
+
27
+ context "fails when" do
28
+ context "text fields with labels" do
29
+ it "cant find the first field" do
30
+ @st.fields_equal("Faust name" => "", "Last name" => "").should be_false
31
+ end
32
+
33
+ it "cant find the last field" do
34
+ @st.fields_equal("First name" => "", "Lost name" => "").should be_false
35
+ end
36
+
37
+ it "fields are not equal" do
38
+ @st.fields_equal("First name" => "Ken", "Last name" => "Brazier").should be_false
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ context "with studying" do
45
+ before(:all) do
46
+ @st.set_fields_study_min('always')
47
+ end
48
+ before(:each) do
49
+ @st.visit("/form").should be_true
50
+ end
51
+
52
+ context "passes when" do
53
+ context "text fields with labels" do
54
+ it "sets one field" do
55
+ @st.set_fields("First name" => "Marcus").should be_true
56
+ @st.fields_equal("First name" => "Marcus").should be_true
57
+ end
58
+
59
+ it "sets zero fields" do
60
+ @st.fields_equal("").should be_true
61
+ end
62
+
63
+ it "sets several fields" do
64
+ @st.set_fields("First name" => "Ken", "Last name" => "Brazier", "Life story" => "My story\\; I get testy a lot.").should be_true
65
+ @st.fields_equal("First name" => "Ken", "Last name" => "Brazier", "Life story" => "My story\\; I get testy a lot.").should be_true
66
+ end
67
+ end
68
+ end
69
+
70
+ context "fails when" do
71
+ context "text fields with labels" do
72
+ it "cant find the first field" do
73
+ @st.fields_equal("Faust name" => "", "Last name" => "").should be_false
74
+ end
75
+
76
+ it "cant find the last field" do
77
+ @st.fields_equal("First name" => "", "Lost name" => "").should be_false
78
+ end
79
+
80
+ it "fields are not equal" do
81
+ @st.fields_equal("First name" => "Ken", "Last name" => "Brazier").should be_false
82
+ end
83
+ end
84
+ end
85
+ after(:all) do
86
+ @st.set_fields_study_min('default')
87
+ end
88
+ end
89
+ end # fields_equal
90
+
@@ -0,0 +1,167 @@
1
+ require 'spec/st_spec_helper'
2
+
3
+ describe 'fields' do
4
+ before(:each) do
5
+ @st.visit("/form").should be_true
6
+ end
7
+
8
+ describe "#type_into_field" do
9
+ context "passes when" do
10
+ context "text field with label" do
11
+ it "exists" do
12
+ @st.type_into_field("Eric", "First name").should be_true
13
+ @st.fill_in_with("Last name", "Pierce").should be_true
14
+ end
15
+ it "exists within scope" do
16
+ @st.type_into_field("Eric", "First name", :within => 'person_form').should be_true
17
+ @st.type_into_field("Andrea", "First name", :within => 'spouse_form').should be_true
18
+ end
19
+ end
20
+
21
+ context "text field with id" do
22
+ it "exists" do
23
+ @st.type_into_field("Eric", "first_name").should be_true
24
+ @st.fill_in_with("last_name", "Pierce").should be_true
25
+ end
26
+ end
27
+
28
+ context "textarea with label" do
29
+ it "exists" do
30
+ @st.type_into_field("Blah blah blah", "Life story").should be_true
31
+ @st.fill_in_with("Life story", "Jibber jabber").should be_true
32
+ end
33
+ end
34
+
35
+ context "textarea with id" do
36
+ it "exists" do
37
+ @st.type_into_field("Blah blah blah", "biography").should be_true
38
+ @st.fill_in_with("biography", "Jibber jabber").should be_true
39
+ end
40
+ end
41
+ end
42
+
43
+ context "fails when" do
44
+ it "no field with the given label or id exists" do
45
+ @st.type_into_field("Matthew", "Middle name").should be_false
46
+ @st.fill_in_with("middle_name", "Matthew").should be_false
47
+ end
48
+
49
+ it "field exists, but not within scope" do
50
+ @st.type_into_field("Long story", "Life story",
51
+ :within => 'spouse_form').should be_false
52
+ end
53
+
54
+ it "field exists, but is read-only" do
55
+ @st.visit("/readonly_form").should be_true
56
+ @st.type_into_field("Eric", "First name").should be_false
57
+ end
58
+ end
59
+ end
60
+
61
+ describe "#field_contains" do
62
+ context "passes when" do
63
+ context "text field with label" do
64
+ it "equals the text" do
65
+ @st.fill_in_with("First name", "Marcus")
66
+ @st.field_contains("First name", "Marcus").should be_true
67
+ end
68
+
69
+ it "contains the text" do
70
+ @st.fill_in_with("First name", "Marcus")
71
+ @st.field_contains("First name", "Marc").should be_true
72
+ end
73
+ end
74
+
75
+ context "textarea with label" do
76
+ it "contains the text" do
77
+ @st.fill_in_with("Life story", "Blah dee blah")
78
+ @st.field_contains("Life story", "blah").should be_true
79
+ end
80
+ end
81
+ end
82
+
83
+ context "fails when" do
84
+ context "text field with label" do
85
+ it "does not exist" do
86
+ @st.field_contains("Third name", "Smith").should be_false
87
+ end
88
+
89
+ it "does not contain the text" do
90
+ @st.fill_in_with("First name", "Marcus")
91
+ @st.field_contains("First name", "Eric").should be_false
92
+ end
93
+ end
94
+
95
+ context "textarea with label" do
96
+ it "does not contain the text" do
97
+ @st.fill_in_with("Life story", "Blah dee blah")
98
+ @st.field_contains("Life story", "spam").should be_false
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ describe "#field_equals" do
105
+ context "passes when" do
106
+ context "text field with label" do
107
+ it "equals the text" do
108
+ @st.fill_in_with("First name", "Ken")
109
+ @st.field_equals("First name", "Ken").should be_true
110
+ end
111
+
112
+ it "equals the text, and is within scope" do
113
+ @st.fill_in_with("First name", "Eric", :within => "person_form")
114
+ @st.field_equals("First name", "Eric", :within => "person_form")
115
+ end
116
+ end
117
+
118
+ context "textarea with label" do
119
+ it "equals the text" do
120
+ @st.fill_in_with("Life story", "Blah dee blah")
121
+ @st.field_equals("Life story", "Blah dee blah").should be_true
122
+ end
123
+
124
+ it "equals the text, and is within scope" do
125
+ @st.fill_in_with("Life story", "Blah dee blah",
126
+ :within => "person_form")
127
+ @st.field_equals("Life story", "Blah dee blah",
128
+ :within => "person_form").should be_true
129
+ end
130
+
131
+ it "equals the text, and is in table row" do
132
+ # TODO
133
+ end
134
+ end
135
+ end
136
+
137
+ context "fails when" do
138
+ context "text field with label" do
139
+ it "does not exactly equal the text" do
140
+ @st.fill_in_with("First name", "Marcus")
141
+ @st.field_equals("First name", "Marc").should be_false
142
+ end
143
+ end
144
+
145
+ context "textarea with label" do
146
+ it "does not exist" do
147
+ @st.field_equals("Third name", "Smith").should be_false
148
+ end
149
+
150
+ it "does not exactly equal the text" do
151
+ @st.fill_in_with("Life story", "Blah dee blah")
152
+ @st.field_equals("Life story", "Blah dee").should be_false
153
+ end
154
+
155
+ it "exactly equals the text, but is not within scope" do
156
+ @st.fill_in_with("First name", "Eric", :within => "person_form")
157
+ @st.field_equals("First name", "Eric", :within => "spouse_form").should be_false
158
+ end
159
+
160
+ it "exactly equals the text, but is not in table row" do
161
+ # TODO
162
+ end
163
+ end
164
+ end
165
+ end
166
+
167
+ end