langalex-culerity 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.textile +12 -9
- data/Rakefile +42 -0
- data/VERSION.yml +1 -1
- data/culerity.gemspec +62 -0
- data/generators/culerity/templates/common_celerity.rb +23 -7
- data/init.rb +1 -0
- data/lib/culerity/celerity_server.rb +1 -1
- data/lib/culerity/remote_object_proxy.rb +8 -1
- data/lib/culerity.rb +2 -1
- data/rails/init.rb +1 -0
- data/spec/celerity_server_spec.rb +2 -2
- data/spec/remote_object_proxy_spec.rb +2 -2
- metadata +15 -11
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Alexander Lang
|
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.textile
CHANGED
@@ -13,41 +13,44 @@ The following guide is written for a Rails application (tested with 2.2.2) but C
|
|
13
13
|
|
14
14
|
First download JRuby and unpack it to some location, for example $HOME/jruby. Make sure that the jruby executable is in your path. You can do this by either setting your PATH accordingly...
|
15
15
|
|
16
|
-
export PATH=$HOME/jruby/bin:$PATH
|
16
|
+
<pre><code> export PATH=$HOME/jruby/bin:$PATH</code></pre>
|
17
17
|
|
18
18
|
... or by creating a symlink from your bin directory:
|
19
19
|
|
20
|
-
ln -s $HOME/jruby/bin/jruby /usr/bin/jruby
|
20
|
+
<pre><code> ln -s $HOME/jruby/bin/jruby /usr/bin/jruby</code></pre>
|
21
21
|
|
22
22
|
Next install the celerity gem for JRuby:
|
23
23
|
|
24
|
-
jruby -S gem install celerity
|
24
|
+
<pre><code> jruby -S gem install celerity</code></pre>
|
25
25
|
|
26
26
|
Now (assuming you have a Rails application set up already) install Culerity as a Rails Plugin:
|
27
27
|
|
28
|
-
cd RAILS_ROOT
|
29
|
-
git clone git://github.com/langalex/culerity.git
|
28
|
+
<pre><code> cd RAILS_ROOT
|
29
|
+
git clone git://github.com/langalex/culerity.git</code></pre>
|
30
30
|
|
31
31
|
or as a gem: (definitely preferred)
|
32
32
|
|
33
|
-
gem install langalex-culerity
|
33
|
+
<pre><code> gem install langalex-culerity --source http://gems.github.com</code></pre>
|
34
34
|
|
35
35
|
Run the RSpec, Cucumber and Culerity generators:
|
36
36
|
|
37
|
+
<pre><code>
|
37
38
|
cd RAILS_ROOT
|
38
39
|
script/generate rspec
|
39
40
|
script/generate cucumber
|
40
41
|
script/generate culerity
|
42
|
+
</code></pre>
|
41
43
|
|
42
44
|
This creates the features folder and a file common_celerity.rb into your application. This file contains step definitions for basic interactions like clicking links or filling out forms.
|
43
45
|
|
44
46
|
After you have written a first feature you can run it just like you would run a standard cucumber feature. The only difference is that you have to start a web server (e.g. mongrel) with the test environment enabled beforehand.
|
45
47
|
|
46
|
-
NOTE:
|
48
|
+
NOTE: The default port for this server is 3001. You can change this in features/step_definitions/common_celerity.rb
|
47
49
|
|
48
50
|
|
49
|
-
|
51
|
+
<pre><code> script/server -p 3001 -e test
|
50
52
|
cucumber features/my_feature.feature
|
53
|
+
</code></pre>
|
51
54
|
|
52
55
|
h2. How does it work
|
53
56
|
|
@@ -59,7 +62,7 @@ I get a broken pipe error:
|
|
59
62
|
* make sure JRuby is installed and in your path: running _jruby -v_ should not produce an error
|
60
63
|
|
61
64
|
I get _Connection Refused_ errors
|
62
|
-
* make sure you have started a server in the test environment that runs on port
|
65
|
+
* make sure you have started a server in the test environment that runs on port 3001
|
63
66
|
|
64
67
|
My application can't find the data I create in my steps
|
65
68
|
* make sure you have disabled transactional fixtures in your env.rb
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rcov/rcovtask'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |s|
|
9
|
+
s.name = "culerity"
|
10
|
+
s.summary = %Q{Culerity integrates Cucumber and Celerity in order to test your application's full stack.}
|
11
|
+
s.email = "alex@upstream-berlin.com"
|
12
|
+
s.homepage = "http://github.com/langalex/culerity"
|
13
|
+
s.description = "Culerity integrates Cucumber and Celerity in order to test your application's full stack."
|
14
|
+
s.authors = ["Alexander Lang"]
|
15
|
+
s.add_dependency 'cucumber'
|
16
|
+
s.add_dependency 'rspec'
|
17
|
+
end
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
20
|
+
end
|
21
|
+
|
22
|
+
Rake::TestTask.new do |t|
|
23
|
+
t.libs << 'lib'
|
24
|
+
t.pattern = 'spec/**/*_spec.rb'
|
25
|
+
t.verbose = false
|
26
|
+
end
|
27
|
+
|
28
|
+
Rake::RDocTask.new do |rdoc|
|
29
|
+
rdoc.rdoc_dir = 'rdoc'
|
30
|
+
rdoc.title = 'Culerity'
|
31
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
32
|
+
rdoc.rdoc_files.include('README*')
|
33
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
34
|
+
end
|
35
|
+
|
36
|
+
Rcov::RcovTask.new do |t|
|
37
|
+
t.libs << 'spec'
|
38
|
+
t.test_files = FileList['spec/**/*_spec.rb']
|
39
|
+
t.verbose = true
|
40
|
+
end
|
41
|
+
|
42
|
+
task :default => :test
|
data/VERSION.yml
CHANGED
data/culerity.gemspec
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{culerity}
|
5
|
+
s.version = "0.1.5"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Alexander Lang"]
|
9
|
+
s.date = %q{2009-05-13}
|
10
|
+
s.description = %q{Culerity integrates Cucumber and Celerity in order to test your application's full stack.}
|
11
|
+
s.email = %q{alex@upstream-berlin.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"README.textile"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
"MIT-LICENSE",
|
17
|
+
"README.textile",
|
18
|
+
"Rakefile",
|
19
|
+
"VERSION.yml",
|
20
|
+
"culerity.gemspec",
|
21
|
+
"generators/culerity/culerity_generator.rb",
|
22
|
+
"generators/culerity/templates/common_celerity.rb",
|
23
|
+
"init.rb",
|
24
|
+
"lib/culerity.rb",
|
25
|
+
"lib/culerity/celerity_server.rb",
|
26
|
+
"lib/culerity/remote_browser_proxy.rb",
|
27
|
+
"lib/culerity/remote_object_proxy.rb",
|
28
|
+
"rails/init.rb",
|
29
|
+
"spec/celerity_server_spec.rb",
|
30
|
+
"spec/remote_browser_proxy_spec.rb",
|
31
|
+
"spec/remote_object_proxy_spec.rb",
|
32
|
+
"spec/spec_helper.rb"
|
33
|
+
]
|
34
|
+
s.has_rdoc = true
|
35
|
+
s.homepage = %q{http://github.com/langalex/culerity}
|
36
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.3.1}
|
39
|
+
s.summary = %q{Culerity integrates Cucumber and Celerity in order to test your application's full stack.}
|
40
|
+
s.test_files = [
|
41
|
+
"spec/celerity_server_spec.rb",
|
42
|
+
"spec/remote_browser_proxy_spec.rb",
|
43
|
+
"spec/remote_object_proxy_spec.rb",
|
44
|
+
"spec/spec_helper.rb"
|
45
|
+
]
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
+
s.specification_version = 2
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_runtime_dependency(%q<cucumber>, [">= 0"])
|
53
|
+
s.add_runtime_dependency(%q<rspec>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
56
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
57
|
+
end
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
60
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
61
|
+
end
|
62
|
+
end
|
@@ -3,8 +3,7 @@ require 'culerity'
|
|
3
3
|
Before do
|
4
4
|
$server ||= Culerity::run_server
|
5
5
|
$browser = Culerity::RemoteBrowserProxy.new $server, {:browser => :firefox}
|
6
|
-
|
7
|
-
@host = 'http://localhost'
|
6
|
+
@host = 'http://localhost:3001'
|
8
7
|
end
|
9
8
|
|
10
9
|
at_exit do
|
@@ -34,25 +33,37 @@ When /^I uncheck "(.*)"$/ do |field|
|
|
34
33
|
$browser.check_box(:id, find_label(field).for).set(false)
|
35
34
|
end
|
36
35
|
|
36
|
+
When /I select "(.*)" from "(.*)"/ do |value, field|
|
37
|
+
$browser.select_list(:id, find_label(field).for).select value
|
38
|
+
end
|
39
|
+
|
37
40
|
When /I choose "(.*)"/ do |field|
|
38
41
|
$browser.radio(:id, find_label(field).for).set(true)
|
39
42
|
end
|
40
43
|
|
41
44
|
When /I go to (.+)/ do |path|
|
42
45
|
$browser.goto @host + path_to(path)
|
46
|
+
assert_successful_response
|
43
47
|
end
|
44
48
|
|
45
|
-
When
|
46
|
-
$browser.
|
49
|
+
When /I wait for the AJAX call to finish/ do
|
50
|
+
$browser.wait
|
47
51
|
end
|
48
52
|
|
49
|
-
|
50
53
|
Then /I should see "(.*)"/ do |text|
|
51
|
-
|
54
|
+
# if we simply check for the browser.html content we don't find content that has been added dynamically, e.g. after an ajax call
|
55
|
+
div = $browser.div(:text, /#{text}/)
|
56
|
+
begin
|
57
|
+
div.html
|
58
|
+
rescue
|
59
|
+
#puts $browser.html
|
60
|
+
raise("div with '#{text}' not found")
|
61
|
+
end
|
52
62
|
end
|
53
63
|
|
54
64
|
Then /I should not see "(.*)"/ do |text|
|
55
|
-
$browser.
|
65
|
+
div = $browser.div(:text, /#{text}/).html rescue nil
|
66
|
+
div.should be_nil
|
56
67
|
end
|
57
68
|
|
58
69
|
def find_label(text)
|
@@ -65,7 +76,12 @@ def assert_successful_response
|
|
65
76
|
location = $browser.page.web_response.get_response_header_value('Location')
|
66
77
|
puts "Being redirected to #{location}"
|
67
78
|
$browser.goto location
|
79
|
+
assert_successful_response
|
68
80
|
elsif status != 200
|
81
|
+
tmp = Tempfile.new 'culerity_results'
|
82
|
+
tmp << $browser.html
|
83
|
+
tmp.close
|
84
|
+
`open -a /Applications/Safari.app #{tmp.path}`
|
69
85
|
raise "Brower returned Response Code #{$browser.page.web_response.status_code}"
|
70
86
|
end
|
71
87
|
end
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rails/init'
|
@@ -17,7 +17,7 @@ module Culerity
|
|
17
17
|
result = target(call.first).send call[1], *call[2..-1]
|
18
18
|
_out << "[:return, #{proxify result}]\n"
|
19
19
|
rescue => e
|
20
|
-
_out << "[:exception, #{e.class.
|
20
|
+
_out << "[:exception, \"#{e.class.name}\", #{e.message.inspect}, #{e.backtrace.inspect}]\n"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -1,4 +1,11 @@
|
|
1
1
|
module Culerity
|
2
|
+
|
3
|
+
class CulerityException < StandardError
|
4
|
+
def initialize(message, backtrace)
|
5
|
+
super message
|
6
|
+
#self.backtrace = backtrace
|
7
|
+
end
|
8
|
+
end
|
2
9
|
|
3
10
|
class RemoteObjectProxy
|
4
11
|
def initialize(remote_object_id, io)
|
@@ -22,7 +29,7 @@ module Culerity
|
|
22
29
|
if res.first == :return
|
23
30
|
res[1]
|
24
31
|
elsif res.first == :exception
|
25
|
-
raise res[1]
|
32
|
+
raise CulerityException.new("#{res[1]}: #{res[2]}", res[3])
|
26
33
|
end
|
27
34
|
end
|
28
35
|
|
data/lib/culerity.rb
CHANGED
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'culerity'
|
@@ -67,11 +67,11 @@ describe Culerity::CelerityServer do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should return an exception" do
|
70
|
-
@browser.stub!(:goto).and_raise(RuntimeError.new('test exception'))
|
70
|
+
@browser.stub!(:goto).and_raise(RuntimeError.new('test exception with "quotes"'))
|
71
71
|
_in = stub 'in'
|
72
72
|
_in.stub!(:gets).and_return("[\"browser\", \"goto\", \"/homepage\"]\n", "[\"_exit_\"]\n")
|
73
73
|
_out = stub 'out'
|
74
|
-
_out.should_receive(:<<).with(/^\[:exception, RuntimeError, \"test exception\", \[.*\]\]\n$/)
|
74
|
+
_out.should_receive(:<<).with(/^\[:exception, \"RuntimeError\", \"test exception with \\\"quotes\\\"\", \[.*\]\]\n$/)
|
75
75
|
Culerity::CelerityServer.new(_in, _out)
|
76
76
|
end
|
77
77
|
end
|
@@ -15,11 +15,11 @@ describe Culerity::RemoteObjectProxy do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should raise the received exception" do
|
18
|
-
io = stub 'io', :gets => "[:exception, RuntimeError, \"test exception\", []]", :<< => nil
|
18
|
+
io = stub 'io', :gets => "[:exception, \"RuntimeError\", \"test exception\", []]", :<< => nil
|
19
19
|
proxy = Culerity::RemoteObjectProxy.new 345, io
|
20
20
|
lambda {
|
21
21
|
proxy.goto '/home'
|
22
|
-
}.should raise_error(
|
22
|
+
}.should raise_error(Culerity::CulerityException)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should send exit" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: langalex-culerity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Lang
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-13 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -38,20 +38,22 @@ executables: []
|
|
38
38
|
|
39
39
|
extensions: []
|
40
40
|
|
41
|
-
extra_rdoc_files:
|
42
|
-
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README.textile
|
43
43
|
files:
|
44
|
+
- MIT-LICENSE
|
44
45
|
- README.textile
|
46
|
+
- Rakefile
|
45
47
|
- VERSION.yml
|
46
|
-
-
|
48
|
+
- culerity.gemspec
|
47
49
|
- generators/culerity/culerity_generator.rb
|
48
|
-
- generators/culerity/templates
|
49
50
|
- generators/culerity/templates/common_celerity.rb
|
50
|
-
-
|
51
|
+
- init.rb
|
52
|
+
- lib/culerity.rb
|
51
53
|
- lib/culerity/celerity_server.rb
|
52
54
|
- lib/culerity/remote_browser_proxy.rb
|
53
55
|
- lib/culerity/remote_object_proxy.rb
|
54
|
-
-
|
56
|
+
- rails/init.rb
|
55
57
|
- spec/celerity_server_spec.rb
|
56
58
|
- spec/remote_browser_proxy_spec.rb
|
57
59
|
- spec/remote_object_proxy_spec.rb
|
@@ -60,7 +62,6 @@ has_rdoc: true
|
|
60
62
|
homepage: http://github.com/langalex/culerity
|
61
63
|
post_install_message:
|
62
64
|
rdoc_options:
|
63
|
-
- --inline-source
|
64
65
|
- --charset=UTF-8
|
65
66
|
require_paths:
|
66
67
|
- lib
|
@@ -83,5 +84,8 @@ rubygems_version: 1.2.0
|
|
83
84
|
signing_key:
|
84
85
|
specification_version: 2
|
85
86
|
summary: Culerity integrates Cucumber and Celerity in order to test your application's full stack.
|
86
|
-
test_files:
|
87
|
-
|
87
|
+
test_files:
|
88
|
+
- spec/celerity_server_spec.rb
|
89
|
+
- spec/remote_browser_proxy_spec.rb
|
90
|
+
- spec/remote_object_proxy_spec.rb
|
91
|
+
- spec/spec_helper.rb
|