cucumber-farmer 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,34 @@
1
+ ##BUNDLER
2
+ .bundle/
3
+
4
+ ## EMACS
5
+ *~
6
+ \#*
7
+
8
+ ## MAC OS
9
+ .DS_Store
10
+
11
+ ## RUBYMINE
12
+ .idea
13
+ .\#*
14
+
15
+ ## RVM
16
+ .rvmrc
17
+
18
+ ## TEXTMATE
19
+ *.tmproj
20
+ tmtags
21
+
22
+ ## VIM
23
+ *.swp
24
+
25
+ ## PROJECT::GENERAL
26
+ coverage
27
+ rdoc
28
+ pkg
29
+
30
+ ## PROJECT::SPECIFIC
31
+
32
+ ## DOCS
33
+ doc/
34
+ .yardoc/
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source :rubygems
2
+
3
+ gem 'bundler', '~> 1.0'
4
+
5
+ gem 'mattscilipoti-rdialog', '~> 0.6.1'
6
+
7
+ group :test do
8
+ gem 'cucumber', '~> 0.6'
9
+ gem 'shoulda', '~> 2.10'
10
+ gem 'sinatra', '= 1.0'
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Matt Scilipoti
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.
@@ -0,0 +1,80 @@
1
+ = farmer
2
+
3
+ A library of cucumber step definitions, which allow you to use a human to assert conditions during acceptance tests.
4
+
5
+ == Why?
6
+ Some requirements are simple for a human to confirm, but are very difficult to assert using automation.
7
+ Farmer allows us to include human confirmation into our normal testing flow.
8
+ For example, we needed to verify that certain portions of an image were 'blacked out'.
9
+
10
+ == What?
11
+ Farmer utilizes rdialog to allow you to:
12
+ * Present messages
13
+ * Display files
14
+ * Ask a human for confirmation
15
+
16
+ == Example
17
+ When I display the message "Please review the following images. \nEnsure 'Frame' and 'Speed Data' items are hidden."
18
+ And I display these Files:
19
+ |filename|
20
+ |images/processed_a.jpg|
21
+ |images/processed_b.jpg|
22
+
23
+ Then I should say "'Frame' item is hidden in all images"
24
+ Then I should say "'Speed Data' item is hidden in all images"
25
+
26
+ This will:
27
+ * Display an info box to the user, informing them of the upcoming test, then...
28
+ * Open a new page in firefox to display the named files (in tabs).
29
+ * Once the user closes all the tabs, confirmation dialogs will be displayed.
30
+
31
+ == Installation
32
+ $ apt-get install dialog
33
+ $ gem install farmer
34
+
35
+ In features/support/env.rb:
36
+ require 'farmer/step_definitions'
37
+
38
+ == Test
39
+ Two levels of testing are required. Library testing and 'usage as a gem' testing.
40
+ ==== Usage as gem:
41
+ A (sinatra) test app is included, containing some acceptance tests.
42
+ Interestingly, these tests ask you to verify farmer's functionality.
43
+
44
+ cd test_app
45
+ cucumber
46
+
47
+ ==== Test the library:
48
+ This library was extracted from an existing app.
49
+ It was created test-first (mostly), but extracting the tests is harder than extracting code.
50
+ Test are added regularly.
51
+ rake
52
+
53
+ == Questions?
54
+ * Check out step_definitions/dialog_steps.
55
+
56
+ == Issues?
57
+ * Create an issue on github (http://github.com/mattscilipoti/farmer/issues???)
58
+
59
+ == TODO:
60
+ * expand test coverage to unit tests
61
+ * add step_definitions to rdoc.
62
+ * utilize pickle foundation.
63
+ * make dialog timeout configurable.
64
+ * namespace
65
+
66
+ == Note on Patches/Pull Requests
67
+ * Fork the project.
68
+ * Since you will probably want to utilize your own copy, while waiting for upstream to include your pull request,
69
+ I recommend creating a branch named 'upstream'.
70
+ * Make your changes in a topic and merge them into 'master' and 'upstream'.
71
+ This way, 'master' can have your readme, version, etc.
72
+ * Please, do not mess with rakefile or version files in the 'upstream' branch.
73
+ * Add tests for it. This is important. I don't want break it in a
74
+ future version unintentionally.
75
+ * Commit.
76
+ * Send me a pull request from 'upstream' or the topic branch.
77
+
78
+ == Copyright
79
+
80
+ Copyright (c) 2010 Matt Scilipoti. See LICENSE for details.
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "cucumber-farmer"
8
+ gem.summary = 'A library of cucumber step definitions, which allow you to use a human to assert conditions during acceptance tests.'
9
+ gem.description = %Q{A library of cucumber step definitions, which allow you to use a human to assert conditions during acceptance tests.
10
+ Some requirements are simple for a human to confirm, but are very difficult to assert using automation.
11
+ Farmer allows us to include human confirmation into our normal testing flow.
12
+ For example, we needed to verify that certain portions of an image were 'blacked out'.
13
+ }
14
+ gem.email = "matt@scilipoti.name"
15
+ gem.homepage = "http://github.com/mattscilipoti/farmer"
16
+ gem.authors = ["Matt Scilipoti"]
17
+ gem.add_dependency('mattscilipoti-rdialog', '0.6.1')
18
+ gem.add_development_dependency "cucumber", ">= 0.6"
19
+ gem.add_development_dependency "shoulda", ">= 2.10"
20
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
21
+ end
22
+ Jeweler::GemcutterTasks.new
23
+ rescue LoadError
24
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
25
+ end
26
+
27
+ require 'rake/testtask'
28
+ Rake::TestTask.new(:test) do |test|
29
+ test.libs << 'lib' << 'test'
30
+ test.pattern = 'test/**/test_*.rb'
31
+ test.verbose = true
32
+ end
33
+
34
+ begin
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ end
41
+ rescue LoadError
42
+ task :rcov do
43
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
44
+ end
45
+ end
46
+
47
+ task :test => :check_dependencies
48
+
49
+ task :default => :test
50
+
51
+ require 'rake/rdoctask'
52
+ Rake::RDocTask.new do |rdoc|
53
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
54
+
55
+ rdoc.rdoc_dir = 'rdoc'
56
+ rdoc.title = "farmer #{version}"
57
+ rdoc.rdoc_files.include('README*')
58
+ rdoc.rdoc_files.include('lib/**/*.rb')
59
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.1
@@ -0,0 +1,69 @@
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{cucumber-farmer}
8
+ s.version = "1.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Matt Scilipoti"]
12
+ s.date = %q{2010-08-26}
13
+ s.description = %q{A library of cucumber step definitions, which allow you to use a human to assert conditions during acceptance tests.
14
+ Some requirements are simple for a human to confirm, but are very difficult to assert using automation.
15
+ Farmer allows us to include human confirmation into our normal testing flow.
16
+ For example, we needed to verify that certain portions of an image were 'blacked out'.
17
+ }
18
+ s.email = %q{matt@scilipoti.name}
19
+ s.extra_rdoc_files = [
20
+ "LICENSE",
21
+ "README.rdoc"
22
+ ]
23
+ s.files = [
24
+ ".document",
25
+ ".gitignore",
26
+ "Gemfile",
27
+ "LICENSE",
28
+ "README.rdoc",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "cucumber-farmer.gemspec",
32
+ "lib/farmer.rb",
33
+ "lib/farmer/step_definitions.rb",
34
+ "test/helper.rb",
35
+ "test_app/features/home_page.feature",
36
+ "test_app/features/human_confirmation.feature",
37
+ "test_app/features/step_definitions/web_steps.rb",
38
+ "test_app/features/support/env.rb",
39
+ "test_app/test_app.rb"
40
+ ]
41
+ s.homepage = %q{http://github.com/mattscilipoti/farmer}
42
+ s.rdoc_options = ["--charset=UTF-8"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = %q{1.3.7}
45
+ s.summary = %q{A library of cucumber step definitions, which allow you to use a human to assert conditions during acceptance tests.}
46
+ s.test_files = [
47
+ "test/helper.rb"
48
+ ]
49
+
50
+ if s.respond_to? :specification_version then
51
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
+ s.specification_version = 3
53
+
54
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
+ s.add_runtime_dependency(%q<mattscilipoti-rdialog>, ["= 0.6.1"])
56
+ s.add_development_dependency(%q<cucumber>, [">= 0.6"])
57
+ s.add_development_dependency(%q<shoulda>, [">= 2.10"])
58
+ else
59
+ s.add_dependency(%q<mattscilipoti-rdialog>, ["= 0.6.1"])
60
+ s.add_dependency(%q<cucumber>, [">= 0.6"])
61
+ s.add_dependency(%q<shoulda>, [">= 2.10"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<mattscilipoti-rdialog>, ["= 0.6.1"])
65
+ s.add_dependency(%q<cucumber>, [">= 0.6"])
66
+ s.add_dependency(%q<shoulda>, [">= 2.10"])
67
+ end
68
+ end
69
+
File without changes
@@ -0,0 +1,84 @@
1
+ begin
2
+ gem 'mattscilipoti-rdialog', '>=0.5.0'
3
+ require 'mattscilipoti-rdialog'
4
+ rescue LoadError
5
+ puts "REQUIRED: dialog & rdialog are required.\n `sudo apt-get install dialog`\n `gem install mattscilipoti-rdialog`"
6
+ exit
7
+ end
8
+
9
+ # When I display the message "message goes here"'
10
+ #Displays info box containing the message
11
+ When /^I display the message "([^\"]*)"$/ do |message|
12
+ dialog = RDialog.new
13
+ dialog.infobox(message)
14
+ end
15
+
16
+ When /^I display these Files:$/ do |table|
17
+ files = table.rows.collect { |row| row[0] }
18
+
19
+ view_in_firefox(*files)
20
+ end
21
+
22
+ def dialog_timeout
23
+ 5 #seconds
24
+ end
25
+
26
+ # Then I should say "confirmation request goes here"'
27
+ #Displays a dialog box containing the message
28
+ #User response is used to pass/fail the test
29
+ #Cancel/No fails test
30
+ Then /^I should say "([^\"]*)"$/ do |question|
31
+ response = nil
32
+ dialog = RDialog.new
33
+ dialog.timeout = dialog_timeout
34
+ msg = %Q{#{question}?
35
+
36
+ This dialog will timeout after #{dialog_timeout} secs.}
37
+ response = dialog.yesno(question + '?')
38
+
39
+ response.should be_true
40
+ end
41
+
42
+ # Given these warnings are displayed:
43
+ # |dialog |
44
+ # |firefox|
45
+ # Displays named warnings to humans.
46
+ # dialog: inform them that their input will be requested
47
+ # firefox: specifies firefox requirements.
48
+ Given /^(?:these warnings are|this warning is) displayed:$/ do |table|
49
+ table.raw.flatten.inject(warnings = []) do |warning_messages, warning_name|
50
+ msg = warning_for(warning_name)
51
+ warning_messages << msg
52
+ end
53
+
54
+ dialog = RDialog.new
55
+ dialog.timeout = 30 #seconds
56
+ dialog.msgbox(warnings.join('\n--------------------------\n'))
57
+ end
58
+
59
+ def dialog_warning
60
+ <<WARN
61
+ Dialog Warning: Some of these scenarios will ask you to manually verify steps.
62
+ Yes/No dialogs will timeout after #{dialog_timeout} secs.
63
+
64
+ test
65
+ WARN
66
+ end
67
+
68
+ def firefox_warning
69
+ <<WARN
70
+ Firefox Notice: profile 'cucumber' expected.\n
71
+ If this profile doesn't exist, ProfileManager will automatically be displayed so you can add it (or use 'firefox -ProfileManager')
72
+ To ensure tests wait until Firefox is closed, please ensure ALL instances of Firefox using the 'cu Profile are closed.
73
+ You can leave instances from other profiles open.
74
+ WARN
75
+ end
76
+
77
+ def view_in_firefox(*files)
78
+ file_args = files.join(' ')
79
+ `firefox -P cucumber -no-remote #{file_args}`
80
+ end
81
+
82
+ def warning_for(identifier)
83
+ send("#{identifier.to_s}_warning")
84
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'farmer'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,5 @@
1
+ Feature : Home Page experience
2
+
3
+ Scenario: See hello world
4
+ When I visit the home page
5
+ Then I should see "Hello World"
@@ -0,0 +1,27 @@
1
+ Feature: Humans can confirm test results
2
+
3
+ In order to ensure that humans can be utilized and incorporated into acceptance testing flow
4
+ As a human tester
5
+ I want be able to receive information and provide feedback
6
+
7
+ Scenario: Basic Yes/No Dialog
8
+ Then I should say "I can see a yes/no dialog box"
9
+
10
+ Scenario: Info Box
11
+ When I display the message "TEST MESSAGE. Please close me."
12
+ Then I should say "I saw the 'TEST MESSAGE'"
13
+
14
+ Scenario: Single Warning (dialog)
15
+ Given this warning is displayed:
16
+ |dialog|
17
+
18
+ Then I should say "I am aware that dialogs will used for manual verification"
19
+
20
+ Scenario: Multiple warnings (dialog & firefox)
21
+ Given these warnings are displayed:
22
+ |dialog|
23
+ |firefox|
24
+
25
+ Then I should say "I am aware that dialogs will used for manual verification"
26
+ Then I should say "I saw an informational warning about firefox requirements"
27
+
@@ -0,0 +1,7 @@
1
+ When /^I visit the home page$/ do
2
+ visit '/'
3
+ end
4
+
5
+ Then /^I should see "([^\"]*)"$/ do |text|
6
+ assert_contain text
7
+ end
@@ -0,0 +1,39 @@
1
+ # See http://wiki.github.com/aslakhellesoy/cucumber/sinatra
2
+ # for more details about Sinatra with Cucumber
3
+
4
+ app_file = File.expand_path('../../test_app', File.dirname(__FILE__))
5
+ require app_file
6
+
7
+ # Force the application name because polyglot breaks the auto-detection logic.
8
+ Sinatra::Application.app_file = app_file
9
+
10
+ gem 'rack-test', '>=0.5.0'
11
+ require 'test/unit/assertions'
12
+ require 'rack/test'
13
+ require 'webrat'
14
+
15
+ Webrat.configure do |config|
16
+ config.mode = :rack
17
+ end
18
+
19
+ class TestAppWorld
20
+ include Test::Unit::Assertions
21
+ include Rack::Test::Methods
22
+ include Webrat::Methods
23
+ include Webrat::Matchers
24
+ # Webrat::Methods.delegate_to_session :response_code, :response_body
25
+
26
+ def app
27
+ Sinatra::Application
28
+ end
29
+ end
30
+
31
+ #add farmer lib to load path (like gem command would do)
32
+ farmer_lib_path = File.expand_path('../../../lib/', File.dirname(__FILE__))
33
+ $LOAD_PATH.unshift farmer_lib_path
34
+
35
+ #>>>>>>>> Adding farmer steps here >>>>>>>>>>>>>>>>>
36
+ require 'farmer/step_definitions'
37
+ #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
38
+
39
+ World { TestAppWorld.new }
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+
3
+ gem 'sinatra', '=1.0'
4
+ require 'sinatra'
5
+ get '/' do
6
+ 'Hello World'
7
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cucumber-farmer
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 1
10
+ version: 1.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Matt Scilipoti
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-26 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: mattscilipoti-rdialog
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - "="
28
+ - !ruby/object:Gem::Version
29
+ hash: 5
30
+ segments:
31
+ - 0
32
+ - 6
33
+ - 1
34
+ version: 0.6.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: cucumber
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 7
46
+ segments:
47
+ - 0
48
+ - 6
49
+ version: "0.6"
50
+ type: :development
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: shoulda
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 23
61
+ segments:
62
+ - 2
63
+ - 10
64
+ version: "2.10"
65
+ type: :development
66
+ version_requirements: *id003
67
+ description: "A library of cucumber step definitions, which allow you to use a human to assert conditions during acceptance tests.\n Some requirements are simple for a human to confirm, but are very difficult to assert using automation.\n Farmer allows us to include human confirmation into our normal testing flow.\n For example, we needed to verify that certain portions of an image were 'blacked out'.\n "
68
+ email: matt@scilipoti.name
69
+ executables: []
70
+
71
+ extensions: []
72
+
73
+ extra_rdoc_files:
74
+ - LICENSE
75
+ - README.rdoc
76
+ files:
77
+ - .document
78
+ - .gitignore
79
+ - Gemfile
80
+ - LICENSE
81
+ - README.rdoc
82
+ - Rakefile
83
+ - VERSION
84
+ - cucumber-farmer.gemspec
85
+ - lib/farmer.rb
86
+ - lib/farmer/step_definitions.rb
87
+ - test/helper.rb
88
+ - test_app/features/home_page.feature
89
+ - test_app/features/human_confirmation.feature
90
+ - test_app/features/step_definitions/web_steps.rb
91
+ - test_app/features/support/env.rb
92
+ - test_app/test_app.rb
93
+ has_rdoc: true
94
+ homepage: http://github.com/mattscilipoti/farmer
95
+ licenses: []
96
+
97
+ post_install_message:
98
+ rdoc_options:
99
+ - --charset=UTF-8
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ hash: 3
108
+ segments:
109
+ - 0
110
+ version: "0"
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ requirements: []
121
+
122
+ rubyforge_project:
123
+ rubygems_version: 1.3.7
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: A library of cucumber step definitions, which allow you to use a human to assert conditions during acceptance tests.
127
+ test_files:
128
+ - test/helper.rb