culerity 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.2.7
2
+
3
+ * fixed RemoteBrowser#confirm called celerity remove_listener with invalid arguments
4
+ * extended communication protocol to be able to send procs as arguments and blocks
5
+ * default mail delivery method is now 'persistent', ActionMailer::Base.deliveries works again in features
6
+
7
+
1
8
  ## 0.2.5
2
9
 
3
10
  * added javascript helper to make 'I wait for the AJAX call to finish' work reliably (langalex)
data/README.md CHANGED
@@ -77,10 +77,6 @@ My database is not cleared automatically between scenarios
77
77
  end
78
78
  end
79
79
 
80
- I want to test emails but the ActionMailer::Base.deliveries array is always empty.
81
-
82
- * 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
83
-
84
80
 
85
81
  ## Links to Celerity documentation
86
82
 
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :build:
3
+ :patch: 7
3
4
  :major: 0
4
5
  :minor: 2
5
- :patch: 6
data/culerity.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{culerity}
8
- s.version = "0.2.6"
8
+ s.version = "0.2.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alexander Lang"]
12
- s.date = %q{2009-12-09}
12
+ s.date = %q{2010-01-17}
13
13
  s.description = %q{Culerity integrates Cucumber and Celerity in order to test your application's full stack.}
14
14
  s.email = %q{alex@upstream-berlin.com}
15
15
  s.extra_rdoc_files = [
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
37
37
  "init.rb",
38
38
  "lib/culerity.rb",
39
39
  "lib/culerity/celerity_server.rb",
40
+ "lib/culerity/persistent_delivery.rb",
40
41
  "lib/culerity/remote_browser_proxy.rb",
41
42
  "lib/culerity/remote_object_proxy.rb",
42
43
  "rails/init.rb",
@@ -8,7 +8,7 @@ Feature: Installing culerity
8
8
  And I run executable "script/generate" with arguments "cucumber"
9
9
  And I delete file "features/step_definitions/webrat_steps.rb"
10
10
  And I delete file "features/support/env.rb"
11
- And I copy the project generators into "vendor/generators"
11
+ And culerity is installed as a plugin
12
12
  And I invoke task "rake db:migrate"
13
13
  When I run executable "script/generate" with arguments "culerity"
14
14
  And I setup load path to local code
@@ -8,7 +8,7 @@ Feature: Running cucumber without explicitly running external services
8
8
  And I run executable "script/generate" with arguments "cucumber"
9
9
  And I delete file "features/step_definitions/webrat_steps.rb"
10
10
  And I delete file "features/support/env.rb"
11
- And I copy the project generators into "vendor/generators"
11
+ And culerity is installed as a plugin
12
12
  And I invoke task "rake db:migrate"
13
13
  When I run executable "script/generate" with arguments "culerity"
14
14
  And I setup load path to local code
@@ -5,11 +5,17 @@ Given /^a Rails app$/ do
5
5
  @active_project_folder = File.expand_path(File.join(@tmp_root, "my_project"))
6
6
  end
7
7
 
8
- Given /^I copy the project generators into "([^\"]*)"$/ do |target_folder|
8
+ Given /^culerity is installed as a plugin$/ do
9
+ generators_folder = 'vendor/generators'
10
+ plugin_folder = 'vendor/plugins/culerity'
9
11
  in_project_folder do
10
- FileUtils.mkdir_p(target_folder)
12
+ FileUtils.mkdir_p(generators_folder)
13
+ FileUtils.mkdir_p(plugin_folder)
11
14
  end
12
- `cp -rf #{File.dirname(__FILE__) + "/../../rails_generators/*"} #{File.join(@active_project_folder, target_folder)}`
15
+ `cp -rf #{File.dirname(__FILE__) + "/../../rails_generators/*"} #{File.join(@active_project_folder, generators_folder)}`
16
+ `cp -rf #{File.dirname(__FILE__) + "/../../lib"} #{File.join(@active_project_folder, plugin_folder)}`
17
+ `cp -rf #{File.dirname(__FILE__) + "/../../rails"} #{File.join(@active_project_folder, plugin_folder)}`
18
+ `cp -rf #{File.dirname(__FILE__) + "/../../init.rb"} #{File.join(@active_project_folder, plugin_folder)}`
13
19
  end
14
20
 
15
21
  When /^I add a feature file to test Rails index.html default file$/ do
@@ -10,19 +10,12 @@ module Culerity
10
10
  @browsers = []
11
11
 
12
12
  while(true)
13
- call = eval _in.gets.to_s.strip
14
- return if call == ["_exit_"]
15
- next(close_browsers) if call == ["_close_browsers_"]
13
+ call, block = eval _in.gets.to_s.strip
14
+ return if call == "_exit_"
15
+ next(close_browsers) if call == "_close_browsers_"
16
16
  unless call.nil?
17
17
  begin
18
- # check if last arg is a block
19
- if call.last.is_a?(Proc)
20
- # pass as &call[-1]
21
- result = target(call.first).send call[1], *call[2..-2], &call[-1]
22
- else
23
- # just call with args as normal
24
- result = target(call.first).send call[1], *call[2..-1]
25
- end
18
+ result = target(call.first).send call[1], *call[2..-1], &block
26
19
  _out << "[:return, #{proxify result}]\n"
27
20
  rescue => e
28
21
  _out << "[:exception, \"#{e.class.name}\", #{e.message.inspect}, #{e.backtrace.inspect}]\n"
@@ -0,0 +1,35 @@
1
+ require 'fileutils'
2
+
3
+ module Culerity
4
+ module PersistentDelivery
5
+
6
+ DELIVERIES_PATH =
7
+ File.join(RAILS_ROOT, 'tmp', 'action_mailer_acceptance_deliveries.cache')
8
+
9
+ def self.included(base)
10
+ base.class_eval do
11
+ def self.deliveries
12
+ return [] unless File.exist?(DELIVERIES_PATH)
13
+ File.open(DELIVERIES_PATH,'r') do |f|
14
+ Marshal.load(f)
15
+ end
16
+ end
17
+
18
+ def self.clear_deliveries
19
+ FileUtils.rm_f DELIVERIES_PATH
20
+ end
21
+ end
22
+ end
23
+
24
+ def perform_delivery_persistent(mail)
25
+ deliveries << mail
26
+ File.open(DELIVERIES_PATH,'w') do |f|
27
+ f << Marshal.dump(deliveries)
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+
34
+ ActionMailer::Base.send :include, Culerity::PersistentDelivery
35
+
@@ -49,7 +49,7 @@ module Culerity
49
49
 
50
50
  self.send_remote(:add_listener, :confirm) { blk }
51
51
  block.call
52
- self.send_remote(:remove_listener, :confirm) { blk }
52
+ self.send_remote(:remove_listener, :confirm, lambda {blk})
53
53
  end
54
54
 
55
55
  end
@@ -21,8 +21,8 @@ module Culerity
21
21
  send_remote(:id)
22
22
  end
23
23
 
24
- def method_missing(name, *args)
25
- send_remote(name, *args)
24
+ def method_missing(name, *args, &block)
25
+ send_remote(name, *args, &block)
26
26
  end
27
27
 
28
28
  #
@@ -34,9 +34,9 @@ module Culerity
34
34
  # straight through, otherwise it will be wrapped in a lambda string before sending.
35
35
  #
36
36
  def send_remote(name, *args, &blk)
37
- input = [remote_object_id, %Q{"#{name}"}, *args.map{|a| a.inspect}]
38
- input << block_to_string(&blk) if block_given?
39
- @io << "[#{input.join(", ")}]\n"
37
+ input = [remote_object_id, %Q{"#{name}"}, *args.map{|a| arg_to_string(a)}]
38
+ serialized_block = ", #{block_to_string(&blk)}" if block_given?
39
+ @io << "[[#{input.join(", ")}]#{serialized_block}]\n"
40
40
  process_result @io.gets.to_s.strip
41
41
  end
42
42
 
@@ -68,6 +68,14 @@ module Culerity
68
68
  end
69
69
  result
70
70
  end
71
+
72
+ def arg_to_string(arg)
73
+ if arg.is_a?(Proc)
74
+ block_to_string(&arg)
75
+ else
76
+ arg.inspect
77
+ end
78
+ end
71
79
 
72
80
  def remote_object_id
73
81
  @remote_object_id
@@ -9,20 +9,8 @@ config.action_controller.consider_all_requests_local = false
9
9
  config.action_controller.perform_caching = true
10
10
  config.action_view.cache_template_loading = true
11
11
 
12
- # See everything in the log (default is :info)
13
- # config.log_level = :debug
12
+ config.action_mailer.delivery_method = :persistent
14
13
 
15
- # Use a different logger for distributed setups
16
- # config.logger = SyslogLogger.new
17
-
18
- # Use a different cache store in production
19
- # config.cache_store = :mem_cache_store
20
-
21
- # Enable serving of images, stylesheets, and javascripts from an asset server
22
- # config.action_controller.asset_host = "http://assets.example.com"
23
-
24
- # Disable delivery errors, bad email addresses will be ignored
25
- # config.action_mailer.raise_delivery_errors = false
26
-
27
- # Enable threaded mode
28
- # config.threadsafe!
14
+ config.after_initialize do
15
+ require 'culerity/persistent_delivery'
16
+ end
@@ -14,4 +14,9 @@ config.action_controller.allow_forgery_protection = false
14
14
  # Tell Action Mailer not to deliver emails to the real world.
15
15
  # The :test delivery method accumulates sent emails in the
16
16
  # ActionMailer::Base.deliveries array.
17
- config.action_mailer.delivery_method = :test
17
+ config.action_mailer.delivery_method = :persistent
18
+
19
+ config.after_initialize do
20
+ require 'culerity/persistent_delivery'
21
+ end
22
+
@@ -12,15 +12,19 @@ jQuery(function($) {
12
12
  throw(e);
13
13
  }
14
14
  window.running_ajax_calls -= 1;
15
- }
15
+ };
16
16
  };
