capybara_minitest_spec 0.2.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/.rvmrc +1 -1
  2. data/HISTORY.md +0 -0
  3. data/README.md +31 -32
  4. data/Rakefile +2 -2
  5. data/capybara_minitest_spec.gemspec +6 -4
  6. data/lib/capybara_minitest_spec.rb +53 -6
  7. data/lib/capybara_minitest_spec/test_name.rb +67 -0
  8. data/lib/capybara_minitest_spec/version.rb +1 -1
  9. data/spec/capybara_minitest_spec.spec.rb +13 -0
  10. data/spec/capybara_rspec_matchers.spec.rb +580 -0
  11. data/spec/helper.rb +39 -0
  12. data/{test_app → spec/test_app}/test_app.rb +0 -0
  13. data/{test_app → spec/test_app}/views/buttons.erb +0 -0
  14. data/{test_app → spec/test_app}/views/fieldsets.erb +0 -0
  15. data/{test_app → spec/test_app}/views/form.erb +0 -0
  16. data/{test_app → spec/test_app}/views/frame_one.erb +0 -0
  17. data/{test_app → spec/test_app}/views/frame_two.erb +0 -0
  18. data/{test_app → spec/test_app}/views/header_links.erb +0 -0
  19. data/{test_app → spec/test_app}/views/host_links.erb +0 -0
  20. data/{test_app → spec/test_app}/views/popup_one.erb +0 -0
  21. data/{test_app → spec/test_app}/views/popup_two.erb +0 -0
  22. data/{test_app → spec/test_app}/views/postback.erb +0 -0
  23. data/{test_app → spec/test_app}/views/tables.erb +0 -0
  24. data/{test_app → spec/test_app}/views/with_html.erb +0 -0
  25. data/{test_app → spec/test_app}/views/with_html_entities.erb +0 -0
  26. data/{test_app → spec/test_app}/views/with_js.erb +0 -0
  27. data/{test_app → spec/test_app}/views/with_scope.erb +0 -0
  28. data/{test_app → spec/test_app}/views/with_simple_html.erb +0 -0
  29. data/{test_app → spec/test_app}/views/within_frames.erb +0 -0
  30. data/{test_app → spec/test_app}/views/within_popups.erb +0 -0
  31. data/spec/test_name.spec.rb +47 -0
  32. metadata +142 -121
  33. data/lib/capybara_minitest_spec/matcher.rb +0 -126
  34. data/test/capybara_node_matchers_spec.rb +0 -471
  35. data/test/custom_matcher_spec.rb +0 -29
  36. data/test/matcher_spec.rb +0 -45
  37. data/test/spec_helper.rb +0 -14
  38. data/test_app/driver.rb +0 -297
  39. data/test_app/fixtures/capybara.jpg +0 -3
  40. data/test_app/fixtures/test_file.txt +0 -1
  41. data/test_app/public/test.js +0 -43
  42. data/test_app/session.rb +0 -154
  43. data/test_app/session/all_spec.rb +0 -78
  44. data/test_app/session/attach_file_spec.rb +0 -73
  45. data/test_app/session/check_spec.rb +0 -65
  46. data/test_app/session/choose_spec.rb +0 -26
  47. data/test_app/session/click_button_spec.rb +0 -304
  48. data/test_app/session/click_link_or_button_spec.rb +0 -36
  49. data/test_app/session/click_link_spec.rb +0 -119
  50. data/test_app/session/current_host_spec.rb +0 -68
  51. data/test_app/session/current_url_spec.rb +0 -15
  52. data/test_app/session/fill_in_spec.rb +0 -125
  53. data/test_app/session/find_button_spec.rb +0 -18
  54. data/test_app/session/find_by_id_spec.rb +0 -18
  55. data/test_app/session/find_field_spec.rb +0 -26
  56. data/test_app/session/find_link_spec.rb +0 -19
  57. data/test_app/session/find_spec.rb +0 -149
  58. data/test_app/session/first_spec.rb +0 -105
  59. data/test_app/session/has_button_spec.rb +0 -32
  60. data/test_app/session/has_content_spec.rb +0 -106
  61. data/test_app/session/has_css_spec.rb +0 -243
  62. data/test_app/session/has_field_spec.rb +0 -192
  63. data/test_app/session/has_link_spec.rb +0 -37
  64. data/test_app/session/has_select_spec.rb +0 -129
  65. data/test_app/session/has_selector_spec.rb +0 -129
  66. data/test_app/session/has_table_spec.rb +0 -96
  67. data/test_app/session/has_xpath_spec.rb +0 -123
  68. data/test_app/session/headers.rb +0 -19
  69. data/test_app/session/javascript.rb +0 -289
  70. data/test_app/session/response_code.rb +0 -19
  71. data/test_app/session/select_spec.rb +0 -113
  72. data/test_app/session/text_spec.rb +0 -19
  73. data/test_app/session/uncheck_spec.rb +0 -21
  74. data/test_app/session/unselect_spec.rb +0 -61
  75. data/test_app/session/within_spec.rb +0 -178
