culerity 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- h2. Introduction
1
+ ## Introduction
2
2
 
3
3
  Culerity integrates Cucumber and Celerity in order to test your application's full stack.
4
4
 
@@ -7,47 +7,48 @@ Culerity lets you:
7
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
8
  * reuse existing Webrat-Style step definitions
9
9
 
10
- h2. Getting Started
10
+ ## Getting Started
11
11
 
12
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
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
- <pre><code> export PATH=$HOME/jruby/bin:$PATH</code></pre>
16
+ export PATH=$HOME/jruby/bin:$PATH
17
17
 
18
18
  ... or by creating a symlink from your bin directory:
19
19
 
20
- <pre><code> ln -s $HOME/jruby/bin/jruby /usr/bin/jruby</code></pre>
20
+ ln -s $HOME/jruby/bin/jruby /usr/bin/jruby
21
+
22
+ You will need the celerity gem installed into JRuby:
23
+
24
+ jruby -S gem install celerity
21
25
 
22
26
  Now (assuming you have a Rails application set up already) install Culerity as a Rails Plugin:
23
27
 
24
- <pre><code> cd RAILS_ROOT
25
- git clone git://github.com/langalex/culerity.git</code></pre>
28
+ cd RAILS_ROOT
29
+ git clone git://github.com/langalex/culerity.git
26
30
 
27
31
  or as a gem: (definitely preferred)
28
32
 
29
- <pre><code> gem install langalex-culerity --source http://gems.github.com</code></pre>
33
+ gem install langalex-culerity --source http://gems.github.com
30
34
 
31
35
  Run the RSpec, Cucumber and Culerity generators:
32
36
 
33
- <pre><code>
34
- cd RAILS_ROOT
35
- script/generate rspec
36
- script/generate cucumber
37
- script/generate culerity
38
- </code></pre>
37
+ cd RAILS_ROOT
38
+ script/generate rspec
39
+ script/generate cucumber
40
+ script/generate culerity
39
41
 
40
42
  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.
41
43
 
42
44
  Culerity is a Ruby-side interface to celerity running on JRuby. To install it:
43
45
 
44
- <pre><code> rake culerity:install</code></pre>
46
+ rake culerity:install
45
47
 
46
48
  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
49
 
48
- <pre><code> rake culerity:rails:start
49
- cucumber features/my_feature.feature
50
- </code></pre>
50
+ rake culerity:rails:start
51
+ cucumber features/my_feature.feature
51
52
 
52
53
  The Rails instance uses a special environment culerity_development.
53
54
 
@@ -55,45 +56,49 @@ When you have finished running culerity/cucumber you can turn off the Rails inst
55
56
 
56
57
  NOTE: The default port for this server is 3001. You can change this in features/step_definitions/common_celerity.rb
57
58
 
58
- <pre><code> rake culerity:rails:stop</code></pre>
59
+ rake culerity:rails:stop
59
60
 
60
- h2. How does it work
61
+ ## How does it work
61
62
 
62
63
  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.
63
64
 
64
- h2. Troubleshooting
65
+ ## Troubleshooting
65
66
 
66
67
  I get a broken pipe error:
68
+
67
69
  * make sure JRuby is installed and in your path: running _jruby -v_ should not produce an error
68
70
 
69
71
  I get _Connection Refused_ errors
72
+
70
73
  * make sure you have started a server in the test environment that runs on port 3001
71
74
 
72
75
  My application can't find the data I create in my steps
76
+
73
77
  * make sure you have disabled transactional fixtures in your env.rb
74
78
 
75
79
  My database is not cleared automatically between scenarios
80
+
76
81
  * 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:
77
82
 
78
- <pre><code>Before do
79
- [User, .... all your models].each do |model|
80
- mode.delete_all
81
- end
82
- end
83
- </code></pre>
83
+ Before do
84
+ [User, .... all your models].each do |model|
85
+ mode.delete_all
86
+ end
87
+ end
84
88
 