17
17
  window.running_ajax_calls = 0;
18
18
 
19
19
  var ajax_with_count = function(options) {
20
- window.running_ajax_calls += 1;
21
- options.success = count_down(options.success);
22
- options.error = count_down(options.error);
23
- original_ajax(options);
20
+ if(options.async == false) {
21
+ return(original_ajax(options));
22
+ } else {
23
+ window.running_ajax_calls += 1;
24
+ options.success = count_down(options.success);
25
+ options.error = count_down(options.error);
26
+ return original_ajax(options);
27
+ }
24
28
  };
25
29
 
26
30
  $.ajax = ajax_with_count;
@@ -9,14 +9,35 @@ describe Culerity::CelerityServer do
9
9
  it "should pass the method call to the celerity browser" do
10
10
  @browser.should_receive(:goto).with('/homepage')
11
11
  _in = stub 'in'
12
- _in.stub!(:gets).and_return("[\"browser0\", \"goto\", \"/homepage\"]\n", "[\"_exit_\"]\n")
12
+ _in.stub!(:gets).and_return("[[\"browser0\", \"goto\", \"/homepage\"]]\n", "[\"_exit_\"]\n")
13
13
  _out = stub 'out', :<< => nil
14
14
  Culerity::CelerityServer.new(_in, _out)
