cuke-island 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +16 -3
- data/features/step_definitions/file_steps.rb +12 -0
- data/features/step_definitions/web_steps.rb +6 -1
- data/features/support/env.rb +57 -2
- data/lib/cuke_island.rb +3 -1
- metadata +20 -2
data/README.rdoc
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
|
3
3
|
== Introduction
|
4
4
|
|
5
|
-
We here at Carney+Co have not discovered how to limit ourselves to Rails only projects yet so we have come up with a simple generator gem that will create a standalone cucumber test inviroment in a folder of our choice. This is a kind of one stop method with the exception of some depdendencies to have the best and easiest to maniupulate test evnironment possible.
|
5
|
+
We here at {Carney+Co}[http://carney.co/] have not discovered how to limit ourselves to Rails only projects yet so we have come up with a simple generator gem that will create a standalone cucumber test inviroment in a folder of our choice. This is a kind of one stop method with the exception of some depdendencies to have the best and easiest to maniupulate test evnironment possible.
|
6
6
|
|
7
|
-
I have expanded this work from the original Author Todd Huss from which this project is forked. I basically added in some extra smarts from the internets to integrate webkit and chromedriver to the installation
|
7
|
+
I have expanded this work from the original Author Todd Huss from which this project is forked. I basically added in some extra smarts from the internets to integrate webkit and chromedriver to the installation.
|
8
|
+
|
9
|
+
Some enhancements over the parent are a nice growing list of generic web_steps and file handling capabilities for downloading and uploading files to your sites.
|
8
10
|
|
9
11
|
http://blogs.kent.ac.uk/webdev/2012/08/02/using-capybara-webkit-with-cucumber-without-rails-or-rack/
|
10
12
|
|
@@ -15,6 +17,16 @@ http://collectiveidea.com/blog/archives/2011/09/27/use-chrome-with-cucumber-capy
|
|
15
17
|
I have also upgraded all the associated gems from the parent project so this install is far easier to get running out of the box
|
16
18
|
|
17
19
|
|
20
|
+
== Changelog
|
21
|
+
|
22
|
+
0.0.4 First Version
|
23
|
+
|
24
|
+
0.0.5 Added more web_steps
|
25
|
+
|
26
|
+
0.0.6 Configuration of Capybara.app_host from command line and existing deployed test instance upgrade strategy
|
27
|
+
|
28
|
+
0.0.7 File download handling through file_steps - This provides a waiting mechanism inspired by http://collectiveidea.com/blog/archives/2012/01/27/testing-file-downloads-with-capybara-and-chromedriver/
|
29
|
+
|
18
30
|
== From the original author
|
19
31
|
I've included a simple search.feature examples that uses Google. To switch to use your own development or staging server adjust the URL in features/support/env.rb. I have this example project setup to use Capybara with Webdriver (Selenium) but you can easily switch this to use Culerity or Webrat by editing features/support/env.rb.
|
20
32
|
|
@@ -43,7 +55,8 @@ Pull requests with updates/enhancements/bug fixes are always welcome!
|
|
43
55
|
== Setting up a test enviornmnet
|
44
56
|
|
45
57
|
* gem install cuke-island
|
46
|
-
* cuke-island <Directory to house testing files>
|
58
|
+
* cuke-island <Directory to house testing files> [<Domain Name (http://google.com)>]
|
59
|
+
* * This second option will replace the Capybara.app_host = 'http://www.google.com' with your value.
|
47
60
|
|
48
61
|
== Running Features
|
49
62
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Then /^I should get a download with the filename "([^\"]*)"$/ do |filename|
|
2
|
+
download_name.should include filename
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^I upload a downloaded file to "([^\"]*)"$/ do |field|
|
6
|
+
#downloads.include? filename
|
7
|
+
attach_file(field, downloads.first)
|
8
|
+
end
|
9
|
+
|
10
|
+
Then /^I should clear downloads$/ do
|
11
|
+
clear_downloads
|
12
|
+
end
|
@@ -48,7 +48,6 @@ end
|
|
48
48
|
When /^I sign in as "(.*?)"$/ do |arg1|
|
49
49
|
fill_in("username", :with => arg1.split("/")[0])
|
50
50
|
fill_in("password", :with => arg1.split("/")[1])
|
51
|
-
click_button('Login')
|
52
51
|
end
|
53
52
|
|
54
53
|
When /^I sign into facebook as "(.*?)"$/ do |arg1|
|
@@ -61,6 +60,12 @@ When /^I click the "([^"]*)" link$/ do |link_text|
|
|
61
60
|
click_link link_text
|
62
61
|
end
|
63
62
|
|
63
|
+
When /^I click the first "([^"]*)" link$/ do |link_text|
|
64
|
+
first(:link, link_text).click
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
#clicks a button with the id specified by button_text. You must have javascript enabled (@javascript at top of feature) to use this webstep
|
64
69
|
When /^I click the "([^"]*)" button$/ do |button_text|
|
65
70
|
click_button button_text
|
66
71
|
end
|
data/features/support/env.rb
CHANGED
@@ -2,7 +2,52 @@ begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations
|
|
2
2
|
require 'capybara'
|
3
3
|
require 'capybara/dsl'
|
4
4
|
require 'capybara/cucumber'
|
5
|
+
require "selenium/webdriver"
|
5
6
|
|
7
|
+
module DownloadHelpers
|
8
|
+
TIMEOUT = 120
|
9
|
+
#Put downloads at the same
|
10
|
+
PATH = File.expand_path (File.dirname(__FILE__)) + "/../../downloads"
|
11
|
+
|
12
|
+
extend self
|
13
|
+
|
14
|
+
def downloads
|
15
|
+
Dir[PATH + "/**"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def download
|
19
|
+
downloads.first
|
20
|
+
end
|
21
|
+
|
22
|
+
def download_name
|
23
|
+
wait_for_download
|
24
|
+
File.basename(download)
|
25
|
+
end
|
26
|
+
|
27
|
+
def download_content
|
28
|
+
wait_for_download
|
29
|
+
File.read(download)
|
30
|
+
end
|
31
|
+
|
32
|
+
def wait_for_download
|
33
|
+
Timeout.timeout(TIMEOUT) do
|
34
|
+
sleep 0.1 until downloaded?
|
35
|
+
end
|
36
|
+
puts downloads
|
37
|
+
end
|
38
|
+
|
39
|
+
def downloaded?
|
40
|
+
!downloading? && downloads.any?
|
41
|
+
end
|
42
|
+
|
43
|
+
def downloading?
|
44
|
+
downloads.grep(/\.crdownload$/).any?
|
45
|
+
end
|
46
|
+
|
47
|
+
def clear_downloads
|
48
|
+
FileUtils.rm_f(downloads)
|
49
|
+
end
|
50
|
+
end
|
6
51
|
|
7
52
|
Capybara.app_host = 'http://www.google.com'
|
8
53
|
|
@@ -17,10 +62,20 @@ Capybara.default_driver = :webkit
|
|
17
62
|
|
18
63
|
#Use ChromeDriver
|
19
64
|
Capybara.register_driver :chrome do |app|
|
20
|
-
|
65
|
+
profile = Selenium::WebDriver::Chrome::Profile.new
|
66
|
+
profile["download.default_directory"] = DownloadHelpers::PATH.to_s
|
67
|
+
Capybara::Selenium::Driver.new(app, :browser => :chrome, :profile => profile)
|
21
68
|
end
|
22
69
|
Capybara.javascript_driver = :chrome
|
23
70
|
|
71
|
+
World(Capybara)
|
72
|
+
World(DownloadHelpers)
|
24
73
|
|
74
|
+
at_exit do
|
75
|
+
DownloadHelpers.clear_downloads
|
76
|
+
end
|
25
77
|
|
26
|
-
|
78
|
+
AfterStep('@pause') do
|
79
|
+
print "Press Return to continue"
|
80
|
+
STDIN.getc
|
81
|
+
end
|
data/lib/cuke_island.rb
CHANGED
@@ -6,7 +6,7 @@ require 'fileutils'
|
|
6
6
|
class CukeIsland < Thor::Group
|
7
7
|
include Thor::Actions
|
8
8
|
|
9
|
-
VERSION = "0.0.
|
9
|
+
VERSION = "0.0.7"
|
10
10
|
|
11
11
|
argument :dir_name
|
12
12
|
argument :hostdomain, :optional => true
|
@@ -34,6 +34,7 @@ class CukeIsland < Thor::Group
|
|
34
34
|
|
35
35
|
def features_directory_and_files
|
36
36
|
empty_directory 'features'
|
37
|
+
empty_directory 'downloads'
|
37
38
|
|
38
39
|
inside 'features' do
|
39
40
|
template '../search.feature.off', 'search.feature.sample'
|
@@ -44,6 +45,7 @@ class CukeIsland < Thor::Group
|
|
44
45
|
end
|
45
46
|
empty_directory 'step_definitions'
|
46
47
|
template '../step_definitions/web_steps.rb', 'step_definitions/web_steps.rb'
|
48
|
+
template '../step_definitions/file_steps.rb', 'step_definitions/file_steps.rb'
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuke-island
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Paul Scarrone
|
9
9
|
- Todd Huss
|
10
|
+
- Julian Toker
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2013-
|
14
|
+
date: 2013-03-22 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: thor
|
@@ -124,6 +125,22 @@ dependencies:
|
|
124
125
|
- - '='
|
125
126
|
- !ruby/object:Gem::Version
|
126
127
|
version: 1.1.0
|
128
|
+
- !ruby/object:Gem::Dependency
|
129
|
+
name: selenium-webdriver
|
130
|
+
requirement: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - '='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 2.30.0
|
136
|
+
type: :runtime
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - '='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: 2.30.0
|
127
144
|
description: ! 'Standalone generator for a lightly configured cucumber capybara chromedriver
|
128
145
|
test enviroment: cuke-island <test folder>'
|
129
146
|
email: paul.scarrone@gmail.com
|
@@ -138,6 +155,7 @@ files:
|
|
138
155
|
- Gemfile
|
139
156
|
- Rakefile
|
140
157
|
- features/search.feature.off
|
158
|
+
- features/step_definitions/file_steps.rb
|
141
159
|
- features/step_definitions/web_steps.rb
|
142
160
|
- features/support/env.rb
|
143
161
|
- README.rdoc
|