kelp 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ docs/_build
5
5
  .rvmrc
6
6
  doc
7
7
  .yardoc
8
+ examples/sinatra_app/features/step_definitions
data/Gemfile.lock CHANGED
@@ -1,9 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kelp (0.1.3)
4
+ kelp (0.1.5)
5
5
  capybara (>= 0.4.0)
6
- webrat
7
6
 
8
7
  GEM
9
8
  remote: http://rubygems.org/
@@ -37,13 +36,22 @@ GEM
37
36
  celerity (0.8.5)
38
37
  childprocess (0.1.4)
39
38
  ffi (~> 0.6.3)
39
+ cucumber (0.10.2)
40
+ builder (>= 2.1.2)
41
+ diff-lcs (>= 1.1.2)
42
+ gherkin (>= 2.3.5)
43
+ json (>= 1.4.6)
44
+ term-ansicolor (>= 1.0.5)
40
45
  culerity (0.2.12)
41
46
  diff-lcs (1.1.2)
42
47
  erubis (2.6.6)
43
48
  abstract (>= 1.0.0)
44
49
  ffi (0.6.3)
45
50
  rake (>= 0.8.7)
51
+ gherkin (2.3.5)
52
+ json (>= 1.4.6)
46
53
  i18n (0.5.0)
54
+ json (1.5.1)
47
55
  json_pure (1.4.6)
48
56
  mime-types (1.16)
49
57
  nokogiri (1.4.4)
@@ -81,6 +89,7 @@ GEM
81
89
  sinatra (1.1.0)
82
90
  rack (~> 1.1)
83
91
  tilt (~> 1.1)
92
+ term-ansicolor (1.0.5)
84
93
  thor (0.14.6)
85
94
  tilt (1.1)
86
95
  tzinfo (0.3.23)
@@ -97,6 +106,7 @@ PLATFORMS
97
106
  DEPENDENCIES
98
107
  bundler (~> 1.0)
99
108
  capybara (>= 0.4.0)
109
+ cucumber
100
110
  kelp!
101
111
  rcov
102
112
  rspec (>= 2.2.0)
data/History.md CHANGED
@@ -1,6 +1,14 @@
1
1
  Kelp History
2
2
  ============
3
3
 
4
+ 0.1.5
5
+ -----
6
+
7
+ - Added Rails generator for generating kelp_steps.rb with some predefined steps
8
+ - Included some cucumber self-tests, especially to test the generated steps
9
+ - Fixed scoping error in xpath_row_containing
10
+
11
+
4
12
  0.1.4
5
13
  -----
6
14
 
@@ -11,7 +19,7 @@ Kelp History
11
19
  0.1.3
12
20
  -----
13
21
 
14
- Messed up 0.1.4 release. Incorrectly requires webrat.
22
+ - Messed up 0.1.4 release. Incorrectly requires webrat.
15
23
 
16
24
 
17
25
  0.1.2
@@ -1,3 +1,5 @@
1
+ # app.rb
2
+
1
3
  require 'rubygems'
2
4
  require 'sinatra/base'
3
5
  require 'rack'
