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,149 +0,0 @@
1
- shared_examples_for "find" do
2
- describe '#find' do
3
- before do
4
- @session.visit('/with_html')
5
- end
6
-
7
- after do
8
- Capybara::Selector.remove(:monkey)
9
- end
10
-
11
- it "should find the first element using the given locator" do
12
- @session.find('//h1').text.should == 'This is a test'
13
- @session.find("//input[@id='test_field']")[:value].should == 'monkey'
14
- end
15
-
16
- it "should find the first element using the given locator and options" do
17
- @session.find('//a', :text => 'Redirect')[:id].should == 'red'
18
- @session.find(:css, 'a', :text => 'A link')[:title].should == 'twas a fine link'
19
- end
20
-
21
- describe 'the returned node' do
22
- it "should act like a session object" do
23
- @session.visit('/form')
24
- @form = @session.find(:css, '#get-form')
25
- @form.should have_field('Middle Name')
26
- @form.should have_no_field('Languages')
27
- @form.fill_in('Middle Name', :with => 'Monkey')
28
- @form.click_button('med')
29
- extract_results(@session)['middle_name'].should == 'Monkey'
30
- end
31
-
32
- it "should scope CSS selectors" do
33
- @session.find(:css, '#second').should have_no_css('h1')
34
- end
35
-
36
- it "should have a reference to its parent if there is one" do
37
- @node = @session.find(:css, '#first')
38
- @node.parent.should == @node.session.document
39
- @node.find('a').parent.should == @node
40
- end
41
- end
42
-
43
- context "with css selectors" do
44
- it "should find the first element using the given locator" do
45
- @session.find(:css, 'h1').text.should == 'This is a test'
46
- @session.find(:css, "input[id='test_field']")[:value].should == 'monkey'
47
- end
48
- end
49
-
50
- context "with id selectors" do
51
- it "should find the first element using the given locator" do
52
- @session.find(:id, 'john_monkey').text.should == 'Monkey John'
53
- @session.find(:id, 'red').text.should == 'Redirect'
54
- @session.find(:red).text.should == 'Redirect'
55
- end
56
- end
57
-
58
- context "with xpath selectors" do
59
- it "should find the first element using the given locator" do
60
- @session.find(:xpath, '//h1').text.should == 'This is a test'
61
- @session.find(:xpath, "//input[@id='test_field']")[:value].should == 'monkey'
62
- end
63
- end
64
-
65
- context "with custom selector" do
66
- it "should use the custom selector" do
67
- Capybara.add_selector(:monkey) do
68
- xpath { |name| ".//*[@id='#{name}_monkey']" }
69
- end
70
- @session.find(:monkey, 'john').text.should == 'Monkey John'
71
- @session.find(:monkey, 'paul').text.should == 'Monkey Paul'
72
- end
73
- end
74
-
75
- context "with custom selector with :for option" do
76
- it "should use the selector when it matches the :for option" do
77
- Capybara.add_selector(:monkey) do
78
- xpath { |num| ".//*[contains(@id, 'monkey')][#{num}]" }
79
- match { |value| value.is_a?(Fixnum) }
80
- end
81
- @session.find(:monkey, '2').text.should == 'Monkey Paul'
82
- @session.find(1).text.should == 'Monkey John'
83
- @session.find(2).text.should == 'Monkey Paul'
84
- @session.find('//h1').text.should == 'This is a test'
85
- end
86
- end
87
-
88
- context "with custom selector with failure_message option" do
89
- it "should raise an error with the failure message if the element is not found" do
90
- Capybara.add_selector(:monkey) do
91
- xpath { |num| ".//*[contains(@id, 'monkey')][#{num}]" }
92
- failure_message { |node, selector| node.all(".//*[contains(@id, 'monkey')]").map { |node| node.text }.sort.join(', ') }
93
- end
94
- running do
95
- @session.find(:monkey, '14').text.should == 'Monkey Paul'
96
- end.should raise_error(Capybara::ElementNotFound, "Monkey John, Monkey Paul")
97
- end
98
-
99
- it "should pass the selector as the second argument" do
100
- Capybara.add_selector(:monkey) do
101
- xpath { |num| ".//*[contains(@id, 'monkey')][#{num}]" }
102
- failure_message { |node, selector| selector.name.to_s + ': ' + selector.locator + ' - ' + node.all(".//*[contains(@id, 'monkey')]").map { |node| node.text }.sort.join(', ') }
103
- end
104
- running do
105
- @session.find(:monkey, '14').text.should == 'Monkey Paul'
106
- end.should raise_error(Capybara::ElementNotFound, "monkey: 14 - Monkey John, Monkey Paul")
107
- end
108
- end
109
-
110
- context "with css as default selector" do
111
- before { Capybara.default_selector = :css }
112
- it "should find the first element using the given locator" do
113
- @session.find('h1').text.should == 'This is a test'
114
- @session.find("input[id='test_field']")[:value].should == 'monkey'
115
- end
116
- after { Capybara.default_selector = :xpath }
117
- end
118
-
119
- it "should raise ElementNotFound with specified fail message if nothing was found" do
120
- running do
121
- @session.find(:xpath, '//div[@id="nosuchthing"]', :message => 'arghh').should be_nil
122
- end.should raise_error(Capybara::ElementNotFound, "arghh")
123
- end
124
-
125
- it "should raise ElementNotFound with a useful default message if nothing was found" do
126
- running do
127
- @session.find(:xpath, '//div[@id="nosuchthing"]').should be_nil
128
- end.should raise_error(Capybara::ElementNotFound, "Unable to find xpath \"//div[@id=\\\"nosuchthing\\\"]\"")
129
- end
130
-
131
- it "should accept an XPath instance and respect the order of paths" do
132
- @session.visit('/form')
133
- @xpath = XPath::HTML.fillable_field('Name')
134
- @session.find(@xpath).value.should == 'John Smith'
135
- end
136
-
137
- context "within a scope" do
138
- before do
139
- @session.visit('/with_scope')
140
- end
141
-
142
- it "should find the first element using the given locator" do
143
- @session.within(:xpath, "//div[@id='for_bar']") do
144
- @session.find('.//li').text.should =~ /With Simple HTML/
145
- end
146
- end
147
- end
148
- end
149
- end
@@ -1,105 +0,0 @@
1
- shared_examples_for "first" do
2
- describe '#first' do
3
- before do
4
- @session.visit('/with_html')
5
- end
6
-
7
- it "should find the first element using the given locator" do
8
- @session.first('//h1').text.should == 'This is a test'
9
- @session.first("//input[@id='test_field']")[:value].should == 'monkey'
10
- end
11
-
12
- it "should return nil when nothing was found" do
13
- @session.first('//div[@id="nosuchthing"]').should be_nil
14
- end
15
-
16
- it "should accept an XPath instance" do
17
- @session.visit('/form')
18
- @xpath = XPath::HTML.fillable_field('Name')
19
- @session.first(@xpath).value.should == 'John Smith'
20
- end
21
-
22
- context "with css selectors" do
23
- it "should find the first element using the given selector" do
24
- @session.first(:css, 'h1').text.should == 'This is a test'
25
- @session.first(:css, "input[id='test_field']")[:value].should == 'monkey'
26
- end
27
- end
28
-
29
- context "with xpath selectors" do
30
- it "should find the first element using the given locator" do
31
- @session.first(:xpath, '//h1').text.should == 'This is a test'
32
- @session.first(:xpath, "//input[@id='test_field']")[:value].should == 'monkey'
33
- end
34
- end
35
-
36
- context "with css as default selector" do
37
- before { Capybara.default_selector = :css }
38
- it "should find the first element using the given locator" do
39
- @session.first('h1').text.should == 'This is a test'
40
- @session.first("input[id='test_field']")[:value].should == 'monkey'
41
- end
42
- after { Capybara.default_selector = :xpath }
43
- end
44
-
45
- context "with visible filter" do
46
- after { Capybara.ignore_hidden_elements = false }
47
- it "should only find visible nodes if true given" do
48
- @session.first(:css, "a#invisible").should_not be_nil
49
- @session.first(:css, "a#invisible", :visible => true).should be_nil
50
- Capybara.ignore_hidden_elements = true
51
- @session.first(:css, "a#invisible").should be_nil
52
- end
53
-
54
- it "should include invisible nodes if false given" do
55
- Capybara.ignore_hidden_elements = true
56
- @session.first(:css, "a#invisible", :visible => false).should_not be_nil
57
- @session.first(:css, "a#invisible").should be_nil
58
- end
59
- end
60
-
61
- context "with prefer visible elements" do
62
- it "should find invisible elements if no visible element exists" do
63
- @session.first(:css, 'a#invisible')[:id].should == 'invisible'
64
- end
65
-
66
- it "should prefer visible elements over invisible elements" do
67
- @session.first(:css, 'a.visibility')[:id].should == 'visible'
68
- end
69
-
70
- it "should return the first invisible element if no visible elements exist" do
71
- @session.first(:css, 'a.hidden')[:id].should == 'first_invisble'
72
- end
73
-
74
- it "find visible links normally" do
75
- @session.first(:css, 'a#visible')[:id].should == 'visible'
76
- end
77
- end
78
-
79
- context "without prefer visible elements" do
80
- before { Capybara.prefer_visible_elements = false }
81
-
82
- it "should find invisible elements if no visible element exists" do
83
- @session.first(:css, 'a#invisible')[:id].should == 'invisible'
84
- end
85
-
86
- it "should not prefer visible elements over invisible elements" do
87
- @session.first(:css, 'a.visibility')[:id].should == 'invisible'
88
- end
89
-
90
- after { Capybara.prefer_visible_elements = true }
91
- end
92
-
93
- context "within a scope" do
94
- before do
95
- @session.visit('/with_scope')
96
- end
97
-
98
- it "should find the first element using the given locator" do
99
- @session.within(:xpath, "//div[@id='for_bar']") do
100
- @session.first('.//form').should_not be_nil
101
- end
102
- end
103
- end
104
- end
105
- end
@@ -1,32 +0,0 @@
1
- shared_examples_for "has_button" do
2
- describe '#has_button?' do
3
- before do
4
- @session.visit('/form')
5
- end
6
-
7
- it "should be true if the given button is on the page" do
8
- @session.should have_button('med')
9
- @session.should have_button('crap321')
10
- end
11
-
12
- it "should be false if the given button is not on the page" do
13
- @session.should_not have_button('monkey')
14
- end
15
- end
16
-
17
- describe '#has_no_button?' do
18
- before do
19
- @session.visit('/form')
20
- end
21
-
22
- it "should be true if the given button is on the page" do
23
- @session.should_not have_no_button('med')
24
- @session.should_not have_no_button('crap321')
25
- end
26
-
27
- it "should be false if the given button is not on the page" do
28
- @session.should have_no_button('monkey')
29
- end
30
- end
31
- end
32
-
@@ -1,106 +0,0 @@
1
- shared_examples_for "has_content" do
2
- describe '#has_content?' do
3
- it "should be true if the given content is on the page at least once" do
4
- @session.visit('/with_html')
5
- @session.should have_content('est')
6
- @session.should have_content('Lorem')
7
- @session.should have_content('Redirect')
8
- end
9
-
10
- it "should be true if scoped to an element which has the content" do
11
- @session.visit('/with_html')
12
- @session.within("//a[@title='awesome title']") do
13
- @session.should have_content('labore')
14
- end
15
- end
16
-
17
- it "should be false if scoped to an element which does not have the content" do
18
- @session.visit('/with_html')
19
- @session.within("//a[@title='awesome title']") do
20
- @session.should_not have_content('monkey')
21
- end
22
- end
23
-
24
- it "should ignore tags" do
25
- @session.visit('/with_html')
26
- @session.should_not have_content('exercitation <a href="/foo" id="foo">ullamco</a> laboris')
27
- @session.should have_content('exercitation ullamco laboris')
28
- end
29
-
30
- it "should ignore extra whitespace and newlines" do
31
- @session.visit('/with_html')
32
- @session.should have_content('text with whitespace')
33
- end
34
-
35
- it "should be false if the given content is not on the page" do
36
- @session.visit('/with_html')
37
- @session.should_not have_content('xxxxyzzz')
38
- @session.should_not have_content('monkey')
39
- end
40
-
41
- it 'should handle single quotes in the content' do
42
- @session.visit('/with-quotes')
43
- @session.should have_content("can't")
44
- end
45
-
46
- it 'should handle double quotes in the content' do
47
- @session.visit('/with-quotes')
48
- @session.should have_content(%q{"No," he said})
49
- end
50
-
51
- it 'should handle mixed single and double quotes in the content' do
52
- @session.visit('/with-quotes')
53
- @session.should have_content(%q{"you can't do that."})
54
- end
55
- end
56
-
57
- describe '#has_no_content?' do
58
- it "should be false if the given content is on the page at least once" do
59
- @session.visit('/with_html')
60
- @session.should_not have_no_content('est')
61
- @session.should_not have_no_content('Lorem')
62
- @session.should_not have_no_content('Redirect')
63
- end
64
-
65
- it "should be false if scoped to an element which has the content" do
66
- @session.visit('/with_html')
67
- @session.within("//a[@title='awesome title']") do
68
- @session.should_not have_no_content('labore')
69
- end
70
- end
71
-
72
- it "should be true if scoped to an element which does not have the content" do
73
- @session.visit('/with_html')
74
- @session.within("//a[@title='awesome title']") do
75
- @session.should have_no_content('monkey')
76
- end
77
- end
78
-
79
- it "should ignore tags" do
80
- @session.visit('/with_html')
81
- @session.should have_no_content('exercitation <a href="/foo" id="foo">ullamco</a> laboris')
82
- @session.should_not have_no_content('exercitation ullamco laboris')
83
- end
84
-
85
- it "should be true if the given content is not on the page" do
86
- @session.visit('/with_html')
87
- @session.should have_no_content('xxxxyzzz')
88
- @session.should have_no_content('monkey')
89
- end
90
-
91
- it 'should handle single quotes in the content' do
92
- @session.visit('/with-quotes')
93
- @session.should_not have_no_content("can't")
94
- end
95
-
96
- it 'should handle double quotes in the content' do
97
- @session.visit('/with-quotes')
98
- @session.should_not have_no_content(%q{"No," he said})
99
- end
100
-
101
- it 'should handle mixed single and double quotes in the content' do
102
- @session.visit('/with-quotes')
103
- @session.should_not have_no_content(%q{"you can't do that."})
104
- end
105
- end
106
- end
@@ -1,243 +0,0 @@
1
- shared_examples_for "has_css" do
2
- describe '#has_css?' do
3
- before do
4
- @session.visit('/with_html')
5
- end
6
-
7
- it "should be true if the given selector is on the page" do
8
- @session.should have_css("p")
9
- @session.should have_css("p a#foo")
10
- end
11
-
12
- it "should be false if the given selector is not on the page" do
13
- @session.should_not have_css("abbr")
14
- @session.should_not have_css("p a#doesnotexist")
15
- @session.should_not have_css("p.nosuchclass")
16
- end
17
-
18
- it "should respect scopes" do
19
- @session.within "//p[@id='first']" do
20
- @session.should have_css("a#foo")
21
- @session.should_not have_css("a#red")
22
- end
23
- end
24
-
25
- context "with between" do
26
- it "should be true if the content occurs within the range given" do
27
- @session.should have_css("p", :between => 1..4)
28
- @session.should have_css("p a#foo", :between => 1..3)
29
- end
30
-
31
- it "should be false if the content occurs more or fewer times than range" do
32
- @session.should_not have_css("p", :between => 6..11 )
33
- @session.should_not have_css("p a#foo", :between => 4..7)
34
- end
35
-
36
- it "should be false if the content isn't on the page at all" do
37
- @session.should_not have_css("abbr", :between => 1..8)
38
- @session.should_not have_css("p a.doesnotexist", :between => 3..8)
39
- end
40
- end
41
-
42
- context "with count" do
43
- it "should be true if the content is on the page the given number of times" do
44
- @session.should have_css("p", :count => 3)
45
- @session.should have_css("p a#foo", :count => 1)
46
- end
47
-
48
- it "should be false if the content occurs the given number of times" do
49
- @session.should_not have_css("p", :count => 6)
50
- @session.should_not have_css("p a#foo", :count => 2)
51
- end
52
-
53
- it "should be false if the content isn't on the page at all" do
54
- @session.should_not have_css("abbr", :count => 2)
55
- @session.should_not have_css("p a.doesnotexist", :count => 1)
56
- end
57
-
58
- it "should coerce count to an integer" do
59
- @session.should have_css("p", :count => "3")
60
- @session.should have_css("p a#foo", :count => "1")
61
- end
62
- end
63
-
64
- context "with maximum" do
65
- it "should be true when content occurs same or fewer times than given" do
66
- @session.should have_css("h2.head", :maximum => 5) # edge case
67
- @session.should have_css("h2", :maximum => 10)
68
- end
69
-
70
- it "should be false when content occurs more times than given" do
71
- @session.should_not have_css("h2.head", :maximum => 4) # edge case
72
- @session.should_not have_css("h2", :maximum => 6)
73
- @session.should_not have_css("p", :maximum => 1)
74
- end
75
-
76
- it "should be false if the content isn't on the page at all" do
77
- @session.should_not have_css("abbr", :maximum => 2)
78
- @session.should_not have_css("p a.doesnotexist", :maximum => 1)
79
- end
80
-
81
- it "should coerce maximum to an integer" do
82
- @session.should have_css("h2.head", :maximum => "5") # edge case
83
- @session.should have_css("h2", :maximum => "10")
84
- end
85
- end
86
-
87
- context "with minimum" do
88
- it "should be true when content occurs same or more times than given" do
89
- @session.should have_css("h2.head", :minimum => 5) # edge case
90
- @session.should have_css("h2", :minimum => 3)
91
- end
92
-
93
- it "should be false when content occurs fewer times than given" do
94
- @session.should_not have_css("h2.head", :minimum => 6) # edge case
95
- @session.should_not have_css("h2", :minimum => 8)
96
- @session.should_not have_css("p", :minimum => 10)
97
- end
98
-
99
- it "should be false if the content isn't on the page at all" do
100
- @session.should_not have_css("abbr", :minimum => 2)
101
- @session.should_not have_css("p a.doesnotexist", :minimum => 7)
102
- end
103
-
104
- it "should coerce minimum to an integer" do
105
- @session.should have_css("h2.head", :minimum => "5") # edge case
106
- @session.should have_css("h2", :minimum => "3")
107
- end
108
- end
109
-
110
- context "with text" do
111
- it "should discard all matches where the given string is not contained" do
112
- @session.should have_css("p a", :text => "Redirect", :count => 1)
113
- @session.should_not have_css("p a", :text => "Doesnotexist")
114
- end
115
-
116
- it "should discard all matches where the given regexp is not matched" do
117
- @session.should have_css("p a", :text => /re[dab]i/i, :count => 1)
118
- @session.should_not have_css("p a", :text => /Red$/)
119
- end
120
- end
121
- end
122
-
123
- describe '#has_no_css?' do
124
- before do
125
- @session.visit('/with_html')
126
- end
127
-
128
- it "should be false if the given selector is on the page" do
129
- @session.should_not have_no_css("p")
130
- @session.should_not have_no_css("p a#foo")
131
- end
132
-
133
- it "should be true if the given selector is not on the page" do
134
- @session.should have_no_css("abbr")
135
- @session.should have_no_css("p a#doesnotexist")
136
- @session.should have_no_css("p.nosuchclass")
137
- end
138
-
139
- it "should respect scopes" do
140
- @session.within "//p[@id='first']" do
141
- @session.should_not have_no_css("a#foo")
142
- @session.should have_no_css("a#red")
143
- end
144
- end
145
-
146
- context "with between" do
147
- it "should be false if the content occurs within the range given" do
148
- @session.should_not have_no_css("p", :between => 1..4)
149
- @session.should_not have_no_css("p a#foo", :between => 1..3)
150
- end
151
-
152
- it "should be true if the content occurs more or fewer times than range" do
153
- @session.should have_no_css("p", :between => 6..11 )
154
- @session.should have_no_css("p a#foo", :between => 4..7)
155
- end
156
-
157
- it "should be true if the content isn't on the page at all" do
158
- @session.should have_no_css("abbr", :between => 1..8)
159
- @session.should have_no_css("p a.doesnotexist", :between => 3..8)
160
- end
161
- end
162
-
163
- context "with count" do
164
- it "should be false if the content is on the page the given number of times" do
165
- @session.should_not have_no_css("p", :count => 3)
166
- @session.should_not have_no_css("p a#foo", :count => 1)
167
- end
168
-
169
- it "should be true if the content is on the page the given number of times" do
170
- @session.should have_no_css("p", :count => 6)
171
- @session.should have_no_css("p a#foo", :count => 2)
172
- end
173
-
174
- it "should be true if the content isn't on the page at all" do
175
- @session.should have_no_css("abbr", :count => 2)
176
- @session.should have_no_css("p a.doesnotexist", :count => 1)
177
- end
178
-
179
- it "should coerce count to an integer" do
180
- @session.should_not have_no_css("p", :count => "3")
181
- @session.should_not have_no_css("p a#foo", :count => "1")
182
- end
183
- end
184
-
185
- context "with maximum" do
186
- it "should be false when content occurs same or fewer times than given" do
187
- @session.should_not have_no_css("h2.head", :maximum => 5) # edge case
188
- @session.should_not have_no_css("h2", :maximum => 10)
189
- end
190
-
191
- it "should be true when content occurs more times than given" do
192
- @session.should have_no_css("h2.head", :maximum => 4) # edge case
193
- @session.should have_no_css("h2", :maximum => 6)
194
- @session.should have_no_css("p", :maximum => 1)
195
- end
196
-
197
- it "should be true if the content isn't on the page at all" do
198
- @session.should have_no_css("abbr", :maximum => 5)
199
- @session.should have_no_css("p a.doesnotexist", :maximum => 10)
200
- end
201
-
202
- it "should coerce maximum to an integer" do
203
- @session.should_not have_no_css("h2.head", :maximum => "5") # edge case
204
- @session.should_not have_no_css("h2", :maximum => "10")
205
- end
206
- end
207
-
208
- context "with minimum" do
209
- it "should be false when content occurs more times than given" do
210
- @session.should_not have_no_css("h2.head", :minimum => 4) # edge case
211
- @session.should_not have_no_css("h2", :minimum => 3)
212
- end
213
-
214
- it "should be true when content occurs fewer times than given" do
215
- @session.should have_no_css("h2.head", :minimum => 6) # edge case
216
- @session.should have_no_css("h2", :minimum => 8)
217
- @session.should have_no_css("p", :minimum => 15)
218
- end
219
-
220
- it "should be true if the content isn't on the page at all" do
221
- @session.should have_no_css("abbr", :minimum => 5)
222
- @session.should have_no_css("p a.doesnotexist", :minimum => 10)
223
- end
224
-
225
- it "should coerce minimum to an integer" do
226
- @session.should_not have_no_css("h2.head", :minimum => "4") # edge case
227
- @session.should_not have_no_css("h2", :minimum => "3")
228
- end
229
- end
230
-
231
- context "with text" do
232
- it "should discard all matches where the given string is not contained" do
233
- @session.should_not have_no_css("p a", :text => "Redirect", :count => 1)
234
- @session.should have_no_css("p a", :text => "Doesnotexist")
235
- end
236
-
237
- it "should discard all matches where the given regexp is not matched" do
238
- @session.should_not have_no_css("p a", :text => /re[dab]i/i, :count => 1)
239
- @session.should have_no_css("p a", :text => /Red$/)
240
- end
241
- end
242
- end
243
- end