cappie 0.0.1 → 0.0.2
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.
- checksums.yaml +7 -0
- data/README.md +8 -4
- data/cappie.gemspec +2 -1
- data/example/app/config.ru +6 -5
- data/example/features/client_side_script.feature +5 -1
- data/example/features/step_definitions/steps.rb +7 -2
- data/example/features/support/env.rb +6 -3
- data/lib/cappie/driver.rb +12 -0
- data/lib/cappie/process.rb +23 -6
- data/lib/cappie/version.rb +1 -1
- data/lib/cappie.rb +6 -4
- data/spec/cappie/example_app.rb +5 -0
- data/spec/cappie/process_spec.rb +42 -0
- metadata +40 -36
- data/lib/cappie/selenium.rb +0 -11
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: f5c6ba37d4f3d93fdbcdae68a68aeded6587fd95
|
|
4
|
+
data.tar.gz: 70135c802bd6c61024e91f138b723d86059672a9
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 78b27d92da3917984e9e36c0df919b6f926618baab8707805740c88dbf81a076c3c28cdc66441d133c4835e217d41a6358caf024c5dca591a0b9c8edd3003215
|
|
7
|
+
data.tar.gz: d93f25f78ba7ff0987fbabd901d5fe7f2d7630d369e83ca1eecee703b0078b215ff5d60d556da10e42523fcd081d8d7fcc52e68d11b4b30ab38cea82f3b5f83a
|
data/README.md
CHANGED
|
@@ -35,8 +35,12 @@ An instant capybara/cucumber/rspec/selenium-webdriver configuration for web apps
|
|
|
35
35
|
Cappie.start(
|
|
36
36
|
command: './serve/my/app --port 8080',
|
|
37
37
|
await: /listening at 8080/,
|
|
38
|
-
host: 'http://localhost:8080'
|
|
38
|
+
host: 'http://localhost:8080',
|
|
39
|
+
driver: :poltergeist,
|
|
40
|
+
environment: { variable: 'value' }
|
|
39
41
|
)
|
|
42
|
+
|
|
43
|
+
(driver and environment are optional)
|
|
40
44
|
|
|
41
45
|
## Usage
|
|
42
46
|
|
|
@@ -47,7 +51,7 @@ Just add cucumber features and step definitions. Your steps can use use capybara
|
|
|
47
51
|
When /^I open my app$/ do
|
|
48
52
|
visit '/'
|
|
49
53
|
end
|
|
50
|
-
|
|
51
|
-
Then /^I should see my
|
|
52
|
-
page.should have_content(
|
|
54
|
+
|
|
55
|
+
Then /^I should see something rendered by my app$/ do
|
|
56
|
+
page.should have_content('Hello from my app')
|
|
53
57
|
end
|
data/cappie.gemspec
CHANGED
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
s.add_runtime_dependency 'childprocess', '>= 0.3.8'
|
|
19
19
|
s.add_runtime_dependency 'rspec-expectations', '>= 2.0.1'
|
|
20
20
|
s.add_runtime_dependency 'selenium-webdriver', '>= 2.29.0'
|
|
21
|
+
s.add_runtime_dependency 'poltergeist', '>= 1.1.1'
|
|
21
22
|
|
|
22
23
|
s.add_development_dependency 'rack', '>= 1.5.2'
|
|
23
24
|
|
|
@@ -27,4 +28,4 @@ Gem::Specification.new do |s|
|
|
|
27
28
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
28
29
|
s.rdoc_options = ["--charset=UTF-8"]
|
|
29
30
|
s.require_path = "lib"
|
|
30
|
-
end
|
|
31
|
+
end
|
data/example/app/config.ru
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
require 'rack'
|
|
2
2
|
|
|
3
|
-
html =
|
|
3
|
+
html = """
|
|
4
4
|
<html>
|
|
5
5
|
<body>
|
|
6
6
|
<h1>Example App</h1>
|
|
7
|
-
<div id=
|
|
7
|
+
<div id='placeholder'>Placeholder</div>
|
|
8
8
|
<script>
|
|
9
|
-
document.getElementById(
|
|
9
|
+
document.getElementById('placeholder').innerHTML = 'text created by client-side script';
|
|
10
10
|
</script>
|
|
11
|
+
<div>#{ENV.inspect}</div>
|
|
11
12
|
</body>
|
|
12
13
|
</html>
|
|
13
|
-
|
|
14
|
+
"""
|
|
14
15
|
|
|
15
16
|
run lambda { |env|
|
|
16
17
|
puts 'GET /'
|
|
17
18
|
[200, {}, [html]]
|
|
18
|
-
}
|
|
19
|
+
}
|
|
@@ -2,4 +2,8 @@ Feature: Client-Side Script
|
|
|
2
2
|
|
|
3
3
|
Scenario: Visiting a page with client-side script
|
|
4
4
|
When I open my app
|
|
5
|
-
Then
|
|
5
|
+
Then my client-side script is executed
|
|
6
|
+
|
|
7
|
+
Scenario: Passing ENV vars
|
|
8
|
+
When I open my app
|
|
9
|
+
Then I see the environment variables
|
|
@@ -2,6 +2,11 @@ When /^I open my app$/ do
|
|
|
2
2
|
visit '/'
|
|
3
3
|
end
|
|
4
4
|
|
|
5
|
-
Then /^
|
|
5
|
+
Then /^my client\-side script is executed$/ do
|
|
6
6
|
page.should have_content("text created by client-side script")
|
|
7
|
-
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Then /^I see the environment variables$/ do
|
|
10
|
+
page.should have_content("foo")
|
|
11
|
+
page.should have_content("bar")
|
|
12
|
+
end
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
require_relative '../../../lib/cappie'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
app_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "app"))
|
|
4
|
+
app_path = File.expand_path(File.join(app_dir, "config.ru"))
|
|
4
5
|
|
|
5
6
|
Cappie.start(
|
|
6
7
|
command: "bundle exec rackup #{app_path}",
|
|
7
8
|
await: /9292/,
|
|
8
|
-
host: "http://localhost:9292"
|
|
9
|
-
|
|
9
|
+
host: "http://localhost:9292",
|
|
10
|
+
environment: {foo: 'bar'},
|
|
11
|
+
driver: :poltergeist
|
|
12
|
+
)
|
data/lib/cappie/process.rb
CHANGED
|
@@ -2,15 +2,20 @@ require 'childprocess'
|
|
|
2
2
|
|
|
3
3
|
module Cappie
|
|
4
4
|
class Process
|
|
5
|
-
def initialize(
|
|
6
|
-
@command = command
|
|
7
|
-
@await = await
|
|
5
|
+
def initialize(options)
|
|
6
|
+
@command = options.delete(:command)
|
|
7
|
+
@await = options.delete(:await)
|
|
8
|
+
@working_dir = options.delete(:working_dir)
|
|
9
|
+
@environment = options.delete(:environment)
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
def start
|
|
11
13
|
args = @command.split(' ')
|
|
12
14
|
@proc = ChildProcess.build(*args)
|
|
13
15
|
|
|
16
|
+
setup_cwd
|
|
17
|
+
setup_environment
|
|
18
|
+
|
|
14
19
|
r, w = IO.pipe
|
|
15
20
|
|
|
16
21
|
@proc.io.stdout = @proc.io.stderr = w
|
|
@@ -31,7 +36,7 @@ module Cappie
|
|
|
31
36
|
end
|
|
32
37
|
end
|
|
33
38
|
rescue EOFError
|
|
34
|
-
raise "app exited:\n#{all_output}"
|
|
39
|
+
raise ProcessExitedError.new "The app process exited\nSTDOUT:\n#{all_output}"
|
|
35
40
|
end
|
|
36
41
|
|
|
37
42
|
Thread.new do
|
|
@@ -42,12 +47,24 @@ module Cappie
|
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
at_exit do
|
|
45
|
-
@proc.stop
|
|
50
|
+
@proc.stop
|
|
46
51
|
end
|
|
47
52
|
|
|
48
53
|
@proc.io.inherit!
|
|
49
54
|
|
|
50
55
|
@proc
|
|
51
56
|
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
def setup_environment
|
|
61
|
+
@environment.each { |key, value| @proc.environment[key] = value } unless @environment.nil?
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def setup_cwd
|
|
65
|
+
@proc.cwd = @working_dir unless @working_dir.nil?
|
|
66
|
+
end
|
|
52
67
|
end
|
|
53
|
-
|
|
68
|
+
|
|
69
|
+
class ProcessExitedError < RuntimeError; end
|
|
70
|
+
end
|
data/lib/cappie/version.rb
CHANGED
data/lib/cappie.rb
CHANGED
|
@@ -2,11 +2,13 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
|
2
2
|
|
|
3
3
|
require 'cappie/version'
|
|
4
4
|
require 'cappie/process'
|
|
5
|
-
require 'cappie/
|
|
5
|
+
require 'cappie/driver'
|
|
6
6
|
|
|
7
7
|
module Cappie
|
|
8
8
|
def self.start(options)
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
host = options.delete(:host)
|
|
10
|
+
driver = options.delete(:driver) || :selenium
|
|
11
|
+
Process.new(options).start
|
|
12
|
+
Driver.new(driver, host)
|
|
11
13
|
end
|
|
12
|
-
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require_relative '../../lib/cappie/process'
|
|
2
|
+
|
|
3
|
+
module Cappie
|
|
4
|
+
|
|
5
|
+
describe Process do
|
|
6
|
+
|
|
7
|
+
def example_app_path
|
|
8
|
+
File.join(File.dirname(__FILE__), "example_app.rb")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'runs a process and awaits some output' do
|
|
12
|
+
process = Process.new(command: "ruby #{example_app_path}", await: /#{Dir.pwd}/).start
|
|
13
|
+
process.should be_alive
|
|
14
|
+
process.stop
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'sets environment variables' do
|
|
18
|
+
process = Process.new(command: "ruby #{example_app_path}", environment: { FOO: 'omg' }, await: /omg/).start
|
|
19
|
+
process.should be_alive
|
|
20
|
+
process.stop
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'accepts a working directory' do
|
|
24
|
+
dir = File.dirname(__FILE__)
|
|
25
|
+
Dir.chdir dir do
|
|
26
|
+
process = Process.new(command: "ruby #{example_app_path}", await: /#{dir}/).start
|
|
27
|
+
process.should be_alive
|
|
28
|
+
process.stop
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe 'when the process exits' do
|
|
33
|
+
it 'raises an exception with the stdout output' do
|
|
34
|
+
lambda {
|
|
35
|
+
Process.new(command: 'pwd').start
|
|
36
|
+
}.should raise_error("The app process exited\nSTDOUT:\n#{Dir.pwd}\n")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
metadata
CHANGED
|
@@ -1,110 +1,111 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cappie
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.0.2
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Josh Chisholm
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date: 2013-
|
|
11
|
+
date: 2013-05-17 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: cucumber
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- -
|
|
17
|
+
- - '>='
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
19
|
version: 1.2.1
|
|
22
20
|
type: :runtime
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
|
-
- -
|
|
24
|
+
- - '>='
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
26
|
version: 1.2.1
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
|
31
28
|
name: capybara
|
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
|
33
|
-
none: false
|
|
34
30
|
requirements:
|
|
35
|
-
- -
|
|
31
|
+
- - '>='
|
|
36
32
|
- !ruby/object:Gem::Version
|
|
37
33
|
version: 2.0.2
|
|
38
34
|
type: :runtime
|
|
39
35
|
prerelease: false
|
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
37
|
requirements:
|
|
43
|
-
- -
|
|
38
|
+
- - '>='
|
|
44
39
|
- !ruby/object:Gem::Version
|
|
45
40
|
version: 2.0.2
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
|
47
42
|
name: childprocess
|
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
|
49
|
-
none: false
|
|
50
44
|
requirements:
|
|
51
|
-
- -
|
|
45
|
+
- - '>='
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
47
|
version: 0.3.8
|
|
54
48
|
type: :runtime
|
|
55
49
|
prerelease: false
|
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
51
|
requirements:
|
|
59
|
-
- -
|
|
52
|
+
- - '>='
|
|
60
53
|
- !ruby/object:Gem::Version
|
|
61
54
|
version: 0.3.8
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
|
63
56
|
name: rspec-expectations
|
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
|
65
|
-
none: false
|
|
66
58
|
requirements:
|
|
67
|
-
- -
|
|
59
|
+
- - '>='
|
|
68
60
|
- !ruby/object:Gem::Version
|
|
69
61
|
version: 2.0.1
|
|
70
62
|
type: :runtime
|
|
71
63
|
prerelease: false
|
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
-
none: false
|
|
74
65
|
requirements:
|
|
75
|
-
- -
|
|
66
|
+
- - '>='
|
|
76
67
|
- !ruby/object:Gem::Version
|
|
77
68
|
version: 2.0.1
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
|
79
70
|
name: selenium-webdriver
|
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
|
81
|
-
none: false
|
|
82
72
|
requirements:
|
|
83
|
-
- -
|
|
73
|
+
- - '>='
|
|
84
74
|
- !ruby/object:Gem::Version
|
|
85
75
|
version: 2.29.0
|
|
86
76
|
type: :runtime
|
|
87
77
|
prerelease: false
|
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
-
none: false
|
|
90
79
|
requirements:
|
|
91
|
-
- -
|
|
80
|
+
- - '>='
|
|
92
81
|
- !ruby/object:Gem::Version
|
|
93
82
|
version: 2.29.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: poltergeist
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - '>='
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 1.1.1
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - '>='
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 1.1.1
|
|
94
97
|
- !ruby/object:Gem::Dependency
|
|
95
98
|
name: rack
|
|
96
99
|
requirement: !ruby/object:Gem::Requirement
|
|
97
|
-
none: false
|
|
98
100
|
requirements:
|
|
99
|
-
- -
|
|
101
|
+
- - '>='
|
|
100
102
|
- !ruby/object:Gem::Version
|
|
101
103
|
version: 1.5.2
|
|
102
104
|
type: :development
|
|
103
105
|
prerelease: false
|
|
104
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
-
none: false
|
|
106
107
|
requirements:
|
|
107
|
-
- -
|
|
108
|
+
- - '>='
|
|
108
109
|
- !ruby/object:Gem::Version
|
|
109
110
|
version: 1.5.2
|
|
110
111
|
description: Instant capybara/cucumber/rspec/selenium-webdriver configuration for
|
|
@@ -122,32 +123,35 @@ files:
|
|
|
122
123
|
- example/features/step_definitions/steps.rb
|
|
123
124
|
- example/features/support/env.rb
|
|
124
125
|
- lib/cappie.rb
|
|
126
|
+
- lib/cappie/driver.rb
|
|
125
127
|
- lib/cappie/process.rb
|
|
126
|
-
- lib/cappie/selenium.rb
|
|
127
128
|
- lib/cappie/version.rb
|
|
129
|
+
- spec/cappie/example_app.rb
|
|
130
|
+
- spec/cappie/process_spec.rb
|
|
128
131
|
homepage: http://github.com/featurist/cappie
|
|
129
132
|
licenses: []
|
|
133
|
+
metadata: {}
|
|
130
134
|
post_install_message:
|
|
131
135
|
rdoc_options:
|
|
132
136
|
- --charset=UTF-8
|
|
133
137
|
require_paths:
|
|
134
138
|
- lib
|
|
135
139
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
|
-
none: false
|
|
137
140
|
requirements:
|
|
138
|
-
- -
|
|
141
|
+
- - '>='
|
|
139
142
|
- !ruby/object:Gem::Version
|
|
140
143
|
version: '0'
|
|
141
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
|
-
none: false
|
|
143
145
|
requirements:
|
|
144
|
-
- -
|
|
146
|
+
- - '>='
|
|
145
147
|
- !ruby/object:Gem::Version
|
|
146
148
|
version: '0'
|
|
147
149
|
requirements: []
|
|
148
150
|
rubyforge_project:
|
|
149
|
-
rubygems_version:
|
|
151
|
+
rubygems_version: 2.0.3
|
|
150
152
|
signing_key:
|
|
151
|
-
specification_version:
|
|
152
|
-
summary: cappie-0.0.
|
|
153
|
-
test_files:
|
|
153
|
+
specification_version: 4
|
|
154
|
+
summary: cappie-0.0.2
|
|
155
|
+
test_files:
|
|
156
|
+
- spec/cappie/example_app.rb
|
|
157
|
+
- spec/cappie/process_spec.rb
|