Byclosure-common_steps 0.0.1
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.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/MIT-LICENSE.txt +20 -0
- data/README.rdoc +20 -0
- data/Rakefile +6 -0
- data/VERSION +1 -0
- data/common_steps.gemspec +77 -0
- data/features/common_steps.feature +9 -0
- data/features/step_definitions/common_steps_steps.rb +0 -0
- data/features/support/env.rb +4 -0
- data/lib/common_steps/helpers/record_helper.rb +63 -0
- data/lib/common_steps/helpers.rb +7 -0
- data/lib/common_steps/matchers/count.rb +17 -0
- data/lib/common_steps/step_definitions/navigation_steps.rb +64 -0
- data/lib/common_steps/step_definitions/record_steps.rb +163 -0
- data/lib/common_steps/step_definitions/webrat_steps.rb +119 -0
- data/lib/common_steps/step_definitions.rb +3 -0
- data/lib/common_steps/support/database.rb +12 -0
- data/lib/common_steps/support/email.rb +14 -0
- data/lib/common_steps/support/env.rb +24 -0
- data/lib/common_steps/support/spec.rb +11 -0
- data/lib/common_steps/tasks/cucumber.rake +24 -0
- data/lib/common_steps/tasks/rspec.rake +165 -0
- data/lib/common_steps.rb +2 -0
- data/spec/common_steps/common_steps_spec.rb +7 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +8 -0
- data/tasks/cucumber.rake +10 -0
- data/tasks/jeweler.rake +52 -0
- data/tasks/rdoc.rake +13 -0
- data/tasks/roodi.rake +11 -0
- data/tasks/rspec.rake +14 -0
- metadata +107 -0
data/.document
ADDED
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Bryan Helmkamp
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
= common_steps
|
2
|
+
|
3
|
+
* http://github.com/Byclosure/common_steps
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
Some common cucumber step definitions, rake tasks, and rspec matchers.
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
sudo gem install Byclosure-common_steps
|
12
|
+
|
13
|
+
== Authors
|
14
|
+
|
15
|
+
- Maintained by {Vasco}[mailto:vasco@byclosure.com]
|
16
|
+
|
17
|
+
== License
|
18
|
+
|
19
|
+
Copyright (c) 2009 Byclosure.
|
20
|
+
See MIT-LICENSE.txt in this directory.
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{common_steps}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Vasco Andrade e Silva", "Duarte Henriques"]
|
12
|
+
s.date = %q{2009-09-09}
|
13
|
+
s.description = %q{common_steps. Some common cucumber step definitions, rake tasks, and rspec matchers}
|
14
|
+
s.email = ["vasco@byclosure.com", "duarte@byclosure.com"]
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
".gitignore",
|
21
|
+
"MIT-LICENSE.txt",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"common_steps.gemspec",
|
26
|
+
"features/common_steps.feature",
|
27
|
+
"features/step_definitions/common_steps_steps.rb",
|
28
|
+
"features/support/env.rb",
|
29
|
+
"lib/common_steps.rb",
|
30
|
+
"lib/common_steps/helpers.rb",
|
31
|
+
"lib/common_steps/helpers/record_helper.rb",
|
32
|
+
"lib/common_steps/matchers/count.rb",
|
33
|
+
"lib/common_steps/step_definitions.rb",
|
34
|
+
"lib/common_steps/step_definitions/navigation_steps.rb",
|
35
|
+
"lib/common_steps/step_definitions/record_steps.rb",
|
36
|
+
"lib/common_steps/step_definitions/webrat_steps.rb",
|
37
|
+
"lib/common_steps/support/database.rb",
|
38
|
+
"lib/common_steps/support/email.rb",
|
39
|
+
"lib/common_steps/support/env.rb",
|
40
|
+
"lib/common_steps/support/spec.rb",
|
41
|
+
"lib/common_steps/tasks/cucumber.rake",
|
42
|
+
"lib/common_steps/tasks/rspec.rake",
|
43
|
+
"spec/common_steps/common_steps_spec.rb",
|
44
|
+
"spec/spec.opts",
|
45
|
+
"spec/spec_helper.rb",
|
46
|
+
"tasks/cucumber.rake",
|
47
|
+
"tasks/jeweler.rake",
|
48
|
+
"tasks/rdoc.rake",
|
49
|
+
"tasks/roodi.rake",
|
50
|
+
"tasks/rspec.rake"
|
51
|
+
]
|
52
|
+
s.homepage = %q{http://github.com/Byclosure/common_steps}
|
53
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
54
|
+
s.require_paths = ["lib"]
|
55
|
+
s.rubygems_version = %q{1.3.5}
|
56
|
+
s.summary = %q{common_steps. Some common cucumber step definitions, rake tasks, and rspec matchers}
|
57
|
+
s.test_files = [
|
58
|
+
"spec/common_steps/common_steps_spec.rb",
|
59
|
+
"spec/spec_helper.rb"
|
60
|
+
]
|
61
|
+
|
62
|
+
if s.respond_to? :specification_version then
|
63
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
64
|
+
s.specification_version = 3
|
65
|
+
|
66
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
67
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
68
|
+
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
69
|
+
else
|
70
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
71
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
72
|
+
end
|
73
|
+
else
|
74
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
75
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
76
|
+
end
|
77
|
+
end
|
File without changes
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module RecordHelper
|
2
|
+
def record_singular_name(*record_names)
|
3
|
+
record_name = record_names.inject("") {|name, rn| name + rn }
|
4
|
+
record_name.gsub(' ', '_').singularize
|
5
|
+
end
|
6
|
+
|
7
|
+
def record_name_to_class(record_name)
|
8
|
+
klass_name = record_singular_name(record_name).classify
|
9
|
+
klass = klass_name.constantize
|
10
|
+
klass.nil? ? raise("Couldn't found any class for record with name `#{record_name}', tried with `#{klass_name}'") : klass
|
11
|
+
end
|
12
|
+
|
13
|
+
# leo = Artist.create!(:name => "Leo")
|
14
|
+
# Paiting.belongs_to :artist
|
15
|
+
# Paintings:
|
16
|
+
# | title | artist_name |
|
17
|
+
# | Mona | Leo |
|
18
|
+
# will associate leo to the paiting with title Mona
|
19
|
+
|
20
|
+
def recordize!(record_name, table, &block)
|
21
|
+
record_class = record_name_to_class(record_name)
|
22
|
+
table.headers.each do |header|
|
23
|
+
rh = record_class.columns_hash[header]
|
24
|
+
if rh.nil? # artist_name case
|
25
|
+
association = record_class.reflect_on_all_associations.detect {|a| header =~ /^#{a.name}/ }
|
26
|
+
raise("Association: `#{header}' not found on #{record_class}") if association.nil?
|
27
|
+
|
28
|
+
find_attrs = header.match(/^#{association.name}(.*)$/)[1]
|
29
|
+
association_class = association.klass
|
30
|
+
table.map_column!(header) { |value| association_class.send("find_by#{find_attrs}", value) }
|
31
|
+
table.map_headers!(header => association.name)
|
32
|
+
else
|
33
|
+
table.map_column!(header) {|value| rh.type_cast(value) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def str_to_num(str)
|
39
|
+
case str
|
40
|
+
when "a" then 1
|
41
|
+
when "an" then 1
|
42
|
+
when "no" then 0
|
43
|
+
else str.to_i
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# TODO refact!
|
48
|
+
def conditions_from_str(record_class, conditions_str)
|
49
|
+
record_conds = conditions_str.gsub(", and", ",").gsub(" and", ",").split(", ")
|
50
|
+
conds = record_conds.map {|rc| rc.gsub(" => ", " of ").split(" of ") }
|
51
|
+
conds.inject({}) {|base, (attr, value_str)| base[attr] = instance_eval(value_str); base}
|
52
|
+
end
|
53
|
+
|
54
|
+
def find_record(record_class, record_conditions)
|
55
|
+
conditions = conditions_from_str(record_class, record_conditions)
|
56
|
+
record = record_class.find(:first, :conditions => conditions)
|
57
|
+
record.nil? ? raise("Couldn't found any record for `#{record_class}' with conditions: `#{conditions.inspect}'") : record
|
58
|
+
end
|
59
|
+
|
60
|
+
def record_class_to_path(record_class)
|
61
|
+
record_class.name.underscore.pluralize
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Dir[File.dirname(__FILE__) + "/helpers/*.rb"].each do |filename|
|
2
|
+
require filename
|
3
|
+
module_name = filename.chomp(".rb").classify.demodulize
|
4
|
+
mod = module_name.constantize rescue warn("unable to load: module `#{module_name}' in file #{filename}")
|
5
|
+
World(mod) if defined?(World)
|
6
|
+
end
|
7
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Spec::Matchers.define :count do |num|
|
2
|
+
match do |collection|
|
3
|
+
collection.count == num
|
4
|
+
end
|
5
|
+
|
6
|
+
failure_message_for_should do |collection|
|
7
|
+
"expected #{collection} count to be #{num} instead of #{collection.count}"
|
8
|
+
end
|
9
|
+
|
10
|
+
failure_message_for_should_not do |collection|
|
11
|
+
"expected #{collection} count not to be #{num}"
|
12
|
+
end
|
13
|
+
|
14
|
+
description do
|
15
|
+
"count should be #{num}"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
When /^I (\w+) the form with$/ do |submit_name, table|
|
2
|
+
pending
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^I go to "([^\"]*)"$/ do |page_name|
|
6
|
+
visit page_name
|
7
|
+
end
|
8
|
+
|
9
|
+
When /^I go to the homepage$/ do
|
10
|
+
When 'I go to "/"'
|
11
|
+
end
|
12
|
+
|
13
|
+
Given /^I am on the new (\w+) page$/ do |record_name|
|
14
|
+
When "I go to the new #{record_name} page"
|
15
|
+
end
|
16
|
+
|
17
|
+
When /^I go to the new (\w+) page$/ do |record_name|
|
18
|
+
record_class = record_name_to_class(record_name)
|
19
|
+
When "I go to \"/#{record_class_to_path(record_class)}/new\""
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^I go to the list page of (\w+)$/ do |record_name|
|
23
|
+
path = record_name.pluralize # TODO refact
|
24
|
+
When "I go to \"/#{path}\""
|
25
|
+
end
|
26
|
+
|
27
|
+
Given /^I am on the edit page of the (\w+) with (a|an) (.*)$/ do |record_name, _, record_conditions|
|
28
|
+
When "I go to the edit page of the #{record_name} with a #{record_conditions}"
|
29
|
+
end
|
30
|
+
|
31
|
+
When /^I go to the edit page of the (\w+) with (a|an) (.*)$/ do |record_name, _, record_conditions|
|
32
|
+
record_class = record_name_to_class(record_name)
|
33
|
+
record = find_record(record_class, record_conditions)
|
34
|
+
When "I go to \"/#{record_class_to_path(record_class)}/#{record.id}/edit\""
|
35
|
+
end
|
36
|
+
|
37
|
+
When /^I go to the show page of the (\w+) with (a|an) (.*)$/ do |record_name, _, record_conditions|
|
38
|
+
record_class = record_name_to_class(record_name)
|
39
|
+
record = find_record(record_class, record_conditions)
|
40
|
+
When "I go to \"/#{record_class_to_path(record_class)}/#{record.id}\""
|
41
|
+
end
|
42
|
+
|
43
|
+
#When /^I go to the delete page of (\w+) with (.*)$/ do |record_name|
|
44
|
+
# pending
|
45
|
+
#end
|
46
|
+
|
47
|
+
Then /^I should be on "([^\"]*)"$/ do |page_name|
|
48
|
+
URI.parse(current_url).path.should == page_name
|
49
|
+
end
|
50
|
+
|
51
|
+
Then /^I should be on the show page of the (\w+) with (a|an) (.*)$/ do |record_name, _,record_conditions|
|
52
|
+
record_class = record_name_to_class(record_name)
|
53
|
+
record = find_record(record_class, record_conditions)
|
54
|
+
path = "/#{record_class_to_path(record_class)}/#{record.id}"
|
55
|
+
URI.parse(current_url).path.should match(/#{path}/)
|
56
|
+
end
|
57
|
+
|
58
|
+
Then /^I should be on the edit page of the (\w+) with (a|an) (.*)$/ do |record_name, _,record_conditions|
|
59
|
+
record_class = record_name_to_class(record_name)
|
60
|
+
record = find_record(record_class, record_conditions)
|
61
|
+
path = "/#{record_class_to_path(record_class)}/#{record.id}"
|
62
|
+
URI.parse(current_url).path.should match(/#{path}/)
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,163 @@
|
|
1
|
+
Given /^there (is|are) (\w+) (\w+) with a (.*)$/ do |_, count_str, record_name, record_conditions|
|
2
|
+
factory_name = record_singular_name(record_name)
|
3
|
+
conditions = conditions_from_str(record_name_to_class(record_name), record_conditions)
|
4
|
+
num = str_to_num(count_str)
|
5
|
+
num.times { Factory(factory_name, conditions) }
|
6
|
+
end
|
7
|
+
|
8
|
+
Given /^there (is|are) (\w+) (\w*)$/ do |_, count_str, record_name|
|
9
|
+
factory_name = record_singular_name(record_name)
|
10
|
+
num = str_to_num(count_str)
|
11
|
+
num.times { Factory(factory_name) }
|
12
|
+
end
|
13
|
+
|
14
|
+
Then /^there should be (\w+) (\w+)$/ do |count_str, record_name|
|
15
|
+
num = str_to_num(count_str)
|
16
|
+
record_name_to_class(record_name).should count(num)
|
17
|
+
end
|
18
|
+
|
19
|
+
Given /^the following (\w+):?$/ do |record_name, table|
|
20
|
+
recordize!(record_name, table)
|
21
|
+
factory_name = record_singular_name(record_name)
|
22
|
+
table.hashes.each do |hash|
|
23
|
+
Factory(factory_name, hash)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Then /^I should see the following (\w+) in order$/ do |record_name, table|
|
28
|
+
class_name = record_name_to_class(record_name)
|
29
|
+
actual_table = table.headers.map {|h| Array(h)}
|
30
|
+
#TODO
|
31
|
+
class_name.find(:all).each do |record|
|
32
|
+
actual_table << [record.name]
|
33
|
+
end
|
34
|
+
table.diff!(actual_table)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
=begin
|
39
|
+
class_name = model_name.gsub(' ', '_').singularize
|
40
|
+
model_class = nil
|
41
|
+
begin
|
42
|
+
model_class = class_name.classify.constantize
|
43
|
+
rescue
|
44
|
+
# do nothing
|
45
|
+
end
|
46
|
+
model_class.delete_all if model_class
|
47
|
+
table.hashes.each do |hash|
|
48
|
+
attr_hash = hash.inject({}) do |attr_hash, (attr_name, attr_value)|
|
49
|
+
if attr_name == 'user' && !attr_value.is_a?(User) # hack
|
50
|
+
attr_hash[attr_name] = find_or_create_valid_user(:login => attr_value)
|
51
|
+
elsif attr_name == "published_at" && hash['published_as'] == "draft" # hack
|
52
|
+
attr_hash[attr_name] = nil
|
53
|
+
elsif (model_class && (association = model_class.reflect_on_all_associations(:has_many).detect { |a| attr_name =~ /^(#{a.name})(_.*)/ }))
|
54
|
+
find_suffix = $2
|
55
|
+
attr_hash[association.name] = if attr_value.nil?
|
56
|
+
[]
|
57
|
+
else
|
58
|
+
association_class = association.class_name.constantize
|
59
|
+
attr_value.split(", ").map do |v|
|
60
|
+
association_class.send("find_by#{find_suffix}", v)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
else
|
64
|
+
attr_hash[attr_name] = attr_value
|
65
|
+
end
|
66
|
+
attr_hash
|
67
|
+
end
|
68
|
+
|
69
|
+
approve = attr_hash.delete("approve")
|
70
|
+
model = Factory(class_name.to_sym, attr_hash)
|
71
|
+
if approve == "true"
|
72
|
+
model.approve!
|
73
|
+
end
|
74
|
+
model
|
75
|
+
end
|
76
|
+
=end
|
77
|
+
|
78
|
+
=begin
|
79
|
+
Given /^the following (.+) records?$/ do |model_name, table|
|
80
|
+
class_name = model_name.gsub(' ', '_').singularize
|
81
|
+
model_class = class_name.classify.constantize
|
82
|
+
model_class.delete_all
|
83
|
+
has_many_opts = model_class.reflect_on_all_associations(:has_many)
|
84
|
+
table.hashes.each do |hash|
|
85
|
+
attr_hash = hash.inject({}) do |attr_hash, (attr_name, attr_value)|
|
86
|
+
if attr_name == 'user' && !attr_value.is_a?(User) # hack
|
87
|
+
attr_hash[attr_name] = find_or_create_valid_user(:login => attr_value)
|
88
|
+
elsif attr_name == "published_at" && hash['published_as'] == "draft" # hack
|
89
|
+
attr_hash[attr_name] = nil
|
90
|
+
elsif (association = has_many_opts.detect { |a| attr_name =~ /^(#{a.name})(_.*)/ })
|
91
|
+
find_suffix = $2
|
92
|
+
attr_hash[association.name] = if attr_value.nil?
|
93
|
+
[]
|
94
|
+
else
|
95
|
+
association_class = association.class_name.constantize
|
96
|
+
attr_value.split(", ").map do |v|
|
97
|
+
association_class.send("find_by#{find_suffix}", v)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
else
|
101
|
+
attr_hash[attr_name] = attr_value
|
102
|
+
end
|
103
|
+
attr_hash
|
104
|
+
end
|
105
|
+
|
106
|
+
approve = attr_hash.delete("approve")
|
107
|
+
model = Factory(class_name.to_sym, attr_hash)
|
108
|
+
if approve == "true"
|
109
|
+
model.approve!
|
110
|
+
end
|
111
|
+
model
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
Given /^there is a ([^\" ]+)$/ do |resource|
|
117
|
+
instance_variable_set(:"@#{resource.gsub(' ', '_')}", respond_to?(:"create_valid_#{resource.gsub(' ', '_')}") ? send(:"create_valid_#{resource.gsub(' ', '_')}") : Factory(:"#{resource.gsub(' ', '_')}"))
|
118
|
+
end
|
119
|
+
Given /^there is a (.+) with (.+) "([^\"]*)"$/ do |resource, field, value|
|
120
|
+
resource_name = resource.gsub(' ', '_')
|
121
|
+
resource_name.classify.constantize.find(:all, :conditions => {field => value}).map(&:destroy) rescue nil # in case there is a uniqueness validation
|
122
|
+
method = :"create_valid_#{resource_name}"
|
123
|
+
instance_variable_set(:"@#{resource_name}", respond_to?(method) ? send(method, field.to_sym => value) : Factory(resource_name, field.to_sym => value))
|
124
|
+
end
|
125
|
+
Given /^there is an (.+) with (.+) "([^\"]*)"$/ do |resource, field, value|
|
126
|
+
resource_name = resource.gsub(' ', '_')
|
127
|
+
resource_name.classify.constantize.find(:all, :conditions => {field => value}).map(&:destroy) rescue nil # in case there is a uniqueness validation
|
128
|
+
method = :"create_valid_#{resource_name}"
|
129
|
+
instance_variable_set(:"@#{resource_name}", respond_to?(method) ? send(method, field.to_sym => value) : Factory(resource_name, field.to_sym => value))
|
130
|
+
end
|
131
|
+
#Given /^I have only one (.+)$/ do |resource|
|
132
|
+
# @myself.send(resource.pluralize).delete_all
|
133
|
+
# instance_variable_set(:"@#{resource.gsub(' ', '_')}", send(:"create_valid_#{resource.gsub(' ', '_')}"))
|
134
|
+
#end
|
135
|
+
Given /^I have only one (.+) with (.+) "([^\"]*)"$/ do |resource, field, value|
|
136
|
+
@myself.send(resource.pluralize).delete_all
|
137
|
+
resource.classify.constantize.find(:all, :conditions => {field => value}).map(&:destroy) rescue nil # in case there is a uniqueness validation
|
138
|
+
instance_variable_set(:"@#{resource.gsub(' ', '_')}", send(:"create_valid_#{resource.gsub(' ', '_')}", field.to_sym => value, :user => @myself))
|
139
|
+
end
|
140
|
+
Given /^I have a (.+) with (.+) "([^\"]*)"$/ do |resource, field, value|
|
141
|
+
resource.classify.constantize.find(:all, :conditions => {field => value}).map(&:destroy) rescue nil # in case there is a uniqueness validation
|
142
|
+
instance_variable_set(:"@#{resource.gsub(' ', '_')}", send(:"create_valid_#{resource.gsub(' ', '_')}", field.to_sym => value, :user => @myself))
|
143
|
+
end
|
144
|
+
|
145
|
+
Then /^there should be ([0-9]+) (.+)$/ do |count, resource|
|
146
|
+
resource.singularize.classify.constantize.count.should == count.to_i
|
147
|
+
end
|
148
|
+
|
149
|
+
Then /^I should have ([0-9]+) (.+)$/ do |count, resource|
|
150
|
+
@myself.send(resource.pluralize).count.should == count.to_i
|
151
|
+
end
|
152
|
+
|
153
|
+
Given /^there are no ([^ ]+)$/ do |resource|
|
154
|
+
resource.singularize.classify.constantize.delete_all
|
155
|
+
end
|
156
|
+
|
157
|
+
Then /^that (.+) should be deleted$/ do |resource|
|
158
|
+
lambda { instance_variable_get(:"@#{resource}").reload }.should raise_error ActiveRecord::RecordNotFound
|
159
|
+
end
|
160
|
+
Then /^that (.+) should no longer exist$/ do |resource|
|
161
|
+
lambda { instance_variable_get(:"@#{resource}").reload }.should raise_error ActiveRecord::RecordNotFound
|
162
|
+
end
|
163
|
+
=end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# Commonly used webrat steps
|
2
|
+
# http://github.com/brynary/webrat
|
3
|
+
|
4
|
+
#Given /^I am on (.+)$/ do |page_name|
|
5
|
+
# visit path_to(page_name)
|
6
|
+
#end
|
7
|
+
|
8
|
+
When /^I press "([^\"]*)"$/ do |button|
|
9
|
+
click_button(button)
|
10
|
+
end
|
11
|
+
|
12
|
+
When /^I follow "([^\"]*)"$/ do |link|
|
13
|
+
click_link(link)
|
14
|
+
end
|
15
|
+
|
16
|
+
When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
|
17
|
+
fill_in(field, :with => value)
|
18
|
+
end
|
19
|
+
|
20
|
+
When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
|
21
|
+
select(value, :from => field)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
25
|
+
# When I select "December 25, 2008 10:00" as the date and time
|
26
|
+
When /^I select "([^\"]*)" as the date and time$/ do |time|
|
27
|
+
select_datetime(time)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Use this step when using multiple datetime_select helpers on a page or
|
31
|
+
# you want to specify which datetime to select. Given the following view:
|
32
|
+
# <%= f.label :preferred %><br />
|
33
|
+
# <%= f.datetime_select :preferred %>
|
34
|
+
# <%= f.label :alternative %><br />
|
35
|
+
# <%= f.datetime_select :alternative %>
|
36
|
+
# The following steps would fill out the form:
|
37
|
+
# When I select "November 23, 2004 11:20" as the "Preferred" data and time
|
38
|
+
# And I select "November 25, 2004 10:30" as the "Alternative" data and time
|
39
|
+
When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
|
40
|
+
select_datetime(datetime, :from => datetime_label)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Use this step in conjunction with Rail's time_select helper. For example:
|
44
|
+
# When I select "2:20PM" as the time
|
45
|
+
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
46
|
+
# will convert the 2:20PM to 14:20 and then select it.
|
47
|
+
When /^I select "([^\"]*)" as the time$/ do |time|
|
48
|
+
select_time(time)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Use this step when using multiple time_select helpers on a page or you want to
|
52
|
+
# specify the name of the time on the form. For example:
|
53
|
+
# When I select "7:30AM" as the "Gym" time
|
54
|
+
When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
|
55
|
+
select_time(time, :from => time_label)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Use this step in conjunction with Rail's date_select helper. For example:
|
59
|
+
# When I select "February 20, 1981" as the date
|
60
|
+
When /^I select "([^\"]*)" as the date$/ do |date|
|
61
|
+
select_date(date)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Use this step when using multiple date_select helpers on one page or
|
65
|
+
# you want to specify the name of the date on the form. For example:
|
66
|
+
# When I select "April 26, 1982" as the "Date of Birth" date
|
67
|
+
When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
|
68
|
+
select_date(date, :from => date_label)
|
69
|
+
end
|
70
|
+
|
71
|
+
When /^I check "([^\"]*)"$/ do |field|
|
72
|
+
check(field)
|
73
|
+
end
|
74
|
+
|
75
|
+
When /^I uncheck "([^\"]*)"$/ do |field|
|
76
|
+
uncheck(field)
|
77
|
+
end
|
78
|
+
|
79
|
+
When /^I choose "([^\"]*)"$/ do |field|
|
80
|
+
choose(field)
|
81
|
+
end
|
82
|
+
|
83
|
+
When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field|
|
84
|
+
attach_file(field, path)
|
85
|
+
end
|
86
|
+
|
87
|
+
Then /^I should see "([^\"]*)"$/ do |text|
|
88
|
+
response.should contain(text)
|
89
|
+
end
|
90
|
+
|
91
|
+
Then /^I should see the list "([^\"]*)"/ do |text|
|
92
|
+
list = text.split(", ")
|
93
|
+
list.each {|e| Then "I should see \"#{e}\"" }
|
94
|
+
end
|
95
|
+
|
96
|
+
Then /^I should not see "([^\"]*)"$/ do |text|
|
97
|
+
response.should_not contain(text)
|
98
|
+
end
|
99
|
+
|
100
|
+
Then /^I should not see the list "([^\"]*)"/ do |text|
|
101
|
+
list = text.split(", ")
|
102
|
+
list.each {|e| Then "I should not see \"#{e}\"" }
|
103
|
+
end
|
104
|
+
|
105
|
+
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
106
|
+
field_labeled(label).should be_checked
|
107
|
+
end
|
108
|
+
|
109
|
+
Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
|
110
|
+
field_labeled(label).should_not be_checked
|
111
|
+
end
|
112
|
+
|
113
|
+
#Then /^I should be on (.+)$/ do |page_name|
|
114
|
+
# URI.parse(current_url).path.should == path_to(page_name)
|
115
|
+
#end
|
116
|
+
|
117
|
+
Then /^the "([^\"]*)" field should be "([^\"]*)"$/ do |name, value|
|
118
|
+
response.should have_tag('form')
|
119
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'database_cleaner'
|
2
|
+
DatabaseCleaner.strategy = :truncation
|
3
|
+
|
4
|
+
Before do
|
5
|
+
DatabaseCleaner.start
|
6
|
+
|
7
|
+
::Rake::Task["db:test:load_contents"].execute if ::Rake::Task.task_defined?("db:test:load_contents")
|
8
|
+
end
|
9
|
+
|
10
|
+
After do
|
11
|
+
DatabaseCleaner.clean
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "rumbster"
|
2
|
+
require "message_observers" # same gem as rumbster
|
3
|
+
|
4
|
+
rumbster = nil
|
5
|
+
Before('@email') do
|
6
|
+
rumbster = Rumbster.new(ActionMailer::Base.smtp_settings[:port])
|
7
|
+
@email_inbox = MailMessageObserver.new
|
8
|
+
rumbster.add_observer @email_inbox
|
9
|
+
rumbster.start
|
10
|
+
end
|
11
|
+
|
12
|
+
After('@email') do
|
13
|
+
rumbster.stop
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Sets up the Rails environment for Cucumber
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
3
|
+
require 'cucumber/rails/world'
|
4
|
+
require 'cucumber/rails/rspec'
|
5
|
+
|
6
|
+
require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
|
7
|
+
|
8
|
+
require 'rake'
|
9
|
+
|
10
|
+
def rake(task)
|
11
|
+
`cd #{RAILS_ROOT} && RAILS_ENV=#{RAILS_ENV} rake #{task}`
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'webrat'
|
15
|
+
|
16
|
+
Webrat.configure do |config|
|
17
|
+
config.mode = ENV["MODE"] == "selenium" ? :selenium : :rails
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'webrat/core/matchers'
|
21
|
+
|
22
|
+
require File.expand_path(File.dirname(__FILE__) + '../../../spec/spec_helper')
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
desc "Run all features"
|
2
|
+
task :features => 'db:test:prepare' if ::Rake::Task.task_defines?("db:test:prepare")
|
3
|
+
task :features => "features:all"
|
4
|
+
|
5
|
+
require 'cucumber/rake/task' #I have to add this -mischa
|
6
|
+
|
7
|
+
namespace :features do
|
8
|
+
Cucumber::Rake::Task.new(:all) do |t|
|
9
|
+
t.cucumber_opts = "-g --format pretty"
|
10
|
+
end
|
11
|
+
|
12
|
+
Cucumber::Rake::Task.new(:cruise) do |t|
|
13
|
+
t.cucumber_opts = "-g --format pretty --out=#{ENV['CC_BUILD_ARTIFACTS']}/features.txt --format html --out=#{ENV['CC_BUILD_ARTIFACTS']}/features.html"
|
14
|
+
t.rcov = true
|
15
|
+
t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/}
|
16
|
+
t.rcov_opts << %[-o "#{ENV['CC_BUILD_ARTIFACTS']}/features_rcov"]
|
17
|
+
end
|
18
|
+
|
19
|
+
Cucumber::Rake::Task.new(:rcov) do |t|
|
20
|
+
t.rcov = true
|
21
|
+
t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/}
|
22
|
+
t.rcov_opts << %[-o "features_rcov"]
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
|
2
|
+
|
3
|
+
# Don't load rspec if running "rake gems:*"
|
4
|
+
unless ARGV.any? {|a| a =~ /^gems/}
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'spec/rake/spectask'
|
8
|
+
rescue MissingSourceFile
|
9
|
+
module Spec
|
10
|
+
module Rake
|
11
|
+
class SpecTask
|
12
|
+
def initialize(name)
|
13
|
+
task name do
|
14
|
+
# if rspec-rails is a configured gem, this will output helpful material and exit ...
|
15
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
|
16
|
+
|
17
|
+
# ... otherwise, do this:
|
18
|
+
raise <<-MSG
|
19
|
+
|
20
|
+
#{"*" * 80}
|
21
|
+
* You are trying to run an rspec rake task defined in
|
22
|
+
* #{__FILE__},
|
23
|
+
* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
|
24
|
+
#{"*" * 80}
|
25
|
+
MSG
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Rake.application.instance_variable_get('@tasks').delete('default')
|
34
|
+
|
35
|
+
spec_prereq = ["db:test:prepare", "db:test:load_contents"].inject([]) do |prereq, task_name|
|
36
|
+
prereq << task_name if ::Rake::Task.task_defined?(task_name)
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
task :stats => "spec:statsetup"
|
41
|
+
|
42
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
43
|
+
Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
|
44
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
45
|
+
t.spec_files = FileList['spec/**/*/*_spec.rb']
|
46
|
+
end
|
47
|
+
|
48
|
+
namespace :spec do
|
49
|
+
desc "Run all specs in spec directory with RCov (excluding plugin specs)"
|
50
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
51
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
52
|
+
t.spec_files = FileList['spec/**/*/*_spec.rb']
|
53
|
+
t.rcov = true
|
54
|
+
t.rcov_opts = lambda do
|
55
|
+
IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Print Specdoc for all specs (excluding plugin specs)"
|
60
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
61
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
62
|
+
t.spec_files = FileList['spec/**/*/*_spec.rb']
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Print Specdoc for all plugin examples"
|
66
|
+
Spec::Rake::SpecTask.new(:plugin_doc) do |t|
|
67
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
68
|
+
t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*')
|
69
|
+
end
|
70
|
+
|
71
|
+
[:models, :controllers, :views, :helpers, :lib].each do |sub|
|
72
|
+
desc "Run the code examples in spec/#{sub}"
|
73
|
+
Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
|
74
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
75
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "Run the code examples in vendor/plugins (except RSpec's own)"
|
80
|
+
Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
|
81
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
82
|
+
t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
|
83
|
+
end
|
84
|
+
|
85
|
+
namespace :plugins do
|
86
|
+
desc "Runs the examples for rspec_on_rails"
|
87
|
+
Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
|
88
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
89
|
+
t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*/*_spec.rb']
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Setup specs for stats
|
94
|
+
task :statsetup do
|
95
|
+
require 'code_statistics'
|
96
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
|
97
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
|
98
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
|
99
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
|
100
|
+
::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
|
101
|
+
::STATS_DIRECTORIES << %w(Routing\ specs spec/lib) if File.exist?('spec/routing')
|
102
|
+
::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
|
103
|
+
::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
|
104
|
+
::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
|
105
|
+
::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
|
106
|
+
::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
|
107
|
+
::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
|
108
|
+
end
|
109
|
+
|
110
|
+
namespace :db do
|
111
|
+
namespace :fixtures do
|
112
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z."
|
113
|
+
task :load => :environment do
|
114
|
+
ActiveRecord::Base.establish_connection(Rails.env)
|
115
|
+
base_dir = File.join(Rails.root, 'spec', 'fixtures')
|
116
|
+
fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
|
117
|
+
|
118
|
+
require 'active_record/fixtures'
|
119
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
|
120
|
+
Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
namespace :server do
|
127
|
+
daemonized_server_pid = File.expand_path("#{RAILS_ROOT}/tmp/pids/spec_server.pid")
|
128
|
+
|
129
|
+
desc "start spec_server."
|
130
|
+
task :start do
|
131
|
+
if File.exist?(daemonized_server_pid)
|
132
|
+
$stderr.puts "spec_server is already running."
|
133
|
+
else
|
134
|
+
$stderr.puts %Q{Starting up spec_server ...}
|
135
|
+
FileUtils.mkdir_p('tmp/pids') unless test ?d, 'tmp/pids'
|
136
|
+
system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
desc "stop spec_server."
|
141
|
+
task :stop do
|
142
|
+
unless File.exist?(daemonized_server_pid)
|
143
|
+
$stderr.puts "No server running."
|
144
|
+
else
|
145
|
+
$stderr.puts "Shutting down spec_server ..."
|
146
|
+
system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) &&
|
147
|
+
File.delete(daemonized_server_pid)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
desc "restart spec_server."
|
152
|
+
task :restart => [:stop, :start]
|
153
|
+
|
154
|
+
desc "check if spec server is running"
|
155
|
+
task :status do
|
156
|
+
if File.exist?(daemonized_server_pid)
|
157
|
+
$stderr.puts %Q{spec_server is running (PID: #{File.read(daemonized_server_pid).gsub("\n","")})}
|
158
|
+
else
|
159
|
+
$stderr.puts "No server running."
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
data/lib/common_steps.rb
ADDED
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
data/tasks/cucumber.rake
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
begin
|
2
|
+
require 'cucumber/rake/task'
|
3
|
+
Cucumber::Rake::Task.new(:features)
|
4
|
+
|
5
|
+
task :features => :check_dependencies
|
6
|
+
rescue LoadError
|
7
|
+
task :features do
|
8
|
+
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
9
|
+
end
|
10
|
+
end
|
data/tasks/jeweler.rake
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gem|
|
4
|
+
gem.name = "common_steps"
|
5
|
+
gem.summary = %Q{common_steps. Some common cucumber step definitions, rake tasks, and rspec matchers}
|
6
|
+
gem.description = gem.summary
|
7
|
+
gem.email = ["vasco@byclosure.com", "duarte@byclosure.com"]
|
8
|
+
gem.homepage = "http://github.com/Byclosure/common_steps"
|
9
|
+
gem.authors = ["Vasco Andrade e Silva", "Duarte Henriques"]
|
10
|
+
gem.add_development_dependency "rspec"
|
11
|
+
gem.add_development_dependency "cucumber"
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
end
|
14
|
+
rescue LoadError
|
15
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
=begin
|
20
|
+
spec = Gem::Specification.new do |s|
|
21
|
+
s.name = "common_steps"
|
22
|
+
s.version = "0.1.0" # CommonSteps::VERSION::STRING
|
23
|
+
s.authors = ["Vasco Andrade e Silva", "Duarte Henriques"]
|
24
|
+
s.email = "vasco@byclosure.com"
|
25
|
+
s.homepage = "http://github.com/Byclosure/common_steps"
|
26
|
+
s.summary = "common_steps. Some common cucumber step definitions, rake tasks, and rspec matchers"
|
27
|
+
s.description = s.summary
|
28
|
+
s.files = %w[MIT-LICENSE.txt README.rdoc Rakefile] + Dir["lib/**/*"]# + Dir["vendor/**/*"]
|
29
|
+
|
30
|
+
#s.add_dependency ""
|
31
|
+
end
|
32
|
+
|
33
|
+
Rake::GemPackageTask.new(spec) do |package|
|
34
|
+
package.gem_spec = spec
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'Show information about the gem.'
|
38
|
+
task :gemspec do
|
39
|
+
File.open("common_steps.gemspec", 'w') do |f|
|
40
|
+
f.write spec.to_ruby
|
41
|
+
end
|
42
|
+
puts "Generated: common_steps.gemspec"
|
43
|
+
end
|
44
|
+
|
45
|
+
CLEAN.include ["pkg", "*.gem", "doc", "ri", "coverage"]
|
46
|
+
|
47
|
+
desc 'Install the package as a gem.'
|
48
|
+
task :install => [:clean, :package] do
|
49
|
+
gem = Dir['pkg/*.gem'].first
|
50
|
+
sh "sudo gem install --no-ri --no-rdoc --local #{gem}"
|
51
|
+
end
|
52
|
+
=end
|
data/tasks/rdoc.rake
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rake/rdoctask'
|
2
|
+
Rake::RDocTask.new do |rdoc|
|
3
|
+
if File.exist?('VERSION')
|
4
|
+
version = File.read('VERSION')
|
5
|
+
else
|
6
|
+
version = ""
|
7
|
+
end
|
8
|
+
|
9
|
+
rdoc.rdoc_dir = 'rdoc'
|
10
|
+
rdoc.title = "tutu #{version}"
|
11
|
+
rdoc.rdoc_files.include('README*')
|
12
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
13
|
+
end
|
data/tasks/roodi.rake
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# require File.expand_path(File.dirname(__FILE__) + '/../lib/common_steps/tasks/rspec.rake')
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
4
|
+
spec.libs << 'lib' << 'spec'
|
5
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
6
|
+
end
|
7
|
+
|
8
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
9
|
+
spec.libs << 'lib' << 'spec'
|
10
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
11
|
+
spec.rcov = true
|
12
|
+
end
|
13
|
+
|
14
|
+
task :spec => :check_dependencies
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Byclosure-common_steps
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vasco Andrade e Silva
|
8
|
+
- Duarte Henriques
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-09-09 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
type: :development
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: cucumber
|
28
|
+
type: :development
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
version:
|
36
|
+
description: common_steps. Some common cucumber step definitions, rake tasks, and rspec matchers
|
37
|
+
email:
|
38
|
+
- vasco@byclosure.com
|
39
|
+
- duarte@byclosure.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files:
|
45
|
+
- README.rdoc
|
46
|
+
files:
|
47
|
+
- .document
|
48
|
+
- .gitignore
|
49
|
+
- MIT-LICENSE.txt
|
50
|
+
- README.rdoc
|
51
|
+
- Rakefile
|
52
|
+
- VERSION
|
53
|
+
- common_steps.gemspec
|
54
|
+
- features/common_steps.feature
|
55
|
+
- features/step_definitions/common_steps_steps.rb
|
56
|
+
- features/support/env.rb
|
57
|
+
- lib/common_steps.rb
|
58
|
+
- lib/common_steps/helpers.rb
|
59
|
+
- lib/common_steps/helpers/record_helper.rb
|
60
|
+
- lib/common_steps/matchers/count.rb
|
61
|
+
- lib/common_steps/step_definitions.rb
|
62
|
+
- lib/common_steps/step_definitions/navigation_steps.rb
|
63
|
+
- lib/common_steps/step_definitions/record_steps.rb
|
64
|
+
- lib/common_steps/step_definitions/webrat_steps.rb
|
65
|
+
- lib/common_steps/support/database.rb
|
66
|
+
- lib/common_steps/support/email.rb
|
67
|
+
- lib/common_steps/support/env.rb
|
68
|
+
- lib/common_steps/support/spec.rb
|
69
|
+
- lib/common_steps/tasks/cucumber.rake
|
70
|
+
- lib/common_steps/tasks/rspec.rake
|
71
|
+
- spec/common_steps/common_steps_spec.rb
|
72
|
+
- spec/spec.opts
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
- tasks/cucumber.rake
|
75
|
+
- tasks/jeweler.rake
|
76
|
+
- tasks/rdoc.rake
|
77
|
+
- tasks/roodi.rake
|
78
|
+
- tasks/rspec.rake
|
79
|
+
has_rdoc: false
|
80
|
+
homepage: http://github.com/Byclosure/common_steps
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options:
|
83
|
+
- --charset=UTF-8
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
version:
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: "0"
|
97
|
+
version:
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.2.0
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: common_steps. Some common cucumber step definitions, rake tasks, and rspec matchers
|
105
|
+
test_files:
|
106
|
+
- spec/common_steps/common_steps_spec.rb
|
107
|
+
- spec/spec_helper.rb
|