@@ -0,0 +1,6 @@
1
+ # config.ru
2
+
3
+ require 'rubygems'
4
+ require File.join(File.dirname(__FILE__), 'app.rb')
5
+
6
+ run TestApp
@@ -0,0 +1,27 @@
1
+ Feature: Dropdowns
2
+
3
+ Background:
4
+ Given I visit "/form"
5
+
6
+ Scenario: Dropdown should equal
7
+ Then the "Height" dropdown should equal "Average"
8
+
9
+ Scenario: Dropdown should include
10
+ Then the "Height" dropdown should include "Tall"
11
+ And the "Quotes" dropdown should include "Single 'quotes'"
12
+ And the "Height" dropdown should include:
13
+ | Short |
14
+ | Average |
15
+ | Tall |
16
+ And the "Quotes" dropdown should include:
17
+ | Single 'quotes' |
18
+ | "Double" quotes |
19
+ | 'Single' and "Double" quotes |
20
+
21
+ Scenario: Dropdown should not include
22
+ Then the "Height" dropdown should not include "Midget"
23
+ And the "Height" dropdown should not include:
24
+ | Dwarf |
25
+ | Behemoth |
26
+
27
+
@@ -0,0 +1,20 @@
1
+ # env.rb
2
+
3
+ require File.join(File.dirname(__FILE__), '..', '..', 'app.rb')
4
+ require 'capybara'
5
+ require 'capybara/cucumber'
6
+ require 'rspec/core'
7
+ require File.expand_path(File.dirname(__FILE__) + '../../../../../lib/kelp')
8
+
9
+ TestApp.set(:environment, :test)
10
+
11
+ Capybara.app = TestApp
12
+
13
+ class TestAppWorld
14
+ include Capybara
15
+ end
16
+
17
+ World do
18
+ TestAppWorld.new
19
+ end
20
+
@@ -0,0 +1,28 @@
1
+ Feature: Visibility
2
+
3
+ Background:
4
+ Given I visit "/home"
5
+
6
+ Scenario: Should or shouldn't see
7
+ Then I should see the following:
8
+ | Hello world |
9
+ | Goodbye world |
10
+
11
+ And I should not see the following:
12
+ | Goodbye cruel world |
13
+
14
+ Scenario: Should or shouldn't see in same row
15
+ Then I should see a table row containing:
16
+ | Eric | Edit |
17
+
18
+ And I should see table rows containing:
19
+ | John | 666-5555 | Edit |
20
+ | Graham "Quoted" | 555-4444 | Edit |
21
+
22
+ And I should not see a table row containing:
23
+ | Eric | Delete |
24
+
25
+ And I should not see table rows containing:
26
+ | John | Delete |
27
+ | Terry | Delete |
28
+
@@ -0,0 +1,4 @@
1
+ Given /^I visit "(.+)"$/ do |path|
2
+ visit path
3
+ end
4
+
@@ -64,6 +64,25 @@
64
64
  </form>
65
65
  </div>
66
66
 
67
+ <div id="checkbox_form">
68
+ <form action="/thanks" method="get">
69
+ <table>
70
+ <tr>
71
+ <td><label for="check_a">Apple</label></td>
72
+ <td><input id="check_a" type="checkbox"/></td>
73
+ </tr>
74
+ <tr>
75
+ <td><label for="check_b">Banana</label></td>
76
+ <td><input id="check_b" type="checkbox"/></td>
77
+ </tr>
78
+ <tr>
79
+ <td><label for="check_c">Carrot</label></td>
80
+ <td><input id="check_c" type="checkbox"/></td>
81
+ </tr>
82
+ </table>
83
+ </form>
84
+ </div>
85
+
67
86
  </body>
68
87
  </html>
69
88
 
@@ -25,7 +25,7 @@
25
25
  </div>
26
26
 
27
27
  <div id="tables">
28
- <table>
28
+ <table id="table_a">
29
29
  <thead>
30
30
  <tr> <th>Name</th> <th>Phone</th> <th>Action</th> </tr>
31
31
  </thead>
@@ -33,9 +33,16 @@
33
33
  <tr> <td>Eric</td> <td>555-4444</td> <td><a href="/edit1">Edit</a></td> </tr>
34
34
  <tr> <td>John</td> <td>666-5555</td> <td><a href="/edit2">Edit</a></td> </tr>
35
35
  <tr> <td>Terry</td> <td>777-6666</td> <td><a href="/edit3">Edit</a></td> </tr>
36
+ </tbody>
37
+ </table>
36
38
 
37
- <tr> <td>Eric "Quoted"</td> <td>555-4444</td> <td><a href="/edit1">Edit</a></td> </tr>
38
- <tr> <td>"John's" quo'ta'tions</td> <td>666-5555</td> <td><a href="/edit2">Edit</a></td> </tr>
39
+ <table id="table_b">
40
+ <thead>
41
+ <tr> <th>Name</th> <th>Phone</th> <th>Action</th> </tr>
42
+ </thead>
43
+ <tbody>
44
+ <tr> <td>Graham "Quoted"</td> <td>555-4444</td> <td><a href="/edit1">Edit</a></td> </tr>
45
+ <tr> <td>"Michael's" quo'ta'tions</td> <td>666-5555</td> <td><a href="/edit2">Edit</a></td> </tr>
39
46
  <tr> <td>Terry's "Big" thing</td> <td>777-6666</td> <td><a href="/edit3">Edit</a></td> </tr>
