culerity 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,42 +5,32 @@ Feature: Installing culerity
5
5
 
6
6
  Background:
7
7
  Given a Rails app
8
- And I run executable "script/generate" with arguments "cucumber"
9
- And I delete file "features/step_definitions/webrat_steps.rb"
10
- And I copy the project generators into "vendor/generators"
11
- And I invoke task "rake db:migrate"
8
+ And I run executable "script/generate" with arguments "cucumber"
9
+ And I delete file "features/step_definitions/webrat_steps.rb"
10
+ And I delete file "features/support/env.rb"
11
+ And I copy the project generators into "vendor/generators"
12
+ And I invoke task "rake db:migrate"
12
13
  When I run executable "script/generate" with arguments "culerity"
13
- And I setup load path to local code
14
+ And I setup load path to local code
15
+ And I setup the culerity javascript helpers
14
16
 
15
- Scenario: Install culerity and setup jruby environment
16
- Given I have jruby installed
17
- When I invoke task "rake culerity:install"
18
- Then the gem "jarib-celerity" is installed into jruby environment
19
-
20
17
  Scenario: Install culerity and test the rails start + stop tasks
21
18
  When I invoke task "rake culerity:rails:start"
22
19
  Then file "tmp/culerity_rails_server.pid" is created
23
- And I invoke task "rake culerity:rails:stop"
20
+ And I invoke task "rake culerity:rails:stop"
24
21
  Then file "tmp/culerity_rails_server.pid" is not created
25
22
 
26
23
  Scenario: Install culerity into a Rails app and check it works
27
24
  Then file "features/step_definitions/culerity_steps.rb" is created
28
25
  Then file "config/environments/culerity_development.rb" is created
29
26
  Then file "config/environments/culerity_continuousintegration.rb" is created
30
-
31
- And I run executable "cucumber" with arguments "features/"
27
+
28
+ When I run executable "cucumber" with arguments "features/"
32
29
  Then I should see "0 scenarios"
33
- And I should see "0 steps"
34
-
30
+ And I should see "0 steps"
35
31
  Given I invoke task "rake culerity:rails:start"
36
-
37
32
  When I add a feature file to test Rails index.html default file
38
- And I run executable "cucumber" with arguments "features/"
33
+ And I run executable "cucumber" with arguments "features/"
39
34
  Then I should see "1 scenario"
40
- And I should see "5 steps (5 passed)"
41
- And I should not see "WARNING: Speed up executing by running 'rake culerity:rails:start'"
42
-
43
-
44
-
45
-
46
-
35
+ And I should see "5 steps (5 passed)"
36
+ And I should not see "WARNING: Speed up executing by running 'rake culerity:rails:start'"
@@ -5,20 +5,19 @@ Feature: Running cucumber without explicitly running external services
5
5
 
6
6
  Background:
7
7
  Given a Rails app
8
- And I run executable "script/generate" with arguments "cucumber"
9
- And I delete file "features/step_definitions/webrat_steps.rb"
10
- And I copy the project generators into "vendor/generators"
11
- And I invoke task "rake db:migrate"
8
+ And I run executable "script/generate" with arguments "cucumber"
9
+ And I delete file "features/step_definitions/webrat_steps.rb"
10
+ And I delete file "features/support/env.rb"
11
+ And I copy the project generators into "vendor/generators"
12
+ And I invoke task "rake db:migrate"
12
13
  When I run executable "script/generate" with arguments "culerity"
13
- And I setup load path to local code
14
+ And I setup load path to local code
15
+ And I setup the culerity javascript helpers
14
16
 
15
17
  Scenario: Successfully run scenarios without requiring celerity or rails processes running
16
18
  When I add a feature file to test Rails index.html default file
17
- And I run executable "cucumber" with arguments "features/"
19
+ And I run executable "cucumber" with arguments "features/"
18
20
  Then file "tmp/culerity_rails_server.pid" is not created
19
- And I should see "1 scenario"
20
- And I should see "5 steps (5 passed)"
21
- And I should see "WARNING: Speed up execution by running 'rake culerity:rails:start'"
22
-
23
-
24
-
21
+ And I should see "1 scenario"
22
+ And I should see "5 steps (5 passed)"
23
+ And I should see "WARNING: Speed up execution by running 'rake culerity:rails:start'"
@@ -19,6 +19,16 @@ When /^I add a feature file to test Rails index.html default file$/ do
19
19
  end
