cappie 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/Gemfile +3 -0
- data/README.md +53 -0
- data/cappie.gemspec +30 -0
- data/example/app/config.ru +18 -0
- data/example/features/client_side_script.feature +5 -0
- data/example/features/step_definitions/steps.rb +7 -0
- data/example/features/support/env.rb +9 -0
- data/lib/cappie/process.rb +53 -0
- data/lib/cappie/selenium.rb +11 -0
- data/lib/cappie/version.rb +3 -0
- data/lib/cappie.rb +12 -0
- metadata +153 -0
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Cappie
|
2
|
+
|
3
|
+
An instant capybara/cucumber/rspec/selenium-webdriver configuration for web apps that aren't written in Ruby.
|
4
|
+
|
5
|
+
## What does it do?
|
6
|
+
|
7
|
+
* Runs your web app in a child process
|
8
|
+
|
9
|
+
* Waits for your web app to start (by matching a regex against stdout output)
|
10
|
+
|
11
|
+
* Sets up selenium-webdriver to use capybara and rspec expectations
|
12
|
+
|
13
|
+
* Points selenium-webdriver at your web app host
|
14
|
+
|
15
|
+
* Sets selenium as the default capybara driver
|
16
|
+
|
17
|
+
## Install
|
18
|
+
|
19
|
+
1. Include cappie in your Gemfile, e.g.
|
20
|
+
|
21
|
+
source 'https://rubygems.org'
|
22
|
+
|
23
|
+
gem 'cappie'
|
24
|
+
|
25
|
+
2. Install your dependencies via bundler:
|
26
|
+
|
27
|
+
> bundle install
|
28
|
+
|
29
|
+
3. Ensure your web app can be started with a single command, and that it _writes something predictable to stdout when it is ready to accept requests_.
|
30
|
+
|
31
|
+
4. Add cappie into your cucumber environment (features/support/env.rb):
|
32
|
+
|
33
|
+
require 'cappie'
|
34
|
+
|
35
|
+
Cappie.start(
|
36
|
+
command: './serve/my/app --port 8080',
|
37
|
+
await: /listening at 8080/,
|
38
|
+
host: 'http://localhost:8080'
|
39
|
+
)
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
Just add cucumber features and step definitions. Your steps can use use capybara, e.g.
|
44
|
+
|
45
|
+
# features/step_definitions/my_app_steps.rb
|
46
|
+
|
47
|
+
When /^I open my app$/ do
|
48
|
+
visit '/'
|
49
|
+
end
|
50
|
+
|
51
|
+
Then /^I should see my name$/ do
|
52
|
+
page.should have_content("Hello Josh")
|
53
|
+
end
|
data/cappie.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
3
|
+
require "cappie/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'cappie'
|
7
|
+
s.version = Cappie::VERSION
|
8
|
+
s.authors = ["Josh Chisholm"]
|
9
|
+
s.email = "josh@featurist.co.uk"
|
10
|
+
s.description = 'Instant capybara/cucumber/rspec/selenium-webdriver configuration for any web app'
|
11
|
+
s.summary = "cappie-#{s.version}"
|
12
|
+
s.homepage = "http://github.com/featurist/cappie"
|
13
|
+
|
14
|
+
s.platform = Gem::Platform::RUBY
|
15
|
+
|
16
|
+
s.add_runtime_dependency 'cucumber', '>= 1.2.1'
|
17
|
+
s.add_runtime_dependency 'capybara', '>= 2.0.2'
|
18
|
+
s.add_runtime_dependency 'childprocess', '>= 0.3.8'
|
19
|
+
s.add_runtime_dependency 'rspec-expectations', '>= 2.0.1'
|
20
|
+
s.add_runtime_dependency 'selenium-webdriver', '>= 2.29.0'
|
21
|
+
|
22
|
+
s.add_development_dependency 'rack', '>= 1.5.2'
|
23
|
+
|
24
|
+
s.rubygems_version = ">= 1.6.1"
|
25
|
+
s.files = `git ls-files`.split("\n").reject {|path| path =~ /\.gitignore$/ }
|
26
|
+
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
27
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
28
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
29
|
+
s.require_path = "lib"
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rack'
|
2
|
+
|
3
|
+
html = '''
|
4
|
+
<html>
|
5
|
+
<body>
|
6
|
+
<h1>Example App</h1>
|
7
|
+
<div id="placeholder">Placeholder</div>
|
8
|
+
<script>
|
9
|
+
document.getElementById("placeholder").innerHTML = "text created by client-side script";
|
10
|
+
</script>
|
11
|
+
</body>
|
12
|
+
</html>
|
13
|
+
'''
|
14
|
+
|
15
|
+
run lambda { |env|
|
16
|
+
puts 'GET /'
|
17
|
+
[200, {}, [html]]
|
18
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'childprocess'
|
2
|
+
|
3
|
+
module Cappie
|
4
|
+
class Process
|
5
|
+
def initialize(command, await)
|
6
|
+
@command = command
|
7
|
+
@await = await
|
8
|
+
end
|
9
|
+
|
10
|
+
def start
|
11
|
+
args = @command.split(' ')
|
12
|
+
@proc = ChildProcess.build(*args)
|
13
|
+
|
14
|
+
r, w = IO.pipe
|
15
|
+
|
16
|
+
@proc.io.stdout = @proc.io.stderr = w
|
17
|
+
|
18
|
+
@proc.start
|
19
|
+
w.close
|
20
|
+
|
21
|
+
all_output = ""
|
22
|
+
|
23
|
+
begin
|
24
|
+
started = false
|
25
|
+
until started
|
26
|
+
partial = r.readpartial(8192)
|
27
|
+
puts partial if ENV['CAPPIE_DEBUG']
|
28
|
+
all_output << partial
|
29
|
+
if (all_output =~ @await)
|
30
|
+
started = true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
rescue EOFError
|
34
|
+
raise "app exited:\n#{all_output}"
|
35
|
+
end
|
36
|
+
|
37
|
+
Thread.new do
|
38
|
+
while true
|
39
|
+
partial = r.readpartial(8192)
|
40
|
+
puts partial if ENV['CAPPIE_DEBUG']
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
at_exit do
|
45
|
+
@proc.stop 0
|
46
|
+
end
|
47
|
+
|
48
|
+
@proc.io.inherit!
|
49
|
+
|
50
|
+
@proc
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/cappie.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
require 'cappie/version'
|
4
|
+
require 'cappie/process'
|
5
|
+
require 'cappie/selenium'
|
6
|
+
|
7
|
+
module Cappie
|
8
|
+
def self.start(options)
|
9
|
+
Process.new(options[:command], options[:await]).start
|
10
|
+
Selenium.new(options[:host])
|
11
|
+
end
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cappie
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Josh Chisholm
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cucumber
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.2.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.2.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: capybara
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.0.2
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.0.2
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: childprocess
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.3.8
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.8
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec-expectations
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.0.1
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.0.1
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: selenium-webdriver
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 2.29.0
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.29.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rack
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.5.2
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.5.2
|
110
|
+
description: Instant capybara/cucumber/rspec/selenium-webdriver configuration for
|
111
|
+
any web app
|
112
|
+
email: josh@featurist.co.uk
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- Gemfile
|
118
|
+
- README.md
|
119
|
+
- cappie.gemspec
|
120
|
+
- example/app/config.ru
|
121
|
+
- example/features/client_side_script.feature
|
122
|
+
- example/features/step_definitions/steps.rb
|
123
|
+
- example/features/support/env.rb
|
124
|
+
- lib/cappie.rb
|
125
|
+
- lib/cappie/process.rb
|
126
|
+
- lib/cappie/selenium.rb
|
127
|
+
- lib/cappie/version.rb
|
128
|
+
homepage: http://github.com/featurist/cappie
|
129
|
+
licenses: []
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options:
|
132
|
+
- --charset=UTF-8
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ! '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ! '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 1.8.24
|
150
|
+
signing_key:
|
151
|
+
specification_version: 3
|
152
|
+
summary: cappie-0.0.1
|
153
|
+
test_files: []
|