sandwich 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -0
- data/VERSION +1 -1
- data/lib/sandwich/cucumber/debug_steps.rb +12 -0
- data/lib/sandwich/cucumber/table_steps.rb +14 -0
- data/lib/sandwich/ext/capybara.rb +15 -0
- data/lib/sandwich/regexps.rb +13 -2
- data/sandwich.gemspec +76 -0
- metadata +42 -3
data/Rakefile
CHANGED
@@ -12,6 +12,10 @@ begin
|
|
12
12
|
gem.authors = ["David Leal"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
14
|
gem.add_development_dependency "yard", ">= 0"
|
15
|
+
gem.add_dependency "machinist", ">= 0"
|
16
|
+
gem.add_dependency "capybara", ">= 0"
|
17
|
+
gem.add_dependency "cucumber", ">= 0"
|
18
|
+
|
15
19
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
20
|
end
|
17
21
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -9,3 +9,15 @@ Then Sandwich.regexps[:show_all] do |targets|
|
|
9
9
|
target.strip.singularize.classify.constantize.all.map { |item| pp item }
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
Then Sandwich.regexps[:show_source_snippet] do |selector|
|
14
|
+
puts locate(selector).html
|
15
|
+
end
|
16
|
+
|
17
|
+
Then Sandwich.regexps[:show_page_text] do
|
18
|
+
IO.popen("html2text", "w+") do |io|
|
19
|
+
io.puts response.body
|
20
|
+
io.close_write
|
21
|
+
puts io.readlines
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'sandwich/regexps'
|
2
|
+
|
3
|
+
When Sandwich.regexps[:fill_within_table] do |column, ordinal, path, value|
|
4
|
+
within(selector_for(path)) do
|
5
|
+
_, column_index = all("th").each_with_index.find { |e, i| e.text == column }
|
6
|
+
locate(:xpath, "//tr[#{ordinal.to_i}]/td[#{column_index + 1}]/input").set(value)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
Then Sandwich.regexps[:find_within_row] do |value, ordinal, path|
|
11
|
+
within(selector_for(path)) do
|
12
|
+
page.should have_xpath("//tr[#{ordinal.to_i}]/td", :text => value)
|
13
|
+
end
|
14
|
+
end
|
data/lib/sandwich/regexps.rb
CHANGED
@@ -5,12 +5,23 @@ module Sandwich
|
|
5
5
|
@regexps ||= {}.tap do |rx|
|
6
6
|
rx[:model] = /^(an?|the|\d+) (.+) exists?$/
|
7
7
|
rx[:no_model] = /^no (.+) exists?$/
|
8
|
-
rx[:model_with_attribute] = /^(an?|the|\d+) (.+) (?:with|in) (.+)
|
9
|
-
rx[:no_model_with_attribute] = /^no (.+) (?:with|in) (.+)
|
8
|
+
rx[:model_with_attribute] = /^(an?|the|\d+) (.+) (?:with|in) (.+) #{quoted_value} exists?$/
|
9
|
+
rx[:no_model_with_attribute] = /^no (.+) (?:with|in) (.+) #{quoted_value} exists?$/
|
10
10
|
rx[:model_with_attributes] = /^(an?|the|\d+) (.+) exists with the following attributes:$/
|
11
11
|
rx[:models_with_attributes] = /^the following (.+) exist:$/
|
12
12
|
rx[:show_source] = /^show me the source$/
|
13
13
|
rx[:show_all] = /^show me all (.+)$/
|
14
|
+
rx[:show_source_snippet] = /^show me the source for #{quoted_value}$/
|
15
|
+
rx[:show_page_text] = /^show me the page text$/
|
16
|
+
rx[:look_at] = /^I look at (.+)$/
|
17
|
+
rx[:fill_within_table] = /^I fill in the #{quoted_value} cell for the (\w+) row of (.+?) with #{quoted_value}$/
|
18
|
+
rx[:find_within_row] = /^I should see #{quoted_value} in the (\w+) data row of (.+)$/
|
14
19
|
end
|
15
20
|
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def self.quoted_value
|
25
|
+
'"([^\"]*)"'
|
26
|
+
end
|
16
27
|
end
|
data/sandwich.gemspec
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{sandwich}
|
8
|
+
s.version = "0.0.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["David Leal"]
|
12
|
+
s.date = %q{2010-04-14}
|
13
|
+
s.description = %q{Yup, cucumber helpers}
|
14
|
+
s.email = %q{david@thedigitalants.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/sandwich.rb",
|
27
|
+
"lib/sandwich/cucumber/debug_steps.rb",
|
28
|
+
"lib/sandwich/cucumber/model_steps.rb",
|
29
|
+
"lib/sandwich/cucumber/table_steps.rb",
|
30
|
+
"lib/sandwich/cucumber/world.rb",
|
31
|
+
"lib/sandwich/ext/active_record.rb",
|
32
|
+
"lib/sandwich/ext/capybara.rb",
|
33
|
+
"lib/sandwich/ext/string.rb",
|
34
|
+
"lib/sandwich/helpers/amounts.rb",
|
35
|
+
"lib/sandwich/regexps.rb",
|
36
|
+
"sandwich.gemspec",
|
37
|
+
"spec/sandwich_spec.rb",
|
38
|
+
"spec/spec.opts",
|
39
|
+
"spec/spec_helper.rb"
|
40
|
+
]
|
41
|
+
s.homepage = %q{http://github.com/david/sandwich}
|
42
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
43
|
+
s.require_paths = ["lib"]
|
44
|
+
s.rubygems_version = %q{1.3.6}
|
45
|
+
s.summary = %q{Cucumber helpers}
|
46
|
+
s.test_files = [
|
47
|
+
"spec/sandwich_spec.rb",
|
48
|
+
"spec/spec_helper.rb"
|
49
|
+
]
|
50
|
+
|
51
|
+
if s.respond_to? :specification_version then
|
52
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
53
|
+
s.specification_version = 3
|
54
|
+
|
55
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
57
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
58
|
+
s.add_runtime_dependency(%q<machinist>, [">= 0"])
|
59
|
+
s.add_runtime_dependency(%q<capybara>, [">= 0"])
|
60
|
+
s.add_runtime_dependency(%q<cucumber>, [">= 0"])
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
63
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
64
|
+
s.add_dependency(%q<machinist>, [">= 0"])
|
65
|
+
s.add_dependency(%q<capybara>, [">= 0"])
|
66
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
67
|
+
end
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
70
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
71
|
+
s.add_dependency(%q<machinist>, [">= 0"])
|
72
|
+
s.add_dependency(%q<capybara>, [">= 0"])
|
73
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David Leal
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-14 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -43,6 +43,42 @@ dependencies:
|
|
43
43
|
version: "0"
|
44
44
|
type: :development
|
45
45
|
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: machinist
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
type: :runtime
|
57
|
+
version_requirements: *id003
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: capybara
|
60
|
+
prerelease: false
|
61
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
type: :runtime
|
69
|
+
version_requirements: *id004
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: cucumber
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
type: :runtime
|
81
|
+
version_requirements: *id005
|
46
82
|
description: Yup, cucumber helpers
|
47
83
|
email: david@thedigitalants.com
|
48
84
|
executables: []
|
@@ -62,11 +98,14 @@ files:
|
|
62
98
|
- lib/sandwich.rb
|
63
99
|
- lib/sandwich/cucumber/debug_steps.rb
|
64
100
|
- lib/sandwich/cucumber/model_steps.rb
|
101
|
+
- lib/sandwich/cucumber/table_steps.rb
|
65
102
|
- lib/sandwich/cucumber/world.rb
|
66
103
|
- lib/sandwich/ext/active_record.rb
|
104
|
+
- lib/sandwich/ext/capybara.rb
|
67
105
|
- lib/sandwich/ext/string.rb
|
68
106
|
- lib/sandwich/helpers/amounts.rb
|
69
107
|
- lib/sandwich/regexps.rb
|
108
|
+
- sandwich.gemspec
|
70
109
|
- spec/sandwich_spec.rb
|
71
110
|
- spec/spec.opts
|
72
111
|
- spec/spec_helper.rb
|