15
15
  end
16
+
17
+ it "should pass procs" do
18
+ @browser.should_receive(:remove_listener).with(:confirm, instance_of(Proc))
19
+ _in = stub 'in'
20
+ _in.stub!(:gets).and_return("[[\"browser0\", \"remove_listener\", :confirm, lambda{true}]]\n", "[\"_exit_\"]\n")
21
+ _out = stub 'out', :<< => nil
22
+ Culerity::CelerityServer.new(_in, _out)
23
+ end
24
+
25
+ it "should pass blocks" do
26
+ def @browser.add_listener(type, &block)
27
+ @type = type
28
+ @block = block
29
+ end
30
+ _in = stub 'in'
31
+ _in.stub!(:gets).and_return("[[\"browser0\", \"add_listener\", :confirm], lambda{true}]\n", "[\"_exit_\"]\n")
32
+ _out = stub 'out', :<< => nil
33
+ Culerity::CelerityServer.new(_in, _out)
34
+ @browser.instance_variable_get(:@type).should == :confirm
35
+ @browser.instance_variable_get(:@block).call.should == true
36
+ end
16
37
 
17
38
  it "should return the browser id when a new browser is requested" do
18
39
  _in = stub 'in'
19
- _in.stub!(:gets).and_return("[\"celerity\", \"new_browser\", {}]\n", "[\"_exit_\"]\n")
40
+ _in.stub!(:gets).and_return("[[\"celerity\", \"new_browser\", {}]]\n", "[\"_exit_\"]\n")
20
41
  _out = stub 'out'