20
20
  end
21
21
 
22
+ When /^I setup the culerity javascript helpers$/ do
23
+ `cp #{File.dirname(__FILE__) + "/../fixtures/jquery"} #{File.join(@active_project_folder, 'public', 'javascripts', 'jquery.js')}`
24
+ in_project_folder do
25
+ _index = File.read('public/index.html')
26
+ File.open('public/index.html', 'w') do |f|
27
+ f << _index.sub('</head>', '<script type="text/javascript" src="javascripts/jquery.js"></script><script type="text/javascript" src="javascripts/culerity.js"></script><script type="text/javascript">jQuery.noConflict();</script></head>')
28
+ end
29
+ end
30
+ end
31
+
22
32
  After do
23
33
  in_project_folder do
24
34
  Given 'I invoke task "rake culerity:rails:stop"'
@@ -4,6 +4,7 @@ class CulerityGenerator < Rails::Generator::Base
4
4
  record do |m|
5
5
  m.directory 'features/step_definitions'
6
6
  m.file 'features/step_definitions/culerity_steps.rb', 'features/step_definitions/culerity_steps.rb'
7
+ m.file 'features/support/env.rb', 'features/support/env.rb'
7
8
  m.file 'config/environments/culerity_continuousintegration.rb', 'config/environments/culerity_continuousintegration.rb'
8
9
  m.file 'config/environments/culerity_development.rb', 'config/environments/culerity_development.rb'
9
10
 
@@ -13,6 +14,8 @@ class CulerityGenerator < Rails::Generator::Base
13
14
  m.gsub_file 'config/database.yml', /\z/, "\nculerity_continuousintegration:\n <<: *CUCUMBER"
14
15
 
15
16
  m.file "lib/tasks/culerity.rake", "lib/tasks/culerity.rake"
17
+
18
+ m.file 'public/javascripts/culerity.js', 'public/javascripts/culerity.js'
16
19
  end
17
20
  end
18
21
 
@@ -1,7 +1,7 @@
1
1
  require 'culerity'
2
2
 
3
3
  Before do
4
- $rails_server ||= Culerity::run_rails(:environment => 'culerity', :port => 3001)
4
+ $rails_server ||= Culerity::run_rails(:environment => 'culerity_development', :port => 3001)
5
5
  $server ||= Culerity::run_server