40
47
  </tbody>
41
48
  </table>
@@ -0,0 +1,14 @@
1
+ Feature: Kelp Step Definitions
2
+
3
+ As a Kelp developer
4
+ I want to be sure the step definitions Kelp provides work correctly
5
+
6
+ Scenario: Regression test
7
+ Given a sinatra application with the latest Kelp step definitions
8
+ When I run "cucumber features -q --no-color" in the sinatra app
9
+ Then the results should be:
10
+ """
11
+ 5 scenarios (5 passed)
12
+ 18 steps (18 passed)
13
+ """
14
+
@@ -0,0 +1,26 @@
1
+ # app_steps.rb
2
+
3
+ require 'fileutils'
4
+
5
+ Given /^a (\w+) application with the latest Kelp step definitions$/ do |platform|
6
+ app_dir = File.join(root_dir, 'examples', "#{platform}_app")
7
+ installed_steps = File.join(app_dir, 'features', 'step_definitions', 'kelp_steps.rb')
8
+ latest_steps = File.join(root_dir, 'rails_generators', 'kelp', 'templates', 'kelp_steps.rb')
9
+ # Remove the installed kelp_steps.rb, if any, then install the latest one
10
+ FileUtils.mkdir_p(File.dirname(installed_steps))
11
+ FileUtils.rm(installed_steps) if File.exists?(installed_steps)
12
+ FileUtils.cp_r(latest_steps, installed_steps)
13
+ end
14
+
15
+ When /^I run "(.+)" in the (\w+) app$/ do |command, platform|
16
+ command.gsub!('cucumber', "#{Cucumber::RUBY_BINARY} #{Cucumber::BINARY}")
17
+ app_dir = File.join(root_dir, 'examples', "#{platform}_app")
18
+ Dir.chdir(app_dir) do
19
+ @output = `#{command}`
20
+ end
21
+ end
22
+
23
+ Then /^the results should be:$/ do |expected_results|
24
+ @output.should include(expected_results)
25
+ end
26
+
@@ -0,0 +1,18 @@
1
+ # env.rb
2
+
3
+ require 'rubygems'
4
+
5
+ class KelpWorld
6
+ def self.root_dir
7
+ @root_dir ||= File.join(File.expand_path(File.dirname(__FILE__)), '..', '..')
8
+ end
9
+
10
+ def root_dir
11
+ KelpWorld.root_dir
12
+ end
13
+ end
14
+
15
+ World do
16
+ KelpWorld.new
17
+ end
18
+
data/kelp.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "kelp"
5
- s.version = "0.1.4"
5
+ s.version = "0.1.5"
6
6
  s.summary = "Cucumber helper methods"
7
7
  s.description = <<-EOS
8
8
  Kelp is a collection of helper methods for Cucumber to ease the process of
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.add_development_dependency 'rspec-rails'
21
21
  s.add_development_dependency 'rcov'
22
22
  s.add_development_dependency 'webrat'
23
+ s.add_development_dependency 'cucumber'
23
24
 
24
25
  s.files = `git ls-files`.split("\n")
25
26
  s.require_path = 'lib'
data/lib/kelp/dropdown.rb CHANGED
@@ -19,18 +19,22 @@ module Kelp
19
19
  # Capybara locator for the dropdown (the `select` element)
20
20
  # @param [String] value
21
21
  # Value you expect to see as the currently-selected option
22
+ # @param [Hash] scope
23
+ # Scoping keywords as understood by {#in_scope}
22
24
  #
23
- def dropdown_should_equal(dropdown, value)
24
- field = nice_find_field(dropdown)
25
- # See if there's a 'selected' option
26
- begin
27
- selected = field.find(:xpath, ".//option[@selected='selected']")
28
- # If not, find the option matching the first field value
29
- rescue Capybara::ElementNotFound
30
- first_value = xpath_sanitize(field.value.first)
31
- selected = field.find(:xpath, ".//option[@value=#{first_value}]")
25
+ def dropdown_should_equal(dropdown, value, scope={})
26
+ in_scope(scope) do
27
+ field = nice_find_field(dropdown)
28
+ # See if there's a 'selected' option
29
+ begin
30
+ selected = field.find(:xpath, ".//option[@selected='selected']")
31
+ # If not, find the option matching the first field value
32
+ rescue Capybara::ElementNotFound
33
+ first_value = xpath_sanitize(field.value.first)
34
+ selected = field.find(:xpath, ".//option[@value=#{first_value}]")
35
+ end
36
+ selected.text.should =~ /#{value}/
32
37
  end