85
89
  I want to test emails but the ActionMailer::Base.deliveries array is always empty.
90
+
86
91
  * 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
87
92
 
88
93
 
89
- h2. Links to Celerity documentation
94
+ ## Links to Celerity documentation
90
95
 
91
96
  * "How to select elements":http://celerity.rubyforge.org/yard/Celerity/Container.html
92
97
  * "FAQ":http://wiki.github.com/jarib/celerity/faq
93
98
  * "Tutorial":http://wiki.github.com/jarib/celerity/getting-started
94
99
  * "API docs":http://celerity.rubyforge.org/yard/
95
100
 
96
- h2. Links
101
+ ## Links
97
102
 
98
103
  * "cucumber":http://github.com/aslakhellesoy/cucumber/wikis
99
104
  * "celerity":http://celerity.rubyforge.org
@@ -101,6 +106,6 @@ h2. Links
101
106
  * "rspec":http://rspec.info
102
107
  * "htmlunit":http://htmlunit.sourceforge.net/
103
108
 
104
- h2. Contact
109
+ ## Contact
105
110
 
106
111
  Written 2009 by Alexander Lang, contact alex[at]upstream-berlin.com or http://github.com/langalex, released under the MIT license
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'rake'
2
- require 'rake/testtask'
2
+ require 'spec/rake/spectask'
3
3
  require 'rake/rdoctask'
4
- # require 'rcov/rcovtask'
5
4
 
6
5
  begin
7
6
  require 'rubygems' unless ENV['NO_RUBYGEMS']
@@ -20,10 +19,9 @@ rescue LoadError
20
19
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
21
20
  end
22
21
 
23
- Rake::TestTask.new do |t|
24
- t.libs << 'lib'
25
- t.pattern = 'spec/**/*_spec.rb'
26
- t.verbose = false
22
+ desc "Run all unit specs"
23
+ Spec::Rake::SpecTask.new(:spec) do |t|
24
+ t.spec_files = FileList['spec/*_spec.rb']
27
25
  end
28
26
 
29
27
  Rake::RDocTask.new do |rdoc|
@@ -34,10 +32,4 @@ Rake::RDocTask.new do |rdoc|
34
32
  rdoc.rdoc_files.include('lib/**/*.rb')
35
33
  end
36
34
 