6
6
  $browser = Culerity::RemoteBrowserProxy.new $server, {:browser => :firefox3,
7
7
  :javascript_exceptions => true,
@@ -18,40 +18,39 @@ at_exit do
18
18
  Process.kill(6, $rails_server.pid.to_i) if $rails_server
19
19
  end
20
20
 
21
- When /I follow "(.*)"/ do |link|
21
+ When /I follow "([^\"]*)"/ do |link|
22
22
  _link = [[:text, /^#{Regexp.escape(link)}$/], [:id, link], [:title, link]].map{|args| $browser.link(*args)}.find{|__link| __link.exist?}
23
23
  raise "link \"#{link}\" not found" unless _link
24
24
  _link.click
25
- $browser.wait
26
25
  assert_successful_response
27
26
  end
28
27
 
29
- When /I press "(.*)"/ do |button|
28
+ When /I press "([^\"]*)"/ do |button|
30
29
  $browser.button(:text, button).click
31
30
  assert_successful_response
32
31
  end
33
32
 
34
- When /I fill in "(.*)" with "(.*)"/ do |field, value|
33
+ When /I fill in "([^\"]*)" with "([^\"]*)"/ do |field, value|
35
34
  find_by_label_or_id(:text_field, field).set(value)
36
35
  end
37
36
 
38
- When /I fill in "(.*)" for "(.*)"/ do |value, field|
37
+ When /I fill in "([^\"]*)" for "([^\"]*)"/ do |value, field|
39
38
  find_by_label_or_id(:text_field, field).set(value)
40
39
  end
41
40
 
42
- When /I check "(.*)"/ do |field|
41
+ When /I check "([^\"]*)"/ do |field|
43
42
  find_by_label_or_id(:check_box, field).set(true)
44
43
  end
45
44
 
46
- When /^I uncheck "(.*)"$/ do |field|
45
+ When /^I uncheck "([^\"]*)"$/ do |field|
47
46
  find_by_label_or_id(:check_box, field).set(true)
48
47
  end
49
48
 
50
- When /I select "(.*)" from "(.*)"/ do |value, field|
49
+ When /I select "([^\"]*)" from "([^\"]*)"/ do |value, field|
51
50
  find_by_label_or_id(:select_list, field).select value
52
51
  end
53
52
 
54
- When /I choose "(.*)"/ do |field|
53
+ When /I choose "([^\"]*)"/ do |field|
55
54
  find_by_label_or_id(:radio, field).set(true)
56
55
  end
57
56
 
@@ -60,17 +59,28 @@ When /I go to (.+)/ do |path|
60
59
  assert_successful_response
61
60
  end
62
61
 
63
- When /I wait for the AJAX call to finish/ do
64
- $browser.wait
62
+ When /^I wait for the AJAX call to finish$/ do
63
+ $browser.wait_while do
64
+ begin
65
+ count = $browser.execute_script("window.running_ajax_calls").to_i
66
+ count.to_i > 0
67
+ rescue => e
68
+ if e.message.include?('HtmlunitCorejsJavascript::Undefined')
69
+ raise "For 'I wait for the AJAX call to finish' to work please include culerity.js after including jQuery. If you don't use jQuery please rewrite culerity.js accordingly."
70
+ else
71
+ raise(e)
72
+ end
73
+ end
74
+ end
65
75
  end
66
76
 
67
- Then /I should see "(.*)"/ do |text|
77
+ Then /I should see "([^\"]*)"/ do |text|
68
78
  # 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
79
  div = $browser.div(:text, /#{text}/)
70
80
  div.should be_exist
71
81
  end
72
82
 
73
- Then /I should not see "(.*)"/ do |text|
83
+ Then /I should not see "([^\"]*)"/ do |text|
74
84
  div = $browser.div(:text, /#{text}/)
75
85
  div.should_not be_exist
76
86
  end
@@ -0,0 +1,9 @@
1
+ ENV["RAILS_ENV"] ||= "culerity_development"
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
3
+ require 'cucumber/rails/world'
4
+
5
+ Cucumber::Rails::World.use_transactional_fixtures = false
6
+ ActionController::Base.allow_rescue = false
7
+
8
+ require 'cucumber/formatter/unicode'
9
+ require 'cucumber/rails/rspec'
@@ -33,6 +33,6 @@ namespace 'culerity' do
33
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
- sh "#{jgem_cmd} -S gem install jarib-celerity --source=http://gems.github.com"
36
+ sh "#{jgem_cmd} -S gem install celerity"
37
37
  end
38
38
  end
@@ -0,0 +1,27 @@
1
+ // this allows culerity to wait until all ajax requests have finished
2
+ jQuery(function($) {
3
+ var original_ajax = $.ajax;
4
+ var count_down = function(callback) {
5
+ return function() {
6
+ try {
7
+ if(callback) {
8
+ callback.apply(this, arguments);
9
+ };
10
+ } catch(e) {
11
+ window.running_ajax_calls -= 1;
12
+ throw(e);
13
+ }
14
+ window.running_ajax_calls -= 1;
15
+ }
16
+ };
17
+ window.running_ajax_calls = 0;
18
+
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);
24
+ };
25
+
26
+ $.ajax = ajax_with_count;
27
+ });
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.4
4
+ version: 0.2.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-11-22 00:00:00 +01:00
12
+ date: 2009-11-28 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,11 +42,13 @@ extra_rdoc_files:
42
42
  - README.md
43
43
  files:
44
44
  - .gitignore
45
+ - CHANGES.md
45
46
  - MIT-LICENSE
46
47
  - README.md
47
48
  - Rakefile
48
49
  - VERSION.yml
49
50
  - culerity.gemspec
51
+ - features/fixtures/jquery
50
52
  - features/fixtures/sample_feature
51
53
  - features/installing_culerity.feature
52
54
  - features/running_cucumber_without_explicitly_running_external_services.feature
@@ -67,7 +69,9 @@ files:
67
69
  - rails_generators/culerity/templates/config/environments/culerity_continuousintegration.rb
68
70
  - rails_generators/culerity/templates/config/environments/culerity_development.rb
69
71
  - rails_generators/culerity/templates/features/step_definitions/culerity_steps.rb
72
+ - rails_generators/culerity/templates/features/support/env.rb
70
73
  - rails_generators/culerity/templates/lib/tasks/culerity.rake
74
+ - rails_generators/culerity/templates/public/javascripts/culerity.js
71
75
  - script/console
72
76
  - script/destroy
73
77
  - script/generate