33
- selected.text.should =~ /#{value}/
34
38
  end
35
39
 
36
40
 
@@ -191,12 +191,16 @@ module Kelp
191
191
  #
192
192
  # @param [Array] texts
193
193
  # Array of Strings that should appear in the same row
194
+ # @param [Hash] scope
195
+ # Scoping keywords as understood by {#in_scope}
194
196
  #
195
- def should_see_in_same_row(texts)
196
- if Kelp.driver == :capybara
197
- page.should have_xpath(xpath_row_containing(texts))
198
- elsif Kelp.driver == :webrat
199
- raise RuntimeError, "Not implemented yet"
197
+ def should_see_in_same_row(texts, scope={})
198
+ in_scope(scope) do
199
+ if Kelp.driver == :capybara
200
+ page.should have_xpath(xpath_row_containing(texts))
201
+ elsif Kelp.driver == :webrat
202
+ raise RuntimeError, "Not implemented yet"
203
+ end
200
204
  end
201
205
  end
202
206
 
@@ -211,14 +215,19 @@ module Kelp
211
215
  #
212
216
  # @param [Array] texts
213
217
  # Array of Strings that should not appear in the same row
218
+ # @param [Hash] scope
219
+ # Scoping keywords as understood by {#in_scope}
214
220
  #
215
- def should_not_see_in_same_row(texts)
216
- if Kelp.driver == :capybara
217
- page.should have_no_xpath(xpath_row_containing(texts))
218
- elsif Kelp.driver == :webrat
219
- raise RuntimeError, "Not implemented yet"
221
+ def should_not_see_in_same_row(texts, scope={})
222
+ in_scope(scope) do
223
+ if Kelp.driver == :capybara
224
+ page.should have_no_xpath(xpath_row_containing(texts))
225
+ elsif Kelp.driver == :webrat
226
+ raise RuntimeError, "Not implemented yet"
227
+ end
220
228
  end
221
229
  end
222
230
 
223
231
  end
224
232
  end
233
+
data/lib/kelp/xpath.rb CHANGED
@@ -2,13 +2,14 @@ module Kelp
2
2
  # This module defines helper methods for building XPath expressions.
3
3
  #
4
4
  module XPath
5
- # Return an XPath for any table row containing all strings in `texts`.
5
+ # Return an XPath for any table row containing all strings in `texts`,
6
+ # within the current context.
6
7
  def xpath_row_containing(texts)
7
8
  texts = [texts] if texts.class == String
8
9
  conditions = texts.collect do |text|
9
10
  "contains(., #{xpath_sanitize(text)})"
10
11
  end.join(' and ')
11
- return "//table//tr[#{conditions}]"
12
+ return ".//tr[#{conditions}]"
12
13
  end
13
14
 
14
15
  # Return the given text string in an XPath-safe form, with