@@ -1,19 +0,0 @@
1
- shared_examples_for "session with status code support" do
2
- describe '#status_code' do
3
- it "should return response codes" do
4
- @session.visit('/with_simple_html')
5
- @session.status_code.should == 200
6
- end
7
- end
8
- end
9
-
10
- shared_examples_for "session without status code support" do
11
- describe "#status_code" do
12
- before{ @session.visit('/with_simple_html') }
13
- it "should raise an error" do
14
- running {
15
- @session.status_code
16
- }.should raise_error(Capybara::NotSupportedByDriverError)
17
- end
18
- end
19
- end
@@ -1,113 +0,0 @@
1
- shared_examples_for "select" do
2
- describe "#select" do
3
- before do
4
- @session.visit('/form')
5
- end
6
-
7
- it "should return value of the first option" do
8
- @session.find_field('Title').value.should == 'Mrs'
9
- end
10
-
11
- it "should return value of the selected option" do
12
- @session.select("Miss", :from => 'Title')
13
- @session.find_field('Title').value.should == 'Miss'
14
- end
15
-
16
- it "should return the value attribute rather than content if present" do
17
- @session.find_field('Locale').value.should == 'en'
18
- end
19
-
20
- it "should select an option from a select box by id" do
21
- @session.select("Finish", :from => 'form_locale')
22
- @session.click_button('awesome')
23
- extract_results(@session)['locale'].should == 'fi'
24
- end
25
-
26
- it "should select an option from a select box by label" do
27
- @session.select("Finish", :from => 'Locale')
28
- @session.click_button('awesome')
29
- extract_results(@session)['locale'].should == 'fi'
30
- end
31
-
32
- it "should select an option without giving a select box" do
33
- @session.select("Mr")
34
- @session.click_button('awesome')
35
- extract_results(@session)['title'].should == 'Mr'
36
- end
37
-
38
- it "should favour exact matches to option labels" do
39
- @session.select("Mr", :from => 'Title')
40
- @session.click_button('awesome')
41
- extract_results(@session)['title'].should == 'Mr'
42
- end
43
-
44
- it "should escape quotes" do
45
- @session.select("John's made-up language", :from => 'Locale')
46
- @session.click_button('awesome')
47
- extract_results(@session)['locale'].should == 'jo'
48
- end
49
-
50
- it "should obey from" do
51
- @session.select("Miss", :from => "Other title")
52
- @session.click_button('awesome')
53
- results = extract_results(@session)
54
- results['other_title'].should == "Miss"
55
- results['title'].should_not == "Miss"
56
- end
57
-
58
- it "show match labels with preceding or trailing whitespace" do
59
- @session.select("Lojban", :from => 'Locale')
60
- @session.click_button('awesome')
61
- extract_results(@session)['locale'].should == 'jbo'
62
- end
63
-
64
- context "with a locator that doesn't exist" do
65
- it "should raise an error" do
66
- running { @session.select('foo', :from => 'does not exist') }.should raise_error(Capybara::ElementNotFound)
67
- end
68
- end
69
-
70
- context "with an option that doesn't exist" do
71
- it "should raise an error" do
72
- running { @session.select('Does not Exist', :from => 'form_locale') }.should raise_error(Capybara::ElementNotFound)
73
- end
74
- end
75
-
76
- context "with multiple select" do
77
- it "should return an empty value" do
78
- @session.find_field('Language').value.should == []
79
- end
80
-
81
- it "should return value of the selected options" do
82
- @session.select("Ruby", :from => 'Language')
83
- @session.select("Javascript", :from => 'Language')
84
- @session.find_field('Language').value.should include('Ruby', 'Javascript')
85
- end
86
-
87
- it "should select one option" do
88
- @session.select("Ruby", :from => 'Language')
89
- @session.click_button('awesome')
90
- extract_results(@session)['languages'].should == ['Ruby']
91
- end
92
-
93
- it "should select multiple options" do
94
- @session.select("Ruby", :from => 'Language')
95
- @session.select("Javascript", :from => 'Language')
96
- @session.click_button('awesome')
97
- extract_results(@session)['languages'].should include('Ruby', 'Javascript')
98
- end
99
-
100
- it "should remain selected if already selected" do
101
- @session.select("Ruby", :from => 'Language')
102
- @session.select("Javascript", :from => 'Language')
103
- @session.select("Ruby", :from => 'Language')
104
- @session.click_button('awesome')
105
- extract_results(@session)['languages'].should include('Ruby', 'Javascript')
106
- end
107
-
108
- it "should return value attribute rather than content if present" do
109
- @session.find_field('Underwear').value.should include('thermal')
110
- end
111
- end
112
- end
113
- end
@@ -1,19 +0,0 @@
1
- shared_examples_for "text" do
2
- describe '#text' do
3
- before do
4
- @session.visit('/with_simple_html')
5
- end
6
-
7
- it "should print the text of the page" do
8
- @session.text.should == 'Bar'
9
- end
10
-
11
- context "with css as default selector" do
12
- before { Capybara.default_selector = :css }
13
- it "should print the text of the page" do
14
- @session.text.should == 'Bar'
15
- end
16
- after { Capybara.default_selector = :xpath }
17
- end
18
- end
19
- end
@@ -1,21 +0,0 @@
1
- shared_examples_for "uncheck" do
2
- describe "#uncheck" do
3
- before do
4
- @session.visit('/form')
5
- end
6
-
7
- it "should uncheck a checkbox by id" do
8
- @session.uncheck("form_pets_hamster")
9
- @session.click_button('awesome')
10
- extract_results(@session)['pets'].should include('dog')
11
- extract_results(@session)['pets'].should_not include('hamster')
12
- end
13
-
14
- it "should uncheck a checkbox by label" do
15
- @session.uncheck("Hamster")
16
- @session.click_button('awesome')
17
- extract_results(@session)['pets'].should include('dog')
18
- extract_results(@session)['pets'].should_not include('hamster')
19
- end
20
- end
21
- end
@@ -1,61 +0,0 @@
1
- shared_examples_for "unselect" do
2
- describe "#unselect" do
3
- before do
4
- @session.visit('/form')
5
- end
6
-
7
- context "with multiple select" do
8
- it "should unselect an option from a select box by id" do
9
- @session.unselect('Commando', :from => 'form_underwear')
10
- @session.click_button('awesome')
11
- extract_results(@session)['underwear'].should include('Briefs', 'Boxer Briefs')
12
- extract_results(@session)['underwear'].should_not include('Commando')
13
- end
14
-
15
- it "should unselect an option without a select box" do
16
- @session.unselect('Commando')
17
- @session.click_button('awesome')
18
- extract_results(@session)['underwear'].should include('Briefs', 'Boxer Briefs')
19
- extract_results(@session)['underwear'].should_not include('Commando')
20
- end
21
-
22
- it "should unselect an option from a select box by label" do
23
- @session.unselect('Commando', :from => 'Underwear')
24
- @session.click_button('awesome')
25
- extract_results(@session)['underwear'].should include('Briefs', 'Boxer Briefs')
26
- extract_results(@session)['underwear'].should_not include('Commando')
27
- end
28
-
29
- it "should favour exact matches to option labels" do
30
- @session.unselect("Briefs", :from => 'Underwear')
31
- @session.click_button('awesome')
32
- extract_results(@session)['underwear'].should include('Commando', 'Boxer Briefs')
33
- extract_results(@session)['underwear'].should_not include('Briefs')
34
- end
35
-
36
- it "should escape quotes" do
37
- @session.unselect("Frenchman's Pantalons", :from => 'Underwear')
38
- @session.click_button('awesome')
39
- extract_results(@session)['underwear'].should_not include("Frenchman's Pantalons")
40
- end
41
- end
42
-
43
- context "with single select" do
44
- it "should raise an error" do
45
- running { @session.unselect("English", :from => 'form_locale') }.should raise_error(Capybara::UnselectNotAllowed)
46
- end
47
- end
48
-
49
- context "with a locator that doesn't exist" do
50
- it "should raise an error" do
51
- running { @session.unselect('foo', :from => 'does not exist') }.should raise_error(Capybara::ElementNotFound)
52
- end
53
- end
54
-
55
- context "with an option that doesn't exist" do
56
- it "should raise an error" do
57
- running { @session.unselect('Does not Exist', :from => 'form_underwear') }.should raise_error(Capybara::ElementNotFound)
58
- end
59
- end
60
- end
61
- end
@@ -1,178 +0,0 @@
1
- shared_examples_for "within" do
2
- describe '#within' do
3
- before do
4
- @session.visit('/with_scope')
5
- end
6
-
7
- context "with CSS selector" do
8
- it "should click links in the given scope" do
9
- @session.within(:css, "ul li[contains('With Simple HTML')]") do
10
- @session.click_link('Go')
11
- end
12
- @session.body.should include('Bar')
13
- end
14
-
15
- it "should assert content in the given scope" do
16
- @session.within(:css, "#for_foo") do
17
- @session.should_not have_content('First Name')
18
- end
19
- @session.should have_content('First Name')
20
- end
21
-
22
- it "should accept additional options" do
23
- @session.within(:css, "ul li", :text => 'With Simple HTML') do
24
- @session.click_link('Go')
25
- end
26
- @session.body.should include('Bar')
27
- end
28
- end
29
-
30
- context "with XPath selector" do
31
- it "should click links in the given scope" do
32
- @session.within(:xpath, "//li[contains(.,'With Simple HTML')]") do
33
- @session.click_link('Go')
34
- end
35
- @session.body.should include('Bar')
36
- end
37
- end
38
-
39
- context "with the default selector" do
40
- it "should use XPath" do
41
- @session.within("//li[contains(., 'With Simple HTML')]") do
42
- @session.click_link('Go')
43
- end
44
- @session.body.should include('Bar')
45
- end
46
- end
47
-
48
- context "with Node rather than selector" do
49
- it "should click links in the given scope" do
50
- node_of_interest = @session.find(:css, "ul li[contains('With Simple HTML')]")
51
-
52
- @session.within(node_of_interest) do
53
- @session.click_link('Go')
54
- end
55
- @session.body.should include('Bar')
56
- end
57
- end
58
-
59
- context "with the default selector set to CSS" do
60
- before { Capybara.default_selector = :css }
61
- it "should use CSS" do
62
- @session.within("ul li[contains('With Simple HTML')]") do
63
- @session.click_link('Go')
64
- end
65
- @session.body.should include('Bar')
66
- end
67
- after { Capybara.default_selector = :xpath }
68
- end
69
-
70
- context "with click_link" do
71
- it "should click links in the given scope" do
72
- @session.within("//li[contains(.,'With Simple HTML')]") do
73
- @session.click_link('Go')
74
- end
75
- @session.body.should include('Bar')
76
- end
77
-
78
- context "with nested scopes" do
79
- it "should respect the inner scope" do
80
- @session.within("//div[@id='for_bar']") do
81
- @session.within(".//li[contains(.,'Bar')]") do
82
- @session.click_link('Go')
83
- end
84
- end
85
- @session.body.should include('Another World')
86
- end
87
-
88
- it "should respect the outer scope" do
89
- @session.within("//div[@id='another_foo']") do
90
- @session.within(".//li[contains(.,'With Simple HTML')]") do
91
- @session.click_link('Go')
92
- end
93
- end
94
- @session.body.should include('Hello world')
95
- end
96
- end
97
-
98
- it "should raise an error if the scope is not found on the page" do
99
- running {
100
- @session.within("//div[@id='doesnotexist']") do
101
- end
102
- }.should raise_error(Capybara::ElementNotFound)
103
- end
104
-
105
- it "should restore the scope when an error is raised" do
106
- running {
107
- @session.within("//div[@id='for_bar']") do
108
- running {
109
- running {
110
- @session.within(".//div[@id='doesnotexist']") do
111
- end
112
- }.should raise_error(Capybara::ElementNotFound)
113
- }.should_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(false)
114
- end
115
- }.should_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(true)
116
- end
117
- end
118
-
119
- context "with forms" do
120
- it "should fill in a field and click a button" do
121
- @session.within("//li[contains(.,'Bar')]") do
122
- @session.click_button('Go')
123
- end
124
- extract_results(@session)['first_name'].should == 'Peter'
125
- @session.visit('/with_scope')
126
- @session.within("//li[contains(.,'Bar')]") do
127
- @session.fill_in('First Name', :with => 'Dagobert')
128
- @session.click_button('Go')
129
- end
130
- extract_results(@session)['first_name'].should == 'Dagobert'
131
- end
132
- end
133
- end
134
-
135
- describe '#within_fieldset' do
136
- before do
137
- @session.visit('/fieldsets')
138
- end
139
-
140
- it "should restrict scope to a fieldset given by id" do
141
- @session.within_fieldset("villain_fieldset") do
142
- @session.fill_in("Name", :with => 'Goldfinger')
143
- @session.click_button("Create")
144
- end
145
- extract_results(@session)['villain_name'].should == 'Goldfinger'
146
- end
147
-
148
- it "should restrict scope to a fieldset given by legend" do
149
- @session.within_fieldset("Villain") do
150
- @session.fill_in("Name", :with => 'Goldfinger')
151
- @session.click_button("Create")
152
- end
153
- extract_results(@session)['villain_name'].should == 'Goldfinger'
154
- end
155
- end
156
-
157
- describe '#within_table' do
158
- before do
159
- @session.visit('/tables')
160
- end
161
-
162
- it "should restrict scope to a fieldset given by id" do
163
- @session.within_table("girl_table") do
164
- @session.fill_in("Name", :with => 'Christmas')
165
- @session.click_button("Create")
166
- end
167
- extract_results(@session)['girl_name'].should == 'Christmas'
168
- end
169
-
170
- it "should restrict scope to a fieldset given by legend" do
171
- @session.within_table("Villain") do
172
- @session.fill_in("Name", :with => 'Quantum')
173
- @session.click_button("Create")
174
- end
175
- extract_results(@session)['villain_name'].should == 'Quantum'
176
- end
177
- end
178
- end