21
42
  _out.should_receive(:<<).with("[:return, \"browser0\"]\n")
22
43
  Culerity::CelerityServer.new(_in, _out)
@@ -24,14 +45,14 @@ describe Culerity::CelerityServer do
24
45
 
25
46
  it "should create a new browser with the provided options" do
26
47
  _in = stub 'in'
27
- _in.stub!(:gets).and_return("[\"celerity\", \"new_browser\", {:browser => :firefox}]\n", "[\"_exit_\"]\n")
48
+ _in.stub!(:gets).and_return("[[\"celerity\", \"new_browser\", {:browser => :firefox}]]\n", "[\"_exit_\"]\n")
28
49
  Celerity::Browser.should_receive(:new).with(:browser => :firefox)
29
50
  Culerity::CelerityServer.new(_in, stub.as_null_object)
30
51
  end
31
52
 
32
53
  it "should create multiple browsers and return the appropriate id for each" do
33
54
  _in = stub 'in'
34
- _in.stub!(:gets).and_return("[\"celerity\", \"new_browser\", {}]\n", "[\"celerity\", \"new_browser\", {}]\n", "[\"_exit_\"]\n")
55
+ _in.stub!(:gets).and_return("[[\"celerity\", \"new_browser\", {}]]\n", "[[\"celerity\", \"new_browser\", {}]]\n", "[\"_exit_\"]\n")
35
56
  Celerity::Browser.should_receive(:new).twice
36
57
  _out = stub 'out'
37
58
  _out.should_receive(:<<).with("[:return, \"browser0\"]\n").ordered
@@ -44,7 +65,7 @@ describe Culerity::CelerityServer do
44
65
  it "should send back the return value of the call" do
45
66
  @browser.stub!(:goto).and_return(true)
46
67
  _in = stub 'in'
47
- _in.stub!(:gets).and_return("[\"browser0\", \"goto\", \"/homepage\"]\n", "[\"_exit_\"]\n")
68
+ _in.stub!(:gets).and_return("[[\"browser0\", \"goto\", \"/homepage\"]]\n", "[\"_exit_\"]\n")
48
69
  _out = stub 'out'
49
70
  _out.should_receive(:<<).with("[:return, true]\n")
50
71
  Culerity::CelerityServer.new(_in, _out)
@@ -61,7 +82,7 @@ describe Culerity::CelerityServer do
61
82
  it "should send back a proxy if the return value is not a string, number, nil or boolean" do
62
83
  @browser.stub!(:goto).and_return(stub('123', :object_id => 456))
63
84
  _in = stub 'in'
64
- _in.stub!(:gets).and_return("[\"browser0\", \"goto\", \"/homepage\"]\n", "[\"_exit_\"]\n")
85
+ _in.stub!(:gets).and_return("[[\"browser0\", \"goto\", \"/homepage\"]]\n", "[\"_exit_\"]\n")
65
86
  _out = stub 'out'
66
87
  _out.should_receive(:<<).with("[:return, Culerity::RemoteObjectProxy.new(456, @io)]\n")