@@ -0,0 +1,19 @@
1
+ # This generator adds Kelp steps to the step_definitions directory
2
+
3
+ generator_base = defined?(Rails) ? Rails::Generator::Base : RubiGen::Base
4
+
5
+ class KelpGenerator < generator_base
6
+ def manifest
7
+ record do |m|
8
+ m.directory 'features/step_definitions'
9
+ m.file 'kelp_steps.rb', 'features/step_definitions/kelp_steps.rb'
10
+ end
11
+ end
12
+
13
+ protected
14
+
15
+ def banner
16
+ "Usage: #{$0} kelp"
17
+ end
18
+
19
+ end
@@ -0,0 +1,148 @@
1
+ # kelp_steps.rb
2
+ #
3
+ # This file defines some generic step definitions that utilize the helper
4
+ # methods provided by Kelp. It is auto-generated by running:
5
+ #
6
+ # script/generate kelp
7
+ #
8
+ # from a Rails application. It's probably a good idea to avoid editing this
9
+ # file, since it may be overwritten by an upgraded kelp gem later. If you
10
+ # find an issues with these step definitions and think they can be improved,
11
+ # please create an issue on Github:
12
+ #
13
+ # http://github.com/wapcaplet/kelp/issues
14
+ #
15
+
16
+ require 'kelp'
17
+ World(Kelp::Visibility)
18
+ World(Kelp::Dropdown)
19
+
20
+ SHOULD_OR_NOT = /(should|should not)/
21
+ WITHIN = /(?: within "([^\"]+)")?/
22
+ STR = /([^\"]+)/
23
+
24
+ # Verify the presence or absence of multiple text strings in the page,
25
+ # or within a given context.
26
+ #
27
+ # With `should see`, fails if any of the strings are missing.
28
+ # With `should not see`, fails if any of the strings are present.
29
+ #
30
+ # `items` may be a Cucumber table, or a multi-line string. Examples:
31
+ #
32
+ # Then I should see the following:
33
+ # | First thing |
34
+ # | Next thing |
35
+ # | Last thing |
36
+ #
37
+ # Then I should see the following:
38
+ # """
39
+ # First thing
40
+ # Next thing
41
+ # Last thing
42
+ # """
43
+ #
44
+ Then /^I #{SHOULD_OR_NOT} see the following#{WITHIN}:$/ do |expect, selector, items|
45
+ if items.class == Cucumber::Ast::Table
46
+ strings = items.raw.flatten
47
+ else
48
+ strings = items.split("\n")
49
+ end
50
+ if expect == 'should'
51
+ should_see strings, :within => selector
52
+ else
53
+ should_not_see strings, :within => selector
54
+ end
55
+ end
56
+
57
+
58
+ # Verify that one or more table rows containing the correct values exist (or do
59
+ # not exist). Rows do not need to match exactly, and fields do not need to be
60
+ # in the same order.
61
+ Then /^I #{SHOULD_OR_NOT} see (?:a table row|table rows)#{WITHIN} containing:$/ do |expect, selector, rows|
62
+ rows.raw.each do |fields|
63
+ if expect == 'should'
64
+ should_see_in_same_row(fields, :within => selector)
65
+ else
66
+ should_not_see_in_same_row(fields, :within => selector)
67
+ end
68
+ end
69
+ end
70
+
71
+
72
+ # Verify that a dropdown has a given value selected. This verifies the visible
73
+ # value shown to the user, rather than the value attribute of the selected
74
+ # option element.
75
+ Then /^the "#{STR}" dropdown#{WITHIN} should equal "#{STR}"$/ do |dropdown, selector, value|
76
+ dropdown_should_equal(dropdown, value, :within => selector)
77
+ end
78
+
79
+
80
+ # Verify that a dropdown includes or doesn't include the given value.
81
+ Then /^the "#{STR}" dropdown#{WITHIN} #{SHOULD_OR_NOT} include "#{STR}"$/ do |dropdown, selector, expect, value|
82
+ if expect == 'should'
83
+ dropdown_should_include(dropdown, value, :within => selector)
84
+ else
85
+ dropdown_should_not_include(dropdown, value, :within => selector)
86
+ end
87
+ end
88
+
89
+
90
+ # Verify that a dropdown includes or doesn't include all values in the given table.
91
+ Then /^the "#{STR}" dropdown#{WITHIN} #{SHOULD_OR_NOT} include:$/ do |dropdown, selector, expect, values|
92
+ values.raw.flatten.each do |value|
93
+ if expect == 'should'
94
+ dropdown_should_include(dropdown, value, :within => selector)
95
+ else
96
+ dropdown_should_not_include(dropdown, value, :within => selector)
97
+ end
98
+ end
99
+ end
100
+
101
+
102
+ # Verify that a given field is empty or nil
103
+ Then /^the "#{STR}" field#{WITHIN} should be empty$/ do |field, selector|
104
+ with_scope(selector) do
105
+ field_should_be_empty field
106
+ end
107
+ end
108
+
109
+
110
+ # Verify multiple fields in a form, optionally restricted to a given selector.
111
+ # Fields may be text inputs or dropdowns
112
+ Then /^the fields#{WITHIN} should contain:$/ do |selector, fields|
113
+ fields_should_contain_within(selector, fields.rows_hash)
114
+ end
115
+
116
+
117
+ # Verify that expected text exists or does not exist in the same row as
118
+ # identifier text. This can be used to ensure the presence or absence of "Edit"
119
+ # or "Delete" links, or specific data associated with a row in a table.
120
+ Then /^I #{SHOULD_OR_NOT} see "#{STR}" next to "#{STR}"#{WITHIN}$/ do |expect, expected, identifier, selector|
121
+ with_scope(selector) do
122
+ if expect == 'should'
123
+ should_see_in_same_row [expected, identifier]
124
+ else
125
+ should_not_see_in_same_row [expected, identifier]
126
+ end
127
+ end
128
+ end
129
+
130
+
131
+ # Click a link in a table row that contains the given text.
132
+ # This can be used to click the "Edit" link for a specific record.
133
+ When /^I follow "#{STR}" next to "#{STR}"$/ do |link, identifier|
134
+ click_link_in_row(link, identifier)
135
+ end
136
+
137
+
138
+ # Verify that a checkbox in a certain table row is checked or unchecked
139
+ Then /^the "#{STR}" checkbox next to "#{STR}"#{WITHIN} should be (checked|unchecked)$/ do |checkbox, text, selector, state|
140
+ within(:xpath, xpath_row_containing(text)) do
141
+ if state == 'checked'
142
+ checkbox_should_be_checked(checkbox, text, :within => selector)
143
+ else
144
+ checkbox_should_not_be_checked(checkbox, text, :within => selector)
145
+ end
146
+ end
147
+ end
148
+
data/spec/spec_helper.rb CHANGED
@@ -6,7 +6,7 @@ require 'capybara/dsl'
6
6
  #require 'webrat'
7
7
 
8
8
  require 'kelp'
9
- require File.expand_path(File.dirname(__FILE__) + '/test_app/test_app')
9
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'examples', 'sinatra_app', 'app'))
10
10
 
