coulda_web_steps 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "json", "~> 1.4.6"
4
+ gem "coulda", "~> 0.6.0"
5
+ gem "capybara", "~> 0.4.0"
6
+ gem "factory_girl", "~> 1.3.2"
7
+
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "yard", "~> 0.6.0"
11
+ gem "bundler", "~> 1.0.0"
12
+ gem "jeweler", "~> 1.5.1"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,56 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ capybara (0.4.0)
5
+ celerity (>= 0.7.9)
6
+ culerity (>= 0.2.4)
7
+ mime-types (>= 1.16)
8
+ nokogiri (>= 1.3.3)
9
+ rack (>= 1.0.0)
10
+ rack-test (>= 0.5.4)
11
+ selenium-webdriver (>= 0.0.27)
12
+ xpath (~> 0.1.2)
13
+ celerity (0.8.6)
14
+ childprocess (0.1.4)
15
+ ffi (~> 0.6.3)
16
+ coulda (0.6.1)
17
+ culerity (0.2.12)
18
+ factory_girl (1.3.2)
19
+ ffi (0.6.3)
20
+ rake (>= 0.8.7)
21
+ git (1.2.5)
22
+ jeweler (1.5.1)
23
+ bundler (~> 1.0.0)
24
+ git (>= 1.2.5)
25
+ rake
26
+ json (1.4.6)
27
+ json_pure (1.4.6)
28
+ mime-types (1.16)
29
+ nokogiri (1.4.4)
30
+ rack (1.2.1)
31
+ rack-test (0.5.6)
32
+ rack (>= 1.0)
33
+ rake (0.8.7)
34
+ rubyzip (0.9.4)
35
+ selenium-webdriver (0.1.1)
36
+ childprocess (= 0.1.4)
37
+ ffi (~> 0.6.3)
38
+ json_pure
39
+ rubyzip
40
+ shoulda (2.11.3)
41
+ xpath (0.1.2)
42
+ nokogiri (~> 1.3)
43
+ yard (0.6.3)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ bundler (~> 1.0.0)
50
+ capybara (~> 0.4.0)
51
+ coulda (~> 0.6.0)
52
+ factory_girl (~> 1.3.2)
53
+ jeweler (~> 1.5.1)
54
+ json (~> 1.4.6)
55
+ shoulda
56
+ yard (~> 0.6.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 elight
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
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,35 @@
1
+ = coulda_web_steps
2
+
3
+ Coulda web steps provides some preliminary reusable steps for Coulda.
4
+
5
+
6
+ == Usage
7
+
8
+ Write the following in your test_helper:
9
+
10
+ Coulda.default_test_case_class = Test::Unit::TestCase
11
+ class Test::Unit::TestCase
12
+ extend Coulda::WebSteps
13
+ end
14
+
15
+ == Contributing to coulda_web_steps
16
+
17
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
18
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
19
+ * Fork the project
20
+ * Start a feature/bugfix branch
21
+ * Commit and push until you are happy with your contribution
22
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. (No there aren't tests for this code yet; however, almost all of it is running in a project somewhere already and working.)
23
+ * Please try not to mess with the Rakefile or VERSION. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
24
+
25
+ == Contributions
26
+
27
+ Thanks to the following for letting me OSS this:
28
+ * WiseView
29
+ * Amit Lubling and Zack Cleary
30
+ * djbrowning[http://github.com/djbrowning] for the seed of what became "#given_a"
31
+
32
+ == Copyright
33
+
34
+ Copyright (c) 2010, 2011 Evan Light. See LICENSE.txt for further details.
35
+
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "coulda_web_steps"
16
+ gem.homepage = "http://github.com/elight/coulda_web_steps"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{TODO: one-line summary of your gem}
19
+ gem.description = %Q{TODO: longer description of your gem}
20
+ gem.email = "evan@tripledogdare.net"
21
+ gem.authors = ["elight"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ task :default => :test
37
+
38
+ require 'yard'
39
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.6.1
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
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{coulda_web_steps}
8
+ s.version = "0.6.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["elight"]
12
+ s.date = %q{2010-12-17}
13
+ s.description = %q{Collection of web automation steps for coulda}
14
+ s.email = %q{evan@tripledogdare.net}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "coulda_web_steps.gemspec",
28
+ "lib/coulda_web_steps.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/elight/coulda_web_steps}
31
+ s.licenses = ["MIT"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.7}
34
+ s.summary = %q{Collection of web automation steps for coulda}
35
+
36
+ if s.respond_to? :specification_version then
37
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
+ s.specification_version = 3
39
+
40
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
+ s.add_runtime_dependency(%q<json>, ["~> 1.4.6"])
42
+ s.add_runtime_dependency(%q<coulda>, ["~> 0.6.0"])
43
+ s.add_runtime_dependency(%q<capybara>, ["~> 0.4.0"])
44
+ s.add_runtime_dependency(%q<factory_girl>, ["~> 1.3.2"])
45
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
46
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
47
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
48
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
49
+ else
50
+ s.add_dependency(%q<json>, ["~> 1.4.6"])
51
+ s.add_dependency(%q<coulda>, ["~> 0.6.0"])
52
+ s.add_dependency(%q<capybara>, ["~> 0.4.0"])
53
+ s.add_dependency(%q<factory_girl>, ["~> 1.3.2"])
54
+ s.add_dependency(%q<shoulda>, [">= 0"])
55
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<json>, ["~> 1.4.6"])
61
+ s.add_dependency(%q<coulda>, ["~> 0.6.0"])
62
+ s.add_dependency(%q<capybara>, ["~> 0.4.0"])
63
+ s.add_dependency(%q<factory_girl>, ["~> 1.3.2"])
64
+ s.add_dependency(%q<shoulda>, [">= 0"])
65
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
66
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
68
+ end
69
+ end
70
+
@@ -0,0 +1,128 @@
1
+ module Coulda
2
+ module WebSteps
3
+ # Creates an object using a factory_girl factory and creates a Given step that reads like
4
+ # "Given a gi_joe with a name of 'Blowtorch' and habit of 'swearing'"
5
+ # @param factory_name A Symbol or String for the name of the factory_girl factory to use
6
+ # @param args Arguments to supply to the *factory_name* factory_girl factory
7
+ def given_a(factory_name, args = {})
8
+ Given "a #{factory_name} #{humanize args}" do
9
+ args.each do |key, value|
10
+ if value.is_a? Symbol
11
+ instance_var_named_value = instance_variable_get("@#{value}")
12
+ args[key] = instance_var_named_value if instance_var_named_value
13
+ end
14
+ end
15
+ model = Factory(factory_name.to_sym, args)
16
+ instance_variable_set("@#{factory_name}", model)
17
+ end
18
+ end
19
+
20
+ # Asserts that the current page has *content* and a Then step that reads like
21
+ # "Then I should see 'You're not cookin!'"
22
+ # @param content The content to check for.
23
+ def then_i_should_see(content)
24
+ Then "I should see '#{content}'" do
25
+ assert page.has_content?(content), "Page doesn't have \"#{content}\""
26
+ end
27
+ end
28
+
29
+ # Asserts that the current page does not have *content* and a Then step that reads like
30
+ # "Then I should not see 'Who'd like a body massage?'"
31
+ # @param content The content to check for.
32
+ def then_i_should_not_see(content)
33
+ Then "I should not see '#{content}'" do
34
+ assert !page.has_content?(content), "Page has \"#{content}\""
35
+ end
36
+ end
37
+
38
+ # Asserts that the response contains JSON, parses it into a hash, stores it in *@json*, and
39
+ # creates a "Then I should get a JSON response" step
40
+ def then_i_should_have_a_json_response
41
+ Then "I should get a JSON response" do
42
+ assert_equal "application/json", @response.content_type
43
+ @json = JSON.parse(@response.body)
44
+ end
45
+ end
46
+
47
+ # Asserts the HTTP status code to be *status* and creates a step like
48
+ # "Then I should receive a 200 response"
49
+ # @param status The expected HTTP status code as a Fixnum
50
+ def then_i_should_receive_a(status)
51
+ Then "I should receive a #{status} response" do
52
+ assert_equal status, @response.status
53
+ end
54
+ end
55
+
56
+ # Asserts that the a flash is on the page, that it has a class of *level* and the expected *message*.
57
+ # and creates a step like "Then I should see the flash error 'PORKCHOP SANDWICHES'"
58
+ # @param level The expected class of the flash on the page: "notice" or "error"
59
+ # @param message The expected message in the flash
60
+ def then_i_should_see_flash(level, message)
61
+ Then "I should see the flash #{level} '#{message}'" do
62
+ assert find("#flash").find(".#{level}").has_content? message
63
+ end
64
+ end
65
+
66
+ # Visits the page specified by *path* and creates a step like
67
+ # "When I visit the pork chop sandwich kitchen"
68
+ # @param path A Symbol giving the name of the helper to invoke to generate a path
69
+ # @param args Symbols representing the names of member variables set in previous steps
70
+ # (see #{WebSteps#given_a} method)
71
+ def when_i_visit(path, *args)
72
+ humanized_path = path.to_s.gsub /_/, " "
73
+ When "I visit the #{humanized_path}" do
74
+ visit __send__(path)
75
+ end
76
+ end
77
+
78
+ # Clicks the link specified by *link* and generates a step like
79
+ # "When I click the link 'Get the f**k out!'"
80
+ # @param link The name of the link to click
81
+ def when_i_click_link(link)
82
+ When "I click the link '#{link}'" do
83
+ click_link link.to_s
84
+ end
85
+ end
86
+
87
+ # Clicks the button specified by *button* and generates a step like
88
+ # "When I click the button 'What are you doing?!'"
89
+ # @param button The name of the button to click
90
+ def when_i_click_button(button)
91
+ When "I click the button '#{button}'" do
92
+ click_button button.to_s
93
+ end
94
+ end
95
+
96
+ private
97
+
98
+ def humanize(hash)
99
+ str = ""
100
+ if !hash.empty?
101
+ str << "with "
102
+ hash.each_with_index do |kv, idx|
103
+ str << choose_conjunction_given(hash, :and_idx => idx)
104
+ key, value = kv.first, kv.second
105
+ str << "#{key} of '#{value}'"
106
+ end
107
+ str
108
+ end
109
+ end
110
+
111
+ def choose_conjunction_given(args_hash, args = {})
112
+ idx = args[:and_idx]
113
+ conj = ""
114
+ if idx > 0
115
+ if args_hash.length > 2
116
+ if idx < args_hash.length - 1
117
+ conj = ", "
118
+ else
119
+ conj = ", and "
120
+ end
121
+ else
122
+ conj = " and "
123
+ end
124
+ end
125
+ conj
126
+ end
127
+ end
128
+ end
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coulda_web_steps
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 6
8
+ - 1
9
+ version: 0.6.1
10
+ platform: ruby
11
+ authors:
12
+ - elight
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-12-17 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: json
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 4
31
+ - 6
32
+ version: 1.4.6
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: coulda
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ - 6
46
+ - 0
47
+ version: 0.6.0
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: capybara
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
+ - 4
61
+ - 0
62
+ version: 0.4.0
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: factory_girl
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 1
75
+ - 3
76
+ - 2
77
+ version: 1.3.2
78
+ type: :runtime
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: shoulda
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ type: :development
92
+ version_requirements: *id005
93
+ - !ruby/object:Gem::Dependency
94
+ name: yard
95
+ prerelease: false
96
+ requirement: &id006 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ segments:
102
+ - 0
103
+ - 6
104
+ - 0
105
+ version: 0.6.0
106
+ type: :development
107
+ version_requirements: *id006
108
+ - !ruby/object:Gem::Dependency
109
+ name: bundler
110
+ prerelease: false
111
+ requirement: &id007 !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ~>
115
+ - !ruby/object:Gem::Version
116
+ segments:
117
+ - 1
118
+ - 0
119
+ - 0
120
+ version: 1.0.0
121
+ type: :development
122
+ version_requirements: *id007
123
+ - !ruby/object:Gem::Dependency
124
+ name: jeweler
125
+ prerelease: false
126
+ requirement: &id008 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ segments:
132
+ - 1
133
+ - 5
134
+ - 1
135
+ version: 1.5.1
136
+ type: :development
137
+ version_requirements: *id008
138
+ description: Collection of web automation steps for coulda
139
+ email: evan@tripledogdare.net
140
+ executables: []
141
+
142
+ extensions: []
143
+
144
+ extra_rdoc_files:
145
+ - LICENSE.txt
146
+ - README.rdoc
147
+ files:
148
+ - .document
149
+ - Gemfile
150
+ - Gemfile.lock
151
+ - LICENSE.txt
152
+ - README.rdoc
153
+ - Rakefile
154
+ - VERSION
155
+ - coulda_web_steps.gemspec
156
+ - lib/coulda_web_steps.rb
157
+ has_rdoc: true
158
+ homepage: http://github.com/elight/coulda_web_steps
159
+ licenses:
160
+ - MIT
161
+ post_install_message:
162
+ rdoc_options: []
163
+
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ none: false
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ segments:
172
+ - 0
173
+ version: "0"
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ segments:
180
+ - 0
181
+ version: "0"
182
+ requirements: []
183
+
184
+ rubyforge_project:
185
+ rubygems_version: 1.3.7
186
+ signing_key:
187
+ specification_version: 3
188
+ summary: Collection of web automation steps for coulda
189
+ test_files: []
190
+