67
88
  Culerity::CelerityServer.new(_in, _out)
@@ -70,7 +91,7 @@ describe Culerity::CelerityServer do
70
91
  it "should send back arrays" do
71
92
  @browser.stub!(:goto).and_return([true, false, "test", 1, 12.3, nil, stub('123', :object_id => 456), ["test2", 32.1, 5000, nil, false, true, stub('789', :object_id => 101)]])
72
93
  _in = stub 'in'
73
- _in.stub!(:gets).and_return("[\"browser0\", \"goto\", \"/homepage\"]\n", "[\"_exit_\"]\n")
94
+ _in.stub!(:gets).and_return("[[\"browser0\", \"goto\", \"/homepage\"]]\n", "[\"_exit_\"]\n")
74
95
  _out = stub 'out'
75
96
  _out.should_receive(:<<).with("[:return, [true, false, \"test\", 1, 12.3, nil, Culerity::RemoteObjectProxy.new(456, @io), [\"test2\", 32.1, 5000, nil, false, true, Culerity::RemoteObjectProxy.new(101, @io)]]]\n")
76
97
  Culerity::CelerityServer.new(_in, _out)
@@ -80,7 +101,7 @@ describe Culerity::CelerityServer do
80
101
  proxy = stub('123', :object_id => 456)
81
102
  @browser.stub!(:goto).and_return(proxy)
82
103
  _in = stub 'in'
83
- _in.stub!(:gets).and_return("[\"browser0\", \"goto\", \"/homepage\"]\n", "[456, \"goto_2\", \"1\"]", "[\"_exit_\"]\n")
104
+ _in.stub!(:gets).and_return("[[\"browser0\", \"goto\", \"/homepage\"]]\n", "[[456, \"goto_2\", \"1\"]]", "[\"_exit_\"]\n")
84
105
  _out = stub 'out', :<< => nil
85
106
  proxy.should_receive(:goto_2).with('1')
86
107
  Culerity::CelerityServer.new(_in, _out)
@@ -90,7 +111,7 @@ describe Culerity::CelerityServer do
90
111
  @browser.should_receive(:goto).with('/homepage')
91
112
  @browser.should_receive(:goto).with('/page2')
92
113
  _in = stub 'in'
93
- _in.stub!(:gets).and_return("[\"browser0\", \"goto\", \"/homepage\"]\n", "[\"browser0\", \"goto\", \"/page2\"]\n", "[\"_exit_\"]\n")
114
+ _in.stub!(:gets).and_return("[[\"browser0\", \"goto\", \"/homepage\"]]\n", "[[\"browser0\", \"goto\", \"/page2\"]]\n", "[\"_exit_\"]\n")
94
115
  _out = stub 'out', :<< => nil
95
116
  Culerity::CelerityServer.new(_in, _out)
96
117
  end
@@ -98,7 +119,7 @@ describe Culerity::CelerityServer do
98
119
  it "should return an exception" do
99
120
  @browser.stub!(:goto).and_raise(RuntimeError.new('test exception with "quotes"'))
100
121
  _in = stub 'in'
101
- _in.stub!(:gets).and_return("[\"browser0\", \"goto\", \"/homepage\"]\n", "[\"_exit_\"]\n")
122
+ _in.stub!(:gets).and_return("[[\"browser0\", \"goto\", \"/homepage\"]]\n", "[\"_exit_\"]\n")
102
123
  _out = stub 'out'