11
11
  RSpec.configure do |config|
12
12
  config.include Capybara
@@ -185,9 +185,15 @@ describe Kelp::Visibility, "should_see_in_same_row" do
185
185
  should_see_in_same_row ["John", "Edit"]
186
186
  end
187
187
 
188
+ it "two strings are in the same row within a given scope" do
189
+ should_see_in_same_row ["Eric", "Edit"], :within => "#table_a"
190
+ should_see_in_same_row ["John", "Edit"], :within => "#table_a"
191
+ should_see_in_same_row ["Graham", "Edit"], :within => "#table_b"
192
+ end
193
+
188
194
  it "two strings are in the same row, and one has single and/or double-quotes" do
189
- should_see_in_same_row [%{Eric "Quoted"}, "Edit"]
190
- should_see_in_same_row [%{"John's" quo'ta'tions}, "Edit"]
195
+ should_see_in_same_row [%{Graham "Quoted"}, "Edit"]
196
+ should_see_in_same_row [%{"Michael's" quo'ta'tions}, "Edit"]
191
197
  should_see_in_same_row [%{Terry's "Big" thing}, "Edit"]
192
198
  end
193
199
 
@@ -196,9 +202,29 @@ describe Kelp::Visibility, "should_see_in_same_row" do
196
202
  should_see_in_same_row ["John", "666-5555", "Edit"]
197
203
  end
198
204
  end
205
+
206
+ context "fails when" do
207
+ it "two strings exist, but are not in the same row" do
208
+ lambda do
209
+ should_see_in_same_row ["Eric", "John"]
210
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
211
+ end
212
+
213
+ it "two strings are in the same row, but a third is not" do
214
+ lambda do
215
+ should_see_in_same_row ["Eric", "Edit", "Delete"]
216
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
217
+ end
218
+
219
+ it "two strings are in the same row, but outside the given scope" do
220
+ lambda do
221
+ should_see_in_same_row ["Eric", "Edit"], :within => "#table_b"
222
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
223
+ end
224
+ end
199
225
  end
200
226
 
201
- describe Kelp::Visibility, "should_see_in_same_row" do
227
+ describe Kelp::Visibility, "should_not_see_in_same_row" do
202
228
  before(:each) do
203
229
  visit('/home')
204
230
  end
@@ -215,6 +241,24 @@ describe Kelp::Visibility, "should_see_in_same_row" do
215
241
  should_not_see_in_same_row ["John", "666-5555", "Delete"]
216
242
  should_not_see_in_same_row ["Terry", "777-6666", "Delete"]
217
243
  end
244
+
245
+ it "two strings are not in the same row within a given scope" do
246
+ should_not_see_in_same_row ["Terry", "Delete"], :within => "#table_a"
247
+ end
248
+ end
249
+
250
+ context "fails when" do
251
+ it "two strings are in the same row" do
252
+ lambda do
253
+ should_not_see_in_same_row ["Eric", "Edit"]
254
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
255
+ end
256
+
257
+ it "two strings are in the same row within a given scope" do
258
+ lambda do
259
+ should_not_see_in_same_row ["Eric", "Edit"], :within => "#table_a"
260
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
261
+ end
218
262
  end
219
263
  end
220
264
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kelp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Pierce
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-06 00:00:00 -06:00
18
+ date: 2011-04-15 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -106,6 +106,20 @@ dependencies:
106
106
  version: "0"
107
107
  type: :development
108
108
  version_requirements: *id006
109
+ - !ruby/object:Gem::Dependency
110
+ name: cucumber
111
+ prerelease: false
112
+ requirement: &id007 !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ type: :development
122
+ version_requirements: *id007
109
123
  description: " Kelp is a collection of helper methods for Cucumber to ease the process of\n writing step definitions.\n"
110
124
  email: wapcaplet88@gmail.com
111
125
  executables: []
@@ -123,6 +137,22 @@ files:
123
137
  - MIT-LICENSE
124
138
  - README.md
125
139
  - Rakefile
140
+ - examples/sinatra_app/app.rb
141
+ - examples/sinatra_app/config.ru
142
+ - examples/sinatra_app/features/dropdown.feature
143
+ - examples/sinatra_app/features/support/env.rb
144
+ - examples/sinatra_app/features/visibility.feature
145
+ - examples/sinatra_app/features/web_steps.rb
146
+ - examples/sinatra_app/views/about.erb
147
+ - examples/sinatra_app/views/edit1.erb
148
+ - examples/sinatra_app/views/edit2.erb
149
+ - examples/sinatra_app/views/edit3.erb
150
+ - examples/sinatra_app/views/form.erb
151
+ - examples/sinatra_app/views/home.erb
152
+ - examples/sinatra_app/views/thanks.erb
153
+ - features/kelp_step_definitions.feature
154
+ - features/step_definitions/app_steps.rb
155
+ - features/support/env.rb
126
156
  - kelp.gemspec
127
157
  - lib/kelp.rb
128
158
  - lib/kelp/attribute.rb
@@ -134,6 +164,9 @@ files:
134
164
  - lib/kelp/scoping.rb
135
165
  - lib/kelp/visibility.rb
136
166
  - lib/kelp/xpath.rb
167
+ - rails_generators/kelp/kelp_generator.rb
168
+ - rails_generators/kelp/templates/capybara_steps.rb
169
+ - rails_generators/kelp/templates/kelp_steps.rb
137
170
  - spec/attribute_spec.rb
138
171
  - spec/checkbox_spec.rb
139
172
  - spec/dropdown_spec.rb
@@ -141,17 +174,8 @@ files:
141
174
  - spec/navigation_spec.rb
142
175
  - spec/scoping_spec.rb
143
176
  - spec/spec_helper.rb
144
- - spec/test_app/test_app.rb
145
- - spec/test_app/views/about.erb
146
- - spec/test_app/views/edit1.erb
147
- - spec/test_app/views/edit2.erb
148
- - spec/test_app/views/edit3.erb
149
- - spec/test_app/views/form.erb
150
- - spec/test_app/views/home.erb
151
- - spec/test_app/views/thanks.erb
152
177
  - spec/visibility_spec.rb
153
178
  - spec/xpath_spec.rb
154
- - step_definitions/capybara_steps.rb
155
179
  has_rdoc: true
156
180
  homepage: http://github.com/wapcaplet/kelp
157
181
  licenses: []