caius-culerity 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
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 ADDED
@@ -0,0 +1,101 @@
1
+ h2. Introduction
2
+
3
+ Culerity integrates Cucumber and Celerity in order to test your application's full stack.
4
+
5
+ Culerity lets you:
6
+ * run Celerity from within Cucumber which allows you to test the full stack of your Rails (or other web) application from Database to in browser JavaScript
7
+ * run your application in any Ruby (like MRI 1.8.6) while Celerity runs in JRuby so you can still use gems/plugins that would not work with JRuby
8
+ * reuse existing Webrat-Style step definitions
9
+
10
+ h2. Getting Started
11
+
12
+ The following guide is written for a Rails application (tested with 2.2.2) but Culerity should work with any other Web Framework that is supported by Cucumber.
13
+
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
+
16
+ <pre><code> export PATH=$HOME/jruby/bin:$PATH</code></pre>
17
+
18
+ ... or by creating a symlink from your bin directory:
19
+
20
+ <pre><code> ln -s $HOME/jruby/bin/jruby /usr/bin/jruby</code></pre>
21
+
22
+ Next install the celerity gem for JRuby:
23
+
24
+ <pre><code> jruby -S gem install celerity</code></pre>
25
+
26
+ Now (assuming you have a Rails application set up already) install Culerity as a Rails Plugin:
27
+
28
+ <pre><code> cd RAILS_ROOT
29
+ git clone git://github.com/langalex/culerity.git</code></pre>
30
+
31
+ or as a gem: (definitely preferred)
32
+
33
+ <pre><code> gem install langalex-culerity --source http://gems.github.com</code></pre>
34
+
35
+ Run the RSpec, Cucumber and Culerity generators:
36
+
37
+ <pre><code>
38
+ cd RAILS_ROOT
39
+ script/generate rspec
40
+ script/generate cucumber
41
+ script/generate culerity
42
+ </code></pre>
43
+
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.
45
+
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.
47
+
48
+ NOTE: The default port for this server is 3001. You can change this in features/step_definitions/common_celerity.rb
49
+
50
+
51
+ <pre><code> script/server -p 3001 -e test
52
+ cucumber features/my_feature.feature
53
+ </code></pre>
54
+
55
+ h2. How does it work
56
+
57
+ While Celerity is based on Java and requires JRuby to run, with Culerity you can still run your tests in your own Ruby Environment. When you run your features a separate JRuby process for Celerity is spawned and all Celerity Commands are redirected to this other process.
58
+
59
+ h2. Troubleshooting
60
+
61
+ I get a broken pipe error:
62
+ * make sure JRuby is installed and in your path: running _jruby -v_ should not produce an error
63
+
64
+ I get _Connection Refused_ errors
65
+ * make sure you have started a server in the test environment that runs on port 3001
66
+
67
+ My application can't find the data I create in my steps
68
+ * make sure you have disabled transactional fixtures in your env.rb
69
+
70
+ My database is not cleared automatically between scenarios
71
+ * Rails can't clean the database because you had to disable transactional fixtures - which only work if your test process is the same as your web server process. Hence you have to clean your database manually. A quick way would be:
72
+
73
+ <pre><code>Before do
74
+ [User, .... all your models].each do |model|
75
+ mode.delete_all
76
+ end
77
+ end
78
+ </code></pre>
79
+
80
+ I want to test emails but the ActionMailer::Base.deliveries array is always empty.
81
+ * that's because the :test delivery method stores all emails in memory, but now that your test process is not the same as your rails process you don't have access to that array. install the http://github.com/ngty/action_mailer_cache_delivery plugin to access the emails in your rails process via a temporary file
82
+
83
+
84
+ h2. Links to Celerity documentation
85
+
86
+ * "How to select elements":http://celerity.rubyforge.org/yard/Celerity/Container.html
87
+ * "FAQ":http://wiki.github.com/jarib/celerity/faq
88
+ * "Tutorial":http://wiki.github.com/jarib/celerity/getting-started
89
+ * "API docs":http://celerity.rubyforge.org/yard/
90
+
91
+ h2. Links
92
+
93
+ * "cucumber":http://github.com/aslakhellesoy/cucumber/wikis
94
+ * "celerity":http://celerity.rubyforge.org
95
+ * "jruby":http://jruby.codehaus.org
96
+ * "rspec":http://rspec.info
97
+ * "htmlunit":http://htmlunit.sourceforge.net/
98
+
99
+ h2. Contact
100
+
101
+ Written 2009 by Alexander Lang, contact alex[at]upstream-berlin.com or http://github.com/langalex, released under the MIT license
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 ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 1
4
+ :patch: 5
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
@@ -0,0 +1,20 @@
1
+ class CulerityGenerator < Rails::Generator::Base
2
+
3
+ def initialize(runtime_args, runtime_options = {})
4
+ Dir.mkdir('features/step_definitions') unless File.directory?('features/step_definitions')
5
+ super
6
+ end
7
+
8
+ def manifest
9
+ record do |m|
10
+ m.template 'common_celerity.rb', 'features/step_definitions/common_celerity.rb'
11
+ end
12
+ end
13
+
14
+ protected
15
+
16
+ def banner
17
+ "Usage: #{$0} culerity"
18
+ end
19
+
20
+ end
@@ -0,0 +1,87 @@
1
+ require 'culerity'
2
+
3
+ Before do
4
+ $server ||= Culerity::run_server
5
+ $browser = Culerity::RemoteBrowserProxy.new $server, {:browser => :firefox}
6
+ @host = 'http://localhost:3001'
7
+ end
8
+
9
+ at_exit do
10
+ $browser.exit
11
+ $server.close
12
+ end
13
+
14
+ When /I press "(.*)"/ do |button|
15
+ $browser.button(:text, button).click
16
+ assert_successful_response
17
+ end
18
+
19
+ When /I follow "(.*)"/ do |link|
20
+ $browser.link(:text, /#{link}/).click
21
+ assert_successful_response
22
+ end
23
+
24
+ When /I fill in "(.*)" for "(.*)"/ do |value, field|
25
+ $browser.text_field(:id, find_label(field).for).set(value)
26
+ end
27
+
28
+ When /I check "(.*)"/ do |field|
29
+ $browser.check_box(:id, find_label(field).for).set(true)
30
+ end
31
+
32
+ When /^I uncheck "(.*)"$/ do |field|
33
+ $browser.check_box(:id, find_label(field).for).set(false)
34
+ end
35
+
36
+ When /I select "(.*)" from "(.*)"/ do |value, field|
37
+ $browser.select_list(:id, find_label(field).for).select value
38
+ end
39
+
40
+ When /I choose "(.*)"/ do |field|
41
+ $browser.radio(:id, find_label(field).for).set(true)
42
+ end
43
+
44
+ When /I go to (.+)/ do |path|
45
+ $browser.goto @host + path_to(path)
46
+ assert_successful_response
47
+ end
48
+
49
+ When /I wait for the AJAX call to finish/ do
50
+ $browser.wait
51
+ end
52
+
53
+ Then /I should see "(.*)"/ do |text|
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
62
+ end
63
+
64
+ Then /I should not see "(.*)"/ do |text|
65
+ div = $browser.div(:text, /#{text}/).html rescue nil
66
+ div.should be_nil
67
+ end
68
+
69
+ def find_label(text)
70
+ $browser.label :text, text
71
+ end
72
+
73
+ def assert_successful_response
74
+ status = $browser.page.web_response.status_code
75
+ if(status == 302 || status == 301)
76
+ location = $browser.page.web_response.get_response_header_value('Location')
77
+ puts "Being redirected to #{location}"
78
+ $browser.goto location
79
+ assert_successful_response
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}`
85
+ raise "Brower returned Response Code #{$browser.page.web_response.status_code}"
86
+ end
87
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'rails/init'
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'celerity'
3
+
4
+
5
+ module Culerity
6
+ class CelerityServer
7
+
8
+ def initialize(_in, _out)
9
+ @proxies = {}
10
+ @browser_options = {}
11
+
12
+ while(true)
13
+ call = eval _in.gets.to_s.strip
14
+ return if call == ["_exit_"]
15
+ unless call.nil?
16
+ begin
17
+ result = target(call.first).send call[1], *call[2..-1]
18
+ _out << "[:return, #{proxify result}]\n"
19
+ rescue => e
20
+ _out << "[:exception, \"#{e.class.name}\", #{e.message.inspect}, #{e.backtrace.inspect}]\n"
21
+ end
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ private
28
+
29
+ def configure_browser(options)
30
+ @browser_options = options
31
+ end
32
+
33
+ def browser
34
+ @browser ||= Celerity::Browser.new @browser_options || {}
35
+ end
36
+
37
+ def target(object_id)
38
+ if object_id == 'browser'
39
+ browser
40
+ elsif object_id == 'celerity'
41
+ self
42
+ else
43
+ @proxies[object_id]
44
+ end
45
+ end
46
+
47
+ def proxify(result)
48
+ if result.is_a?(Array)
49
+ result.map {|x| proxify(x) }.inspect
50
+ elsif [String, TrueClass, FalseClass, Fixnum, Float, NilClass].include?(result.class)
51
+ result.inspect
52
+ else
53
+ @proxies[result.object_id] = result
54
+ "Culerity::RemoteObjectProxy.new(#{result.object_id}, @io)"
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,21 @@
1
+ module Culerity
2
+
3
+ class RemoteBrowserProxy < RemoteObjectProxy
4
+ def initialize(io, browser_options = {})
5
+ @io = io
6
+ unless browser_options.empty?
7
+ @remote_object_id = 'celerity'
8
+ configure_browser browser_options
9
+ @remote_object_id = nil
10
+ end
11
+
12
+ end
13
+
14
+ private
15
+
16
+ def remote_object_id
17
+ (@remote_object_id || 'browser').inspect
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,40 @@
1
+ module Culerity
2
+
3
+ class CulerityException < StandardError
4
+ def initialize(message, backtrace)
5
+ super message
6
+ #self.backtrace = backtrace
7
+ end
8
+ end
9
+
10
+ class RemoteObjectProxy
11
+ def initialize(remote_object_id, io)
12
+ @remote_object_id = remote_object_id
13
+ @io = io
14
+ end
15
+
16
+ def method_missing(name, *args)
17
+ @io << "[#{remote_object_id}, \"#{name}\", #{args.map{|a| a.inspect}.join(', ')}]\n"
18
+ process_result @io.gets.to_s.strip
19
+ end
20
+
21
+ def exit
22
+ @io << '["_exit_"]'
23
+ end
24
+
25
+ private
26
+
27
+ def process_result(result)
28
+ res = eval result
29
+ if res.first == :return
30
+ res[1]
31
+ elsif res.first == :exception
32
+ raise CulerityException.new("#{res[1]}: #{res[2]}", res[3])
33
+ end
34
+ end
35
+
36
+ def remote_object_id
37
+ @remote_object_id
38
+ end
39
+ end
40
+ end
data/lib/culerity.rb ADDED
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/culerity/remote_object_proxy'
2
+ require File.dirname(__FILE__) + '/culerity/remote_browser_proxy'
3
+
4
+ module Culerity
5
+
6
+ def self.run_server
7
+ IO.popen("jruby #{__FILE__}", 'r+')
8
+ end
9
+
10
+ end
11
+
12
+ if __FILE__ == $0
13
+ require File.dirname(__FILE__) + '/culerity/celerity_server'
14
+ Culerity::CelerityServer.new STDIN, STDOUT
15
+ end
16
+
data/rails/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'culerity'
@@ -0,0 +1,77 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe Culerity::CelerityServer do
4
+ before(:each) do
5
+ @browser = stub 'browser'
6
+ Celerity::Browser.stub!(:new).and_return(@browser)
7
+ end
8
+
9
+ it "should pass the method call to the selerity browser" do
10
+ @browser.should_receive(:goto).with('/homepage')
11
+ _in = stub 'in'
12
+ _in.stub!(:gets).and_return("[\"browser\", \"goto\", \"/homepage\"]\n", "[\"_exit_\"]\n")
13
+ _out = stub 'out', :<< => nil
14
+ Culerity::CelerityServer.new(_in, _out)
15
+ end
16
+
17
+ it "should send back the return value of the call" do
18
+ @browser.stub!(:goto).and_return(true)
19
+ _in = stub 'in'
20
+ _in.stub!(:gets).and_return("[\"browser\", \"goto\", \"/homepage\"]\n", "[\"_exit_\"]\n")
21
+ _out = stub 'out'
22
+ _out.should_receive(:<<).with("[:return, true]\n")
23
+ Culerity::CelerityServer.new(_in, _out)
24
+ end
25
+
26
+ it "should ignore empty inputs" do
27
+ _in = stub 'in'
28
+ _in.stub!(:gets).and_return("\n", "[\"_exit_\"]\n")
29
+ _out = stub 'out'
30
+ _out.should_not_receive(:<<)
31
+ Culerity::CelerityServer.new(_in, _out)
32
+ end
33
+
34
+ it "should send back a proxy if the return value is not a string, number, nil or boolean" do
35
+ @browser.stub!(:goto).and_return(stub('123', :object_id => 456))
36
+ _in = stub 'in'
37
+ _in.stub!(:gets).and_return("[\"browser\", \"goto\", \"/homepage\"]\n", "[\"_exit_\"]\n")
38
+ _out = stub 'out'
39
+ _out.should_receive(:<<).with("[:return, Culerity::RemoteObjectProxy.new(456, @io)]\n")
40
+ Culerity::CelerityServer.new(_in, _out)
41
+ end
42
+
43
+ it "should pass the method call to a proxy" do
44
+ proxy = stub('123', :object_id => 456)
45
+ @browser.stub!(:goto).and_return(proxy)
46
+ _in = stub 'in'
47
+ _in.stub!(:gets).and_return("[\"browser\", \"goto\", \"/homepage\"]\n", "[456, \"goto_2\", \"1\"]", "[\"_exit_\"]\n")
48
+ _out = stub 'out', :<< => nil
49
+ proxy.should_receive(:goto_2).with('1')
50
+ Culerity::CelerityServer.new(_in, _out)
51
+ end
52
+
53
+ it "should configure the browser" do
54
+ _in = stub 'in'
55
+ _in.stub!(:gets).and_return('["celerity", "configure_browser", {:browser=>:firefox}]' + "\n", '["browser", "goto", "/homepage"]' + "\n", "[\"_exit_\"]\n")
56
+ Celerity::Browser.should_receive(:new).with(:browser => :firefox)
57
+ Culerity::CelerityServer.new(_in, stub.as_null_object)
58
+ end
59
+
60
+ it "should pass multiple method calls" do
61
+ @browser.should_receive(:goto).with('/homepage')
62
+ @browser.should_receive(:goto).with('/page2')
63
+ _in = stub 'in'
64
+ _in.stub!(:gets).and_return("[\"browser\", \"goto\", \"/homepage\"]\n", "[\"browser\", \"goto\", \"/page2\"]\n", "[\"_exit_\"]\n")
65
+ _out = stub 'out', :<< => nil
66
+ Culerity::CelerityServer.new(_in, _out)
67
+ end
68
+
69
+ it "should return an exception" do
70
+ @browser.stub!(:goto).and_raise(RuntimeError.new('test exception with "quotes"'))
71
+ _in = stub 'in'
72
+ _in.stub!(:gets).and_return("[\"browser\", \"goto\", \"/homepage\"]\n", "[\"_exit_\"]\n")
73
+ _out = stub 'out'
74
+ _out.should_receive(:<<).with(/^\[:exception, \"RuntimeError\", \"test exception with \\\"quotes\\\"\", \[.*\]\]\n$/)
75
+ Culerity::CelerityServer.new(_in, _out)
76
+ end
77
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe Culerity::RemoteBrowserProxy do
4
+ it "should send the serialized method call to the output" do
5
+ io = stub 'io', :gets => '[return, :okay]'
6
+ io.should_receive(:<<).with("[\"browser\", \"goto\", \"/homepage\"]\n")
7
+ proxy = Culerity::RemoteBrowserProxy.new io
8
+ proxy.goto '/homepage'
9
+ end
10
+
11
+ it "should return the deserialized return value" do
12
+ io = stub 'io', :gets => "[:return, :okay]\n", :<< => nil
13
+ proxy = Culerity::RemoteBrowserProxy.new io
14
+ proxy.goto.should == :okay
15
+ end
16
+
17
+ it "should send the brower options to the remote server" do
18
+ io = stub 'io', :gets => "[:return, :okay]"
19
+ io.should_receive(:<<).with('["celerity", "configure_browser", {:browser=>:firefox}]' + "\n")
20
+ proxy = Culerity::RemoteBrowserProxy.new io, {:browser => :firefox}
21
+ end
22
+
23
+ end
@@ -0,0 +1,31 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe Culerity::RemoteObjectProxy do
4
+ it "should send the serialized method call to the output" do
5
+ io = stub 'io', :gets => '[:return]'
6
+ io.should_receive(:<<).with("[345, \"goto\", \"/homepage\"]\n")
7
+ proxy = Culerity::RemoteObjectProxy.new 345, io
8
+ proxy.goto '/homepage'
9
+ end
10
+
11
+ it "should return the deserialized return value" do
12
+ io = stub 'io', :gets => "[:return, :okay]\n", :<< => nil
13
+ proxy = Culerity::RemoteObjectProxy.new 345, io
14
+ proxy.goto.should == :okay
15
+ end
16
+
17
+ it "should raise the received exception" do
18
+ io = stub 'io', :gets => "[:exception, \"RuntimeError\", \"test exception\", []]", :<< => nil
19
+ proxy = Culerity::RemoteObjectProxy.new 345, io
20
+ lambda {
21
+ proxy.goto '/home'
22
+ }.should raise_error(Culerity::CulerityException)
23
+ end
24
+
25
+ it "should send exit" do
26
+ io = stub 'io', :gets => '[:return]'
27
+ io.should_receive(:<<).with('["_exit_"]')
28
+ proxy = Culerity::RemoteObjectProxy.new 345, io
29
+ proxy.exit
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ if RUBY_PLATFORM != 'java'
2
+ puts "You need JRuby to run these specs"
3
+ exit -1
4
+ end
5
+
6
+ require File.dirname(__FILE__) + '/../lib/culerity'
7
+ require File.dirname(__FILE__) + '/../lib/culerity/celerity_server'
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: caius-culerity
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Lang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-13 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: cucumber
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description: Culerity integrates Cucumber and Celerity in order to test your application's full stack.
36
+ email: alex@upstream-berlin.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README.textile
43
+ files:
44
+ - MIT-LICENSE
45
+ - README.textile
46
+ - Rakefile
47
+ - VERSION.yml
48
+ - culerity.gemspec
49
+ - generators/culerity/culerity_generator.rb
50
+ - generators/culerity/templates/common_celerity.rb
51
+ - init.rb
52
+ - lib/culerity.rb
53
+ - lib/culerity/celerity_server.rb
54
+ - lib/culerity/remote_browser_proxy.rb
55
+ - lib/culerity/remote_object_proxy.rb
56
+ - rails/init.rb
57
+ - spec/celerity_server_spec.rb
58
+ - spec/remote_browser_proxy_spec.rb
59
+ - spec/remote_object_proxy_spec.rb
60
+ - spec/spec_helper.rb
61
+ has_rdoc: true
62
+ homepage: http://github.com/langalex/culerity
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --charset=UTF-8
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.2.0
84
+ signing_key:
85
+ specification_version: 2
86
+ summary: Culerity integrates Cucumber and Celerity in order to test your application's full stack.
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