culerity 0.2.10 → 0.2.12

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 10
4
+ :patch: 12
5
5
  :build:
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.10"
8
+ s.version = "0.2.12"
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{2010-04-28}
12
+ s.date = %q{2010-08-20}
13
13
  s.default_executable = %q{run_celerity_server.rb}
14
14
  s.description = %q{Culerity integrates Cucumber and Celerity in order to test your application's full stack.}
15
15
  s.email = %q{alex@upstream-berlin.com}
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
43
43
  "lib/culerity/persistent_delivery.rb",
44
44
  "lib/culerity/remote_browser_proxy.rb",
45
45
  "lib/culerity/remote_object_proxy.rb",
46
+ "lib/start_celerity.rb",
46
47
  "lib/tasks/rspec.rake",
47
48
  "rails/init.rb",
48
49
  "rails_generators/culerity/culerity_generator.rb",
@@ -5,15 +5,17 @@ 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"
8
+ And I run executable "script/generate" with arguments "cucumber --rspec --webrat"
9
+ And I delete file "features/step_definitions/web_steps.rb"
10
10
  And I delete file "features/support/env.rb"
11
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
15
15
  And I setup the culerity javascript helpers
16
-
16
+ And I add the JRUBY_INVOCATION check to "features/support/env.rb"
17
+ And I add an rvm_verbose_flag=0-wielding .rvmrc to the home folder
18
+
17
19
  Scenario: Install culerity and test the rails start + stop tasks
18
20
  When I invoke task "rake culerity:rails:start"
19
21
  Then file "tmp/culerity_rails_server.pid" is created
@@ -23,7 +25,7 @@ Feature: Installing culerity
23
25
  Scenario: Install culerity into a Rails app and check it works
24
26
  Then file "features/step_definitions/culerity_steps.rb" is created
25
27
  Then file "config/environments/culerity.rb" is created
26
-
28
+
27
29
  When I run executable "cucumber" with arguments "features/"
28
30
  Then I should see "0 scenarios"
29
31
  And I should see "0 steps"
@@ -32,4 +34,4 @@ Feature: Installing culerity
32
34
  And I run executable "cucumber" with arguments "features/"
33
35
  Then I should see "1 scenario"
34
36
  And I should see "5 steps (5 passed)"
35
- And I should not see "WARNING: Speed up executing by running 'rake culerity:rails:start'"
37
+ And I should not see "WARNING: Speed up executing by running 'rake culerity:rails:start'"
@@ -5,14 +5,16 @@ 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"
8
+ And I run executable "script/generate" with arguments "cucumber --rspec --webrat"
9
+ And I delete file "features/step_definitions/web_steps.rb"
10
10
  And I delete file "features/support/env.rb"
11
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
15
15
  And I setup the culerity javascript helpers
16
+ And I add the JRUBY_INVOCATION check to "features/support/env.rb"
17
+ And I add an rvm_verbose_flag=0-wielding .rvmrc to the home folder
16
18
 
17
19
  Scenario: Successfully run scenarios without requiring celerity or rails processes running
18
20
  When I add a feature file to test Rails index.html default file
@@ -26,6 +26,14 @@ When /^I add a feature file to test Rails index.html default file$/ do
26
26
  end
27
27
  end
28
28
 
29
+ When /^(?:I )?add an rvm_verbose_flag=0-wielding \.rvmrc to the home folder$/ do
30
+ in_home_folder do
31
+ File.open('.rvmrc', 'w+') do |f|
32
+ f.puts "rvm_verbose_flag=0"
33
+ end
34
+ end
35
+ end
36
+
29
37
  When /^I setup the culerity javascript helpers$/ do
30
38
  `cp #{File.dirname(__FILE__) + "/../fixtures/jquery"} #{File.join(@active_project_folder, 'public', 'javascripts', 'jquery.js')}`
31
39
  in_project_folder do
@@ -21,3 +21,4 @@ include RubiGen::GeneratorTestHelper
21
21
  SOURCES = Dir[File.dirname(__FILE__) + "/../../generators"].map do |f|
22
22
  RubiGen::PathSource.new(:test, File.expand_path(f))
23
23
  end
24
+
data/lib/culerity.rb CHANGED
@@ -23,9 +23,25 @@ module Culerity
23
23
  self.puts '["_clear_proxies_"]'
24
24
  end
25
25
  end
26
-
26
+
27
+ def self.culerity_root
28
+ File.expand_path('../../', __FILE__)
29
+ end
30
+
31
+ def self.celerity_invocation
32
+ %{#{culerity_root}/lib/start_celerity.rb}
33
+ end
34
+
35
+ def self.jruby_invocation
36
+ @jruby_invocation ||= (ENV["JRUBY_INVOCATION"] || "jruby")
37
+ end
38
+
39
+ def self.jruby_invocation=(invocation)
40
+ @jruby_invocation = invocation
41
+ end
42
+
27
43
  def self.run_server
28
- IO.popen(File.dirname(__FILE__) + "/../bin/run_celerity_server.rb", 'r+').extend(ServerCommands)
44
+ IO.popen(%{#{jruby_invocation} "#{celerity_invocation}"}, 'r+').extend(ServerCommands)
29
45
  end
30
46
 
31
47
  def self.run_rails(options = {})
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'culerity/celerity_server'
3
+ Culerity::CelerityServer.new(STDIN, STDOUT)
@@ -1,4 +1,4 @@
1
- config.cache_classes = false
1
+ config.cache_classes = true # set because of https://rspec.lighthouseapp.com/projects/16211/tickets/165
2
2
 
3
3
  # Log error messages when you accidentally call methods on nil.
4
4
  config.whiny_nils = true
@@ -146,14 +146,11 @@ Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
146
146
  end
147
147
 
148
148
  Then /I should see "([^\"]*)"/ do |text|
149
- # 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
150
- div = $browser.div(:text, /#{Regexp::escape(text)}/)
151
- div.should be_exist
149
+ $browser.text.include?(text).should be_true
152
150
  end
153
151
 
154
152
  Then /I should not see "([^\"]*)"/ do |text|
155
- div = $browser.div(:text, /#{Regexp::escape(text)}/)
156
- div.should_not be_exist
153
+ $browser.text.include?(text).should_not be_true
157
154
  end
158
155
 
159
156
  def find_by_label_or_id(element, attribute)
@@ -1,47 +1,112 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe Culerity, 'run_rails' do
4
- before(:each) do
5
- Kernel.stub!(:sleep)
6
- IO.stub!(:popen)
7
- Culerity.stub!(:fork).and_yield.and_return(3200)
8
- Culerity.stub!(:exec)
9
- Culerity.stub!(:sleep)
10
- [$stdin, $stdout, $stderr].each{|io| io.stub(:reopen)}
3
+ describe Culerity do
4
+ describe 'run_rails' do
5
+ def stub_rails_root!
6
+ unless defined?(::Rails)
7
+ Kernel.const_set "Rails", stub()
8
+ end
9
+ Rails.stub!(:root).and_return(Dir.pwd)
10
+ end
11
+
12
+ before(:each) do
13
+ Kernel.stub!(:sleep)
14
+ IO.stub!(:popen)
15
+ Culerity.stub!(:fork).and_yield.and_return(3200)
16
+ Culerity.stub!(:exec)
17
+ Culerity.stub!(:sleep)
18
+ [$stdin, $stdout, $stderr].each{|io| io.stub(:reopen)}
19
+ end
20
+
21
+ it "should not run rails if we are not using rails" do
22
+ Culerity.should_not_receive(:exec)
23
+ Culerity.run_rails :port => 4000, :environment => 'culerity'
24
+ end
25
+
26
+ describe "when Rails is being used" do
27
+ before(:each) do
28
+ stub_rails_root!
29
+ end
30
+
31
+ it "should run rails with default values" do
32
+ Culerity.should_receive(:exec).with("script/server -e culerity -p 3001")
33
+ Culerity.run_rails
34
+ end
35
+
36
+ it "should run rails with the given values" do
37
+ Culerity.should_receive(:exec).with("script/server -e culerity -p 4000")
38
+ Culerity.run_rails :port => 4000, :environment => 'culerity'
39
+ end
40
+
41
+ it "should change into the rails root directory" do
42
+ Dir.should_receive(:chdir).with(Dir.pwd)
43
+ Culerity.run_rails :port => 4000, :environment => 'culerity'
44
+ end
45
+
46
+ it "should wait for the server to start up" do
47
+ Culerity.should_receive(:sleep)
48
+ Culerity.run_rails :port => 4000, :environment => 'culerity'
49
+ end
50
+
51
+ it "should reopen the i/o channels to /dev/null" do
52
+ [$stdin, $stdout, $stderr].each{|io| io.should_receive(:reopen).with("/dev/null")}
53
+ Culerity.run_rails :port => 4000, :environment => 'culerity'
54
+ end
55
+ end
11
56
  end
12
57
 
13
- it "should not run rails if we are not using rails" do
14
- Culerity.should_not_receive(:exec)
15
- Culerity.run_rails :port => 4000, :environment => 'culerity'
16
- end
17
-
18
- it "should run rails with default values" do
19
- Rails ||= stub(:rails, :root => Dir.pwd)
20
- Culerity.should_receive(:exec).with("script/server -e culerity -p 3001")
21
- Culerity.run_rails
22
- end
23
-
24
- it "should run rails with the given values" do
25
- Rails ||= stub(:rails, :root => Dir.pwd)
26
- Culerity.should_receive(:exec).with("script/server -e culerity -p 4000")
27
- Culerity.run_rails :port => 4000, :environment => 'culerity'
28
- end
29
-
30
- it "should change into the rails root directory" do
31
- Rails ||= stub(:rails, :root => Dir.pwd)
32
- Dir.should_receive(:chdir).with(Dir.pwd)
33
- Culerity.run_rails :port => 4000, :environment => 'culerity'
34
- end
35
-
36
- it "should wait for the server to start up" do
37
- Rails ||= stub(:rails, :root => Dir.pwd)
38
- Culerity.should_receive(:sleep)
39
- Culerity.run_rails :port => 4000, :environment => 'culerity'
40
- end
41
-
42
- it "should reopen the i/o channels to /dev/null" do
43
- Rails ||= stub(:rails, :root => Dir.pwd)
44
- [$stdin, $stdout, $stderr].each{|io| io.should_receive(:reopen).with("/dev/null")}
45
- Culerity.run_rails :port => 4000, :environment => 'culerity'
58
+ describe "run_server" do
59
+ before(:each) do
60
+ IO.stub!(:popen)
61
+ end
62
+
63
+ after(:each) do
64
+ Culerity.jruby_invocation = nil
65
+ end
66
+
67
+ it "knows where it is located" do
68
+ Culerity.culerity_root.should == File.expand_path(File.dirname(__FILE__) + '/../')
69
+ end
70
+
71
+ it "has access to the Celerity invocation" do
72
+ Culerity.stub!(:culerity_root).and_return('/path/to/culerity')
73
+
74
+ Culerity.celerity_invocation.should == "/path/to/culerity/lib/start_celerity.rb"
75
+ end
76
+
77
+ describe "invoking JRuby" do
78
+ it "knows how to invoke it" do
79
+ Culerity.jruby_invocation.should == 'jruby'
80
+ end
81
+
82
+ it "allows for the invocation to be overridden directly" do
83
+ Culerity.jruby_invocation = '/opt/local/bin/jruby'
84
+
85
+ Culerity.jruby_invocation.should == '/opt/local/bin/jruby'
86
+ end
87
+
88
+ it "allows for the invocation to be overridden from an environment variable" do
89
+ ENV['JRUBY_INVOCATION'] = 'rvm jruby ruby'
90
+
91
+ Culerity.jruby_invocation.should == 'rvm jruby ruby'
92
+ end
93
+ end
94
+
95
+ it "shells out and sparks up jruby with the correct invocation" do
96
+ Culerity.stub!(:celerity_invocation).and_return('/path/to/start_celerity.rb')
97
+
98
+ IO.should_receive(:popen).with('jruby "/path/to/start_celerity.rb"', 'r+')
99
+
100
+ Culerity.run_server
101
+ end
102
+
103
+ it "allows a more complex situation, e.g. using RVM + named gemset" do
104
+ Culerity.stub!(:celerity_invocation).and_return('/path/to/start_celerity.rb')
105
+
106
+ IO.should_receive(:popen).with('rvm jruby@culerity ruby "/path/to/start_celerity.rb"', 'r+')
107
+
108
+ Culerity.jruby_invocation = "rvm jruby@culerity ruby"
109
+ Culerity.run_server
110
+ end
46
111
  end
47
112
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 10
9
- version: 0.2.10
8
+ - 12
9
+ version: 0.2.12
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alexander Lang
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-28 00:00:00 +02:00
17
+ date: 2010-08-20 00:00:00 +02:00
18
18
  default_executable: run_celerity_server.rb
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -75,6 +75,7 @@ files:
75
75
  - lib/culerity/persistent_delivery.rb
76
76
  - lib/culerity/remote_browser_proxy.rb
77
77
  - lib/culerity/remote_object_proxy.rb
78
+ - lib/start_celerity.rb
78
79
  - lib/tasks/rspec.rake
79
80
  - rails/init.rb
80
81
  - rails_generators/culerity/culerity_generator.rb