103
124
  _out.should_receive(:<<).with(/^\[:exception, \"RuntimeError\", \"test exception with \\\"quotes\\\"\", \[.*\]\]\n$/)
104
125
  Culerity::CelerityServer.new(_in, _out)
@@ -4,9 +4,10 @@ describe Culerity::RemoteBrowserProxy do
4
4
  before(:each) do
5
5
  @io = stub 'io', :gets => "[:return, \"browser0\"]", :<< => nil
6
6
  end
7
+
7
8
  it "should send the serialized method call to the output" do
8
- @io.should_receive(:<<).with("[\"celerity\", \"new_browser\", {}]\n").ordered
9
- @io.should_receive(:<<).with("[\"browser0\", \"goto\", \"/homepage\"]\n").ordered
9
+ @io.should_receive(:<<).with("[[\"celerity\", \"new_browser\", {}]]\n").ordered
10
+ @io.should_receive(:<<).with("[[\"browser0\", \"goto\", \"/homepage\"]]\n").ordered
10
11
  proxy = Culerity::RemoteBrowserProxy.new @io
11
12
  proxy.goto '/homepage'
12
13
  end
@@ -19,7 +20,7 @@ describe Culerity::RemoteBrowserProxy do
19
20
 
20
21
  it "should send the browser options to the remote server" do
21
22
  io = stub 'io', :gets => "[:return, \"browser0\"]"
22
- io.should_receive(:<<).with('["celerity", "new_browser", {:browser=>:firefox}]' + "\n")
23
+ io.should_receive(:<<).with('[["celerity", "new_browser", {:browser=>:firefox}]]' + "\n")
23
24
  proxy = Culerity::RemoteBrowserProxy.new io, {:browser => :firefox}
24
25
  end
25
26
 
@@ -52,7 +53,7 @@ describe Culerity::RemoteBrowserProxy do
52
53
 
53
54
  proxy.should_receive(:send_remote).with(:add_listener, :confirm).and_return(true)
54
55
  proxy.should_receive(:send_remote).with(:goto, "http://example.com").and_return(true)
55
- proxy.should_receive(:send_remote).with(:remove_listener, :confirm).and_return(true)
56
+ proxy.should_receive(:send_remote).with(:remove_listener, :confirm, an_instance_of(Proc)).and_return(true)
56
57
 
57
58
  proxy.confirm(true) do
58
59
  proxy.goto "http://example.com"
@@ -19,22 +19,22 @@ describe Culerity::RemoteObjectProxy do
19
19
 
20
20
  it "should send the serialized method call to the output" do
21
21
  io = stub 'io', :gets => '[:return]'
22
- io.should_receive(:<<).with(%Q{[345, "goto", "/homepage"]\n})
22
+ io.should_receive(:<<).with(%Q{[[345, "goto", "/homepage"]]\n})
23
23
  proxy = Culerity::RemoteObjectProxy.new 345, io
24
24
  proxy.goto '/homepage'
25
25
  end
26
26
 
27
- it "should send the serialized method call with argument plus block to the output" do
27
+ it "should send the serialized method call with a proc argument to the output" do
28
28
  io = stub 'io', :gets => "[:return]"
29
- io.should_receive(:<<).with(%Q{[345, "method", true, lambda { true }]\n})
29
+ io.should_receive(:<<).with(%Q{[[345, "method", true, lambda { true }]]\n})
30
30
  proxy = Culerity::RemoteObjectProxy.new 345, io
31
31
 
32
- proxy.send_remote(:method, true) { "lambda { true }" }
32
+ proxy.send_remote(:method, true, lambda{true})
33
33
  end
34
34
 
35
- it "should send the serialized method call without argument plus block to the output" do
35
+ it "should send the serialized method call and a block to the output" do
36
36
  io = stub 'io', :gets => "[:return]"
37
- io.should_receive(:<<).with(%Q{[345, "method", lambda { true }]\n})
37
+ io.should_receive(:<<).with(%Q{[[345, "method"], lambda { true }]\n})
38
38
  proxy = Culerity::RemoteObjectProxy.new 345, io
39
39
 
40
40
  proxy.send_remote(:method) { "lambda { true }" }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: culerity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
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-09 00:00:00 +01:00
12
+ date: 2010-01-17 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -62,6 +62,7 @@ files:
62
62
  - init.rb
63
63
  - lib/culerity.rb
64
64
  - lib/culerity/celerity_server.rb
65
+ - lib/culerity/persistent_delivery.rb
65
66
  - lib/culerity/remote_browser_proxy.rb
66
67
  - lib/culerity/remote_object_proxy.rb
67
68
  - rails/init.rb