37
- # Rcov::RcovTask.new do |t|
38
- # t.libs << 'spec'
39
- # t.test_files = FileList['spec/**/*_spec.rb']
40
- # t.verbose = true
41
- # end
42
-
43
- task :default => :test
35
+ task :default => :spec
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 3
4
+ :patch: 4
data/culerity.gemspec CHANGED
@@ -2,20 +2,20 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{culerity}
5
- s.version = "0.2.3"
5
+ s.version = "0.2.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Alexander Lang"]
9
- s.date = %q{2009-09-08}
9
+ s.date = %q{2009-11-22}
10
10
  s.description = %q{Culerity integrates Cucumber and Celerity in order to test your application's full stack.}
11
11
  s.email = %q{alex@upstream-berlin.com}
12
12
  s.extra_rdoc_files = [
13
- "README.textile"
13
+ "README.md"
14
14
  ]
15
15
  s.files = [
16
16
  ".gitignore",
17
17
  "MIT-LICENSE",
18
- "README.textile",
18
+ "README.md",
19
19
  "Rakefile",
20
20
  "VERSION.yml",
21
21
  "culerity.gemspec",
@@ -38,12 +38,13 @@ Gem::Specification.new do |s|
38
38
  "rails_generators/culerity/culerity_generator.rb",
39
39
  "rails_generators/culerity/templates/config/environments/culerity_continuousintegration.rb",
40
40
  "rails_generators/culerity/templates/config/environments/culerity_development.rb",
41
- "rails_generators/culerity/templates/features/step_definitions/common_celerity_steps.rb",
41
+ "rails_generators/culerity/templates/features/step_definitions/culerity_steps.rb",
42
42
  "rails_generators/culerity/templates/lib/tasks/culerity.rake",
43
43
  "script/console",
44
44
  "script/destroy",
45
45
  "script/generate",
46
46
  "spec/celerity_server_spec.rb",
47
+ "spec/culerity_spec.rb",
47
48
  "spec/remote_browser_proxy_spec.rb",
48
49
  "spec/remote_object_proxy_spec.rb",
49
50
  "spec/spec_helper.rb"
@@ -55,6 +56,7 @@ Gem::Specification.new do |s|
55
56
  s.summary = %q{Culerity integrates Cucumber and Celerity in order to test your application's full stack.}
56
57
  s.test_files = [
57
58
  "spec/celerity_server_spec.rb",
59
+ "spec/culerity_spec.rb",
58
60
  "spec/remote_browser_proxy_spec.rb",
59
61
  "spec/remote_object_proxy_spec.rb",
60
62
  "spec/spec_helper.rb"
@@ -24,7 +24,7 @@ Feature: Installing culerity
24
24
  Then file "tmp/culerity_rails_server.pid" is not created
25
25
 
26
26
  Scenario: Install culerity into a Rails app and check it works
27
- Then file "features/step_definitions/common_celerity_steps.rb" is created
27
+ Then file "features/step_definitions/culerity_steps.rb" is created
28
28
  Then file "config/environments/culerity_development.rb" is created
29
29
  Then file "config/environments/culerity_continuousintegration.rb" is created
30
30
 
@@ -1,7 +1,7 @@
1
1
  When /^I setup load path to local code$/ do
2
2
  project_lib_path = File.expand_path(File.dirname(__FILE__) + "/../../lib")
3
3
  in_project_folder do
4
- force_local_lib_override(:target => 'features/step_definitions/common_celerity_steps.rb')
4
+ force_local_lib_override(:target => 'features/step_definitions/culerity_steps.rb')
5
5
  end
6
6
  end
7
7
 
data/lib/culerity.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  require File.dirname(__FILE__) + '/culerity/remote_object_proxy'
2
2
  require File.dirname(__FILE__) + '/culerity/remote_browser_proxy'
3
3
 
4
+ Symbol.class_eval do
5
+ def to_proc
6
+ Proc.new{|object| object.send(self)}
7
+ end
8
+ end unless :symbol.respond_to?(:to_proc)
9
+
4
10
  module Culerity
5
11
 
6
12
  module ServerCommands
@@ -16,44 +22,21 @@ module Culerity
16
22
 
17
23
  def self.run_server
18
24
  IO.popen("jruby #{__FILE__}", 'r+').extend(ServerCommands)
19
-
20
- # open the two pipes that were created below
21
- # while(!File.exists?("tmp/culerity_in.pipe"))
22
- # sleep(1)
23
- # end
24
- # pipe_in = open("tmp/culerity_in.pipe", "w+")
25
- # pipe_out = open("tmp/culerity_out.pipe", "r+")
26
-
27
-
28
-
29
- # store celerity pid in tmp/culerity_celerity.pid
30
- # store server pid in tmp/culerity_rails_server.pid
31
-
32
- # open named pipes to communicate with celerity_server + return them
33
25
  end
34
26
 
35
- def self.run_rails
36
- unless File.exists?("tmp/culerity_rails_server.pid")
27
+ def self.run_rails(options = {})
28
+ if defined?(Rails) && !File.exists?("tmp/culerity_rails_server.pid")
37
29
  puts "WARNING: Speed up execution by running 'rake culerity:rails:start'"
38
- port = 3001
39
- environment = 'culerity_development'
40
- puts "Launched rails on :#{port}..."
41
- return IO.popen("script/server -e #{environment} -p #{port}", 'r+')
30
+ port = options[:port] || 3001
31
+ environment = options[:environment] || 'culerity_development'
32
+ rails_server = IO.popen("script/server -e #{environment} -p #{port}", 'r+')
33
+ sleep 5
34
+ rails_server
42
35
  end
43
36
  end
44
37
  end
45
38
 
46
39
  if __FILE__ == $0
47
- # `rm tmp/culerity_in.pipe`
48
- # `mkfifo tmp/culerity_in.pipe`
49
- # `rm tmp/culerity_out.pipe`
50
- # `mkfifo tmp/culerity_out.pipe`
51
- #
52
- # pipe_in = open("tmp/culerity_in.pipe", "r+")
53
- # p pipe_in
54
- # p STDIN
55
- # pipe_out = open("tmp/culerity_out.pipe", "w+")
56
- #
57
40
  require File.dirname(__FILE__) + '/culerity/celerity_server'
58
41
  Culerity::CelerityServer.new STDIN, STDOUT
59
42
  end
@@ -67,11 +67,11 @@ module Culerity
67
67
  end
68
68
  end
69
69
 
70
- def proxify(result, in_array = false)
70
+ def proxify(result)
71
71
  if result.is_a?(Array)
72
- result.map {|x| proxify(x, true) }.inspect
72
+ "[" + result.map {|x| proxify(x) }.join(", ") + "]"
73
73
  elsif [String, TrueClass, FalseClass, Fixnum, Float, NilClass].include?(result.class)
74
- in_array ? result : result.inspect
74
+ result.inspect
75
75
  else
76
76
  @proxies[result.object_id] = result
77
77
  "Culerity::RemoteObjectProxy.new(#{result.object_id}, @io)"
@@ -3,7 +3,7 @@ class CulerityGenerator < Rails::Generator::Base
3
3
  def manifest
4
4
  record do |m|
5
5
  m.directory 'features/step_definitions'
6
- m.file 'features/step_definitions/common_celerity_steps.rb', 'features/step_definitions/common_celerity_steps.rb'
6
+ m.file 'features/step_definitions/culerity_steps.rb', 'features/step_definitions/culerity_steps.rb'
7
7
  m.file 'config/environments/culerity_continuousintegration.rb', 'config/environments/culerity_continuousintegration.rb'
8
8
  m.file 'config/environments/culerity_development.rb', 'config/environments/culerity_development.rb'
9
9
 
@@ -0,0 +1,99 @@
1
+ require 'culerity'
2
+
3
+ Before do
4
+ $rails_server ||= Culerity::run_rails(:environment => 'culerity', :port => 3001)
5
+ $server ||= Culerity::run_server
6
+ $browser = Culerity::RemoteBrowserProxy.new $server, {:browser => :firefox3,
7
+ :javascript_exceptions => true,
8
+ :resynchronize => true,
9
+ :status_code_exceptions => true
10
+ }
11
+ $browser.log_level = :warning
12
+ @host = 'http://localhost:3001'
13
+ end
14
+
15
+ at_exit do
16
+ $browser.exit if $browser
17
+ $server.close if $server
18
+ Process.kill(6, $rails_server.pid.to_i) if $rails_server
19
+ end
20
+
21
+ When /I follow "(.*)"/ do |link|
22
+ _link = [[:text, /^#{Regexp.escape(link)}$/], [:id, link], [:title, link]].map{|args| $browser.link(*args)}.find{|__link| __link.exist?}
23
+ raise "link \"#{link}\" not found" unless _link
24
+ _link.click
25
+ $browser.wait
26
+ assert_successful_response
27
+ end
28
+
29
+ When /I press "(.*)"/ do |button|
30
+ $browser.button(:text, button).click
31
+ assert_successful_response
32
+ end
33
+
34
+ When /I fill in "(.*)" with "(.*)"/ do |field, value|
35
+ find_by_label_or_id(:text_field, field).set(value)
36
+ end
37
+
38
+ When /I fill in "(.*)" for "(.*)"/ do |value, field|
39
+ find_by_label_or_id(:text_field, field).set(value)
40
+ end
41
+
42
+ When /I check "(.*)"/ do |field|
43
+ find_by_label_or_id(:check_box, field).set(true)
44
+ end
45
+
46
+ When /^I uncheck "(.*)"$/ do |field|
47
+ find_by_label_or_id(:check_box, field).set(true)
48
+ end
49
+
50
+ When /I select "(.*)" from "(.*)"/ do |value, field|
51
+ find_by_label_or_id(:select_list, field).select value
52
+ end
53
+
54
+ When /I choose "(.*)"/ do |field|
55
+ find_by_label_or_id(:radio, field).set(true)
56
+ end
57
+
58
+ When /I go to (.+)/ do |path|
59
+ $browser.goto @host + path_to(path)
60
+ assert_successful_response
61
+ end
62
+
63
+ When /I wait for the AJAX call to finish/ do
64
+ $browser.wait
65
+ end
66
+
67
+ Then /I should see "(.*)"/ do |text|
68
+ # 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
69
+ div = $browser.div(:text, /#{text}/)
70
+ div.should be_exist
71
+ end
72
+
73
+ Then /I should not see "(.*)"/ do |text|
74
+ div = $browser.div(:text, /#{text}/)
75
+ div.should_not be_exist
76
+ end
77
+
78
+ def find_by_label_or_id(element, attribute)
79
+ matchers = [[attribute, :id], [attribute, :name]]
80
+ matchers << [$browser.label(:text, attribute).for, :id] if $browser.label(:text, attribute).exist?
81
+ field = matchers.map{|_field, matcher| $browser.send(element, matcher, _field)}.find(&:exist?) || raise("#{element} not found using \"#{attribute}\"")
82
+ end
83
+
84
+ def assert_successful_response
85
+ status = $browser.page.web_response.status_code
86
+ if(status == 302 || status == 301)
87
+ location = $browser.page.web_response.get_response_header_value('Location')
88
+ puts "Being redirected to #{location}"
89
+ $browser.goto location
90
+ assert_successful_response
91
+ elsif status != 200
92
+ filename = "culerity-#{Time.now.to_i}.html"
93
+ File.open(RAILS_ROOT + "/tmp/#{filename}", "w") do |f|
94
+ f.write $browser.html
95
+ end
96
+ `open tmp/#{filename}`
97
+ raise "Browser returned Response Code #{$browser.page.web_response.status_code}"
98
+ end
99
+ end
@@ -1,9 +1,9 @@
1
1
  namespace 'culerity' do
2
2
  namespace 'rails' do
3
3
  desc "Starts a rails server for cucumber/culerity tests"
4
- task :start => :environment do
4
+ task :start do
5
5
  port = ENV['PORT'] || 3001
6
- environment = 'culerity_development'
6
+ environment = ENV["RAILS_ENV"] || 'culerity_development'
7
7
  pid_file = RAILS_ROOT + "/tmp/culerity_rails_server.pid"
8
8
  if File.exists?(pid_file)
9
9
  puts "culerity rails server already running; if not, delete tmp/culerity_rails_server.pid and try again"
@@ -14,7 +14,7 @@ namespace 'culerity' do
14
14
  end
15
15
 
16
16
  desc "Stops the running rails server for cucumber/culerity tests"
17
- task :stop => :environment do
17
+ task :stop do
18
18
  pid_file = RAILS_ROOT + "/tmp/culerity_rails_server.pid"
19
19
  if File.exists?(pid_file)
20
20
  pid = File.read(pid_file).to_i
@@ -30,7 +30,7 @@ namespace 'culerity' do
30
30
  end
31
31
 
32
32
  desc "Install required gems into jruby"
33
- task :install => :environment do
33
+ task :install do
34
34
  jgem_cmd = `which jruby`.strip
35
35
  raise "ERROR: You need to install jruby to use culerity and celerity." if jgem_cmd.blank?
36
36
  sh "#{jgem_cmd} -S gem install jarib-celerity --source=http://gems.github.com"
@@ -66,6 +66,15 @@ describe Culerity::CelerityServer do
66
66
  _out.should_receive(:<<).with("[:return, Culerity::RemoteObjectProxy.new(456, @io)]\n")
67
67
  Culerity::CelerityServer.new(_in, _out)
68
68
  end
69
+
70
+ it "should send back arrays" do
71
+ @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
+ _in = stub 'in'
73
+ _in.stub!(:gets).and_return("[\"browser0\", \"goto\", \"/homepage\"]\n", "[\"_exit_\"]\n")
74
+ _out = stub 'out'
75
+ _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
+ Culerity::CelerityServer.new(_in, _out)
77
+ end
69
78
 
70
79
  it "should pass the method call to a proxy" do
71
80
  proxy = stub('123', :object_id => 456)
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Culerity, 'run_rails' do
4
+ before(:each) do
5
+ Kernel.stub!(:sleep)
6
+ IO.stub!(:popen)
7
+ Culerity.stub!(:sleep)
8
+ end
9
+
10
+ it "should not run rails if we are not using rails" do
11
+ IO.should_not_receive(:popen)
12
+ Culerity.run_rails :port => 4000, :environment => 'culerity'
13
+ end
14
+
15
+ it "should run rails with default values" do
16
+ Rails ||= :rails
17
+ IO.should_receive(:popen).with("script/server -e culerity_development -p 3001", 'r+')
18
+ Culerity.run_rails
19
+ end
20
+
21
+ it "should run rails with the given values" do
22
+ Rails ||= :rails
23
+ IO.should_receive(:popen).with("script/server -e culerity -p 4000", 'r+')
24
+ Culerity.run_rails :port => 4000, :environment => 'culerity'
25
+
26
+ end
27
+
28
+ it "should wait for the server to start up" do
29
+ Rails ||= :rails
30
+ Culerity.should_receive(:sleep)
31
+ Culerity.run_rails :port => 4000, :environment => 'culerity'
32
+ end
33
+ end
@@ -17,7 +17,7 @@ describe Culerity::RemoteBrowserProxy do
17
17
  proxy.goto.should == :okay
18
18
  end
19
19
 
20
- it "should send the brower options to the remote server" do
20
+ it "should send the browser options to the remote server" do
21
21
  io = stub 'io', :gets => "[:return, \"browser0\"]"
22
22
  io.should_receive(:<<).with('["celerity", "new_browser", {:browser=>:firefox}]' + "\n")
23
23
  proxy = Culerity::RemoteBrowserProxy.new io, {:browser => :firefox}
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.3
4
+ version: 0.2.4
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-09-08 00:00:00 +02:00
12
+ date: 2009-11-22 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -39,11 +39,11 @@ executables: []
39
39
  extensions: []
40
40
 
41
41
  extra_rdoc_files:
42
- - README.textile
42
+ - README.md
43
43
  files:
44
44
  - .gitignore
45
45
  - MIT-LICENSE
46
- - README.textile
46
+ - README.md
47
47
  - Rakefile
48
48
  - VERSION.yml
49
49
  - culerity.gemspec
@@ -66,12 +66,13 @@ files:
66
66
  - rails_generators/culerity/culerity_generator.rb
67
67
  - rails_generators/culerity/templates/config/environments/culerity_continuousintegration.rb
68
68
  - rails_generators/culerity/templates/config/environments/culerity_development.rb
69
- - rails_generators/culerity/templates/features/step_definitions/common_celerity_steps.rb
69
+ - rails_generators/culerity/templates/features/step_definitions/culerity_steps.rb
70
70
  - rails_generators/culerity/templates/lib/tasks/culerity.rake
71
71
  - script/console
72
72
  - script/destroy
73
73
  - script/generate
74
74
  - spec/celerity_server_spec.rb
75
+ - spec/culerity_spec.rb
75
76
  - spec/remote_browser_proxy_spec.rb
76
77
  - spec/remote_object_proxy_spec.rb
77
78
  - spec/spec_helper.rb
@@ -105,6 +106,7 @@ specification_version: 3
105
106
  summary: Culerity integrates Cucumber and Celerity in order to test your application's full stack.
106
107
  test_files:
107
108
  - spec/celerity_server_spec.rb
109
+ - spec/culerity_spec.rb
108
110
  - spec/remote_browser_proxy_spec.rb
109
111
  - spec/remote_object_proxy_spec.rb
110
112
  - spec/spec_helper.rb
@@ -1,93 +0,0 @@
1
- require 'culerity'
2
-
3
- Before do
4
- unless $rails_server
5
- $rails_server = Culerity::run_rails
6
- sleep 5
7
- end
8
-
9
- $server ||= Culerity::run_server
10
- $browser = Culerity::RemoteBrowserProxy.new $server, {:browser => :firefox}
11
- @host = 'http://localhost:3001'
12
- end
13
-
14
- at_exit do
15
- $browser.exit if $browser
16
- $server.exit_server if $server
17
- Process.kill(6, $rails_server.pid.to_i) if $rails_server
18
- end
19
-
20
- When /I press "(.*)"/ do |button|
21
- $browser.button(:text, button).click
22
- assert_successful_response
23
- end
24
-
25
- When /I follow "(.*)"/ do |link|
26
- $browser.link(:text, /#{link}/).click
27
- assert_successful_response
28
- end
29
-
30
- When /I fill in "(.*)" for "(.*)"/ do |value, field|
31
- $browser.text_field(:id, find_label(field).for).set(value)
32
- end
33
-
34
- When /I check "(.*)"/ do |field|
35
- $browser.check_box(:id, find_label(field).for).set(true)
36
- end
37
-
38
- When /^I uncheck "(.*)"$/ do |field|
39
- $browser.check_box(:id, find_label(field).for).set(false)
40
- end
41
-
42
- When /I select "(.*)" from "(.*)"/ do |value, field|
43
- $browser.select_list(:id, find_label(field).for).select value
44
- end
45
-
46
- When /I choose "(.*)"/ do |field|
47
- $browser.radio(:id, find_label(field).for).set(true)
48
- end
49
-
50
- When /I go to (.+)/ do |path|
51
- $browser.goto @host + path_to(path)
52
- assert_successful_response
53
- end
54
-
55
- When /I wait for the AJAX call to finish/ do
56
- $browser.wait
57
- end
58
-
59
- Then /I should see "(.*)"/ do |text|
60
- # 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
61
- div = $browser.div(:text, /#{text}/)
62
- begin
63
- div.html
64
- rescue
65
- #puts $browser.html
66
- raise("div with '#{text}' not found")
67
- end
68
- end
69
-
70
- Then /I should not see "(.*)"/ do |text|
71
- div = $browser.div(:text, /#{text}/).html rescue nil
72
- div.should be_nil
73
- end
74
-
75
- def find_label(text)
76
- $browser.label :text, text
77
- end
78
-
79
- def assert_successful_response
80
- status = $browser.page.web_response.status_code
81
- if(status == 302 || status == 301)
82
- location = $browser.page.web_response.get_response_header_value('Location')
83
- puts "Being redirected to #{location}"
84
- $browser.goto location
85
- assert_successful_response
86
- elsif status != 200
87
- tmp = Tempfile.new 'culerity_results'
88
- tmp << $browser.html
89
- tmp.close
90
- `open -a /Applications/Safari.app #{tmp.path}`
91
- raise "Brower returned Response Code #{$browser.page.web_response.status_code}"
92
- end
93
- end