culerity 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.8
2
+
3
+ * removed separate development and continuous integration environments and replaced them with a single one (thilo)
4
+ * more webrat like step definitions (lupine)
5
+ * improve on stability issues (mattmatt)
6
+
1
7
  ## 0.2.7
2
8
 
3
9
  * fixed RemoteBrowser#confirm called celerity remove_listener with invalid arguments
@@ -11,4 +17,4 @@
11
17
 
12
18
  ## Before that
13
19
 
14
- Lots of important contributions from a bunch of people. check the commit logs.
20
+ Lots of important contributions from a bunch of people. check the commit logs.
data/README.md CHANGED
@@ -41,7 +41,7 @@ After you have written a first feature you can run it just like you would run a
41
41
  rake culerity:rails:start
42
42
  cucumber features/my_feature.feature
43
43
 
44
- The Rails instance uses a special environment culerity_development.
44
+ The Rails instance uses a special environment culerity.
45
45
 
46
46
  When you have finished running culerity/cucumber you can turn off the Rails instance:
47
47
 
@@ -73,7 +73,7 @@ My database is not cleared automatically between scenarios
73
73
 
74
74
  Before do
75
75
  [User, .... all your models].each do |model|
76
- mode.delete_all
76
+ model.delete_all
77
77
  end
78
78
  end
79
79
 
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :build:
3
- :patch: 7
3
+ :patch: 8
4
4
  :major: 0
5
5
  :minor: 2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{culerity}
8
- s.version = "0.2.7"
8
+ s.version = "0.2.8"
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-01-17}
12
+ s.date = %q{2010-02-06}
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 = [
@@ -40,10 +40,11 @@ Gem::Specification.new do |s|
40
40
  "lib/culerity/persistent_delivery.rb",
41
41
  "lib/culerity/remote_browser_proxy.rb",
42
42
  "lib/culerity/remote_object_proxy.rb",
43
+ "lib/tasks/rspec.rake",
43
44
  "rails/init.rb",
44
45
  "rails_generators/culerity/culerity_generator.rb",
46
+ "rails_generators/culerity/templates/config/environments/culerity.rb",
45
47
  "rails_generators/culerity/templates/config/environments/culerity_continuousintegration.rb",
46
- "rails_generators/culerity/templates/config/environments/culerity_development.rb",
47
48
  "rails_generators/culerity/templates/features/step_definitions/culerity_steps.rb",
48
49
  "rails_generators/culerity/templates/features/support/env.rb",
49
50
  "rails_generators/culerity/templates/lib/tasks/culerity.rake",
@@ -22,8 +22,7 @@ Feature: Installing culerity
22
22
 
23
23
  Scenario: Install culerity into a Rails app and check it works
24
24
  Then file "features/step_definitions/culerity_steps.rb" is created
25
- Then file "config/environments/culerity_development.rb" is created
26
- Then file "config/environments/culerity_continuousintegration.rb" is created
25
+ Then file "config/environments/culerity.rb" is created
27
26
 
28
27
  When I run executable "cucumber" with arguments "features/"
29
28
  Then I should see "0 scenarios"
@@ -17,7 +17,6 @@ end
17
17
  require 'rubigen'
18
18
  require 'rubigen/helpers/generator_test_helper'
19
19
  include RubiGen::GeneratorTestHelper
20
- require 'rails_generator'
21
20
 
22
21
  SOURCES = Dir[File.dirname(__FILE__) + "/../../generators"].map do |f|
23
22
  RubiGen::PathSource.new(:test, File.expand_path(f))
@@ -28,8 +28,15 @@ module Culerity
28
28
  if defined?(Rails) && !File.exists?("tmp/culerity_rails_server.pid")
29
29
  puts "WARNING: Speed up execution by running 'rake culerity:rails:start'"
30
30
  port = options[:port] || 3001
31
- environment = options[:environment] || 'culerity_development'
32
- rails_server = IO.popen("script/server -e #{environment} -p #{port}", 'r+')
31
+ environment = options[:environment] || 'culerity'
32
+ rails_server = fork do
33
+ $stdin.reopen "/dev/null"
34
+ $stdout.reopen "/dev/null"
35
+ $stderr.reopen "/dev/null"
36
+ Dir.chdir(Rails.root) do
37
+ exec "script/server -e #{environment} -p #{port}"
38
+ end
39
+ end
33
40
  sleep 5
34
41
  rails_server
35
42
  end
@@ -1,9 +1,10 @@
1
1
  module Culerity
2
-
3
2
  class RemoteBrowserProxy < RemoteObjectProxy
4
3
  def initialize(io, browser_options = {})
5
4
  @io = io
6
- @remote_object_id = "celerity".inspect
5
+ #sets the remote receiver to celerity for the new_browser message.
6
+ @remote_object_id = "celerity".inspect
7
+ #celerity server will create a new browser which shall receive the remote calls from now on.
7
8
  @remote_object_id = new_browser(browser_options).inspect
8
9
  end
9
10
 
@@ -3,7 +3,7 @@ module Culerity
3
3
  class CulerityException < StandardError
4
4
  def initialize(message, backtrace)
5
5
  super message
6
- #self.backtrace = backtrace
6
+ set_backtrace(backtrace)
7
7
  end
8
8
  end
9
9
 
@@ -0,0 +1,66 @@
1
+ gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
2
+
3
+ # Don't load rspec if running "rake gems:*"
4
+ unless ARGV.any? {|a| a =~ /^gems/}
5
+
6
+ begin
7
+ require 'spec/rake/spectask'
8
+ rescue MissingSourceFile
9
+ module Spec
10
+ module Rake
11
+ class SpecTask
12
+ def initialize(name)
13
+ task name do
14
+ # if rspec-rails is a configured gem, this will output helpful material and exit ...
15
+ require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
16
+
17
+ # ... otherwise, do this:
18
+ raise <<-MSG
19
+
20
+ #{"*" * 80}
21
+ * You are trying to run an rspec rake task defined in
22
+ * #{__FILE__},
23
+ * but rspec can not be found in vendor/gems, vendor/plugins or system gems.
24
+ #{"*" * 80}
25
+ MSG
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ Rake.application.instance_variable_get('@tasks').delete('default')
34
+
35
+ spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
36
+ task :noop do
37
+ end
38
+
39
+ task :default => [:spec,:features]
40
+ task :stats => "spec:statsetup"
41
+
42
+ desc "Run all specs in spec directory (excluding plugin specs)"
43
+ Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
44
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
45
+ t.spec_files = FileList['spec/**/*/*_spec.rb']
46
+ end
47
+
48
+ desc "Run all specs in the spec directory with html output (excluding plugins specs)"
49
+ Spec::Rake::SpecTask.new(:spec_html => spec_prereq) do |t|
50
+ t.spec_opts = ['--colour', '--format html', '--loadby mtime', '--reverse']
51
+ t.spec_files = FileList['spec/**/*/*_spec.rb']
52
+ end
53
+
54
+ namespace :spec do
55
+ desc "Run all specs in spec directory with RCov (excluding plugin specs)"
56
+ Spec::Rake::SpecTask.new(:rcov) do |t|
57
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
58
+ t.spec_files = FileList['spec/**/*/*_spec.rb']
59
+ t.rcov = true
60
+ t.rcov_opts = lambda do
61
+ IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
62
+ end
63
+ end
64
+ end
65
+
66
+ end
@@ -5,13 +5,11 @@ class CulerityGenerator < Rails::Generator::Base
5
5
  m.directory 'features/step_definitions'
6
6
  m.file 'features/step_definitions/culerity_steps.rb', 'features/step_definitions/culerity_steps.rb'
7
7
  m.file 'features/support/env.rb', 'features/support/env.rb'
8
- m.file 'config/environments/culerity_continuousintegration.rb', 'config/environments/culerity_continuousintegration.rb'
9
- m.file 'config/environments/culerity_development.rb', 'config/environments/culerity_development.rb'
8
+ m.file 'config/environments/culerity.rb', 'config/environments/culerity.rb'
10
9
 
11
10
  m.gsub_file 'config/database.yml', /cucumber:.*\n/, "cucumber: &CUCUMBER\n"
12
11
 
13
- m.gsub_file 'config/database.yml', /\z/, "\nculerity_development:\n <<: *CUCUMBER"
14
- m.gsub_file 'config/database.yml', /\z/, "\nculerity_continuousintegration:\n <<: *CUCUMBER"
12
+ m.gsub_file 'config/database.yml', /\z/, "\nculerity:\n <<: *CUCUMBER"
15
13
 
16
14
  m.file "lib/tasks/culerity.rake", "lib/tasks/culerity.rake"
17
15
 
@@ -1,7 +1,7 @@
1
1
  require 'culerity'
2
2
 
3
3
  Before do
4
- $rails_server ||= Culerity::run_rails(:environment => 'culerity_development', :port => 3001)
4
+ $rails_server ||= Culerity::run_rails(:environment => 'culerity', :port => 3001)
5
5
  $server ||= Culerity::run_server
6
6
  $browser = Culerity::RemoteBrowserProxy.new $server, {:browser => :firefox3,
7
7
  :javascript_exceptions => true,
@@ -18,8 +18,17 @@ at_exit do
18
18
  Process.kill(6, $rails_server.pid.to_i) if $rails_server
19
19
  end
20
20
 
21
+ Given /^(?:|I )am on (.+)$/ do |page_name|
22
+ $browser.goto @host + path_to(page_name)
23
+ end
24
+
21
25
  When /I follow "([^\"]*)"/ do |link|
22
- _link = [[:text, /^#{Regexp.escape(link)}$/], [:id, link], [:title, link]].map{|args| $browser.link(*args)}.find{|__link| __link.exist?}
26
+ _link = [
27
+ [:text, /^#{Regexp.escape(link)}$/ ],
28
+ [:id, link],
29
+ [:title, link],
30
+ [:text, /#{Regexp.escape(link)}/ ],
31
+ ].map{|args| $browser.link(*args)}.find{|__link| __link.exist?}
23
32
  raise "link \"#{link}\" not found" unless _link
24
33
  _link.click
25
34
  assert_successful_response
@@ -43,7 +52,7 @@ When /I check "([^\"]*)"/ do |field|
43
52
  end
44
53
 
45
54
  When /^I uncheck "([^\"]*)"$/ do |field|
46
- find_by_label_or_id(:check_box, field).set(true)
55
+ find_by_label_or_id(:check_box, field).set(false)
47
56
  end
48
57
 
49
58
  When /I select "([^\"]*)" from "([^\"]*)"/ do |value, field|
@@ -74,14 +83,69 @@ When /^I wait for the AJAX call to finish$/ do
74
83
  end
75
84
  end
76
85
 
86
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
87
+ current_path = URI.parse($browser.url)
88
+ expected_path = URI.parse(path_to(page_name))
89
+
90
+ # If our expected path doesn't specify a query-string, ignore any query string
91
+ # in the current path
92
+ current_path, expected_path = if expected_path.query.nil?
93
+ [ current_path.path, expected_path.path ]
94
+ else
95
+ [ current_path.select(:path, :query).compact.join('?'), path_to(page_name) ]
96
+ end
97
+
98
+ if defined?(Spec::Rails::Matchers)
99
+ current_path.should == path_to(page_name)
100
+ else
101
+ assert_equal path_to(page_name), current_path
102
+ end
103
+ end
104
+
105
+ Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
106
+ f = find_by_label_or_id(:text_field, field)
107
+ if defined?(Spec::Rails::Matchers)
108
+ f.text.should =~ /#{Regexp::escape(value)}/
109
+ else
110
+ assert_match(/#{Regexp::escape(value)}/, f.text)
111
+ end
112
+ end
113
+
114
+ Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
115
+ f = find_by_label_or_id(:text_field, field)
116
+ if defined?(Spec::Rails::Matchers)
117
+ f.text.should_not =~ /#{Regexp::escape(value)}/
118
+ else
119
+ assert_no_match(/#{Regexp::escape(value)}/, f.text)
120
+ end
121
+ end
122
+
123
+ Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
124
+ f = find_by_label_or_id(:check_box, label)
125
+ if defined?(Spec::Rails::Matchers)
126
+ f.should be_checked
127
+ else
128
+ assert f.checked?
129
+ end
130
+ end
131
+
132
+ Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
133
+ f = find_by_label_or_id(:check_box, label)
134
+ if defined?(Spec::Rails::Matchers)
135
+ f.should_not be_checked
136
+ else
137
+ assert !f.checked?
138
+ end
139
+ end
140
+
77
141
  Then /I should see "([^\"]*)"/ do |text|
78
142
  # 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
79
- div = $browser.div(:text, /#{text}/)
143
+ div = $browser.div(:text, /#{Regexp::escape(text)}/)
80
144
  div.should be_exist
81
145
  end
82
146
 
83
147
  Then /I should not see "([^\"]*)"/ do |text|
84
- div = $browser.div(:text, /#{text}/)
148
+ div = $browser.div(:text, /#{Regexp::escape(text)}/)
85
149
  div.should_not be_exist
86
150
  end
87
151
 
@@ -1,4 +1,4 @@
1
- ENV["RAILS_ENV"] ||= "culerity_development"
1
+ ENV["RAILS_ENV"] ||= "culerity"
2
2
  require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
3
3
  require 'cucumber/rails/world'
4
4
 
@@ -3,7 +3,7 @@ namespace 'culerity' do
3
3
  desc "Starts a rails server for cucumber/culerity tests"
4
4
  task :start do
5
5
  port = ENV['PORT'] || 3001
6
- environment = ENV["RAILS_ENV"] || 'culerity_development'
6
+ environment = ENV["RAILS_ENV"] || 'culerity'
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"
@@ -4,30 +4,44 @@ describe Culerity, 'run_rails' do
4
4
  before(:each) do
5
5
  Kernel.stub!(:sleep)
6
6
  IO.stub!(:popen)
7
+ Culerity.stub!(:fork).and_yield.and_return(3200)
8
+ Culerity.stub!(:exec)
7
9
  Culerity.stub!(:sleep)
10
+ [$stdin, $stdout, $stderr].each{|io| io.stub(:reopen)}
8
11
  end
9
12
 
10
13
  it "should not run rails if we are not using rails" do
11
- IO.should_not_receive(:popen)
14
+ Culerity.should_not_receive(:exec)
12
15
  Culerity.run_rails :port => 4000, :environment => 'culerity'
13
16
  end
14
17
 
15
18
  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+')
19
+ Rails ||= stub(:rails, :root => Dir.pwd)
20
+ Culerity.should_receive(:exec).with("script/server -e culerity -p 3001")
18
21
  Culerity.run_rails
19
22
  end
20
23
 
21
24
  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+')
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)
24
33
  Culerity.run_rails :port => 4000, :environment => 'culerity'
25
-
26
34
  end
27
35
 
28
36
  it "should wait for the server to start up" do
29
- Rails ||= :rails
37
+ Rails ||= stub(:rails, :root => Dir.pwd)
30
38
  Culerity.should_receive(:sleep)
31
39
  Culerity.run_rails :port => 4000, :environment => 'culerity'
32
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'
46
+ end
33
47
  end
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.7
4
+ version: 0.2.8
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: 2010-01-17 00:00:00 +01:00
12
+ date: 2010-02-06 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -65,10 +65,11 @@ files:
65
65
  - lib/culerity/persistent_delivery.rb
66
66
  - lib/culerity/remote_browser_proxy.rb
67
67
  - lib/culerity/remote_object_proxy.rb
68
+ - lib/tasks/rspec.rake
68
69
  - rails/init.rb
69
70
  - rails_generators/culerity/culerity_generator.rb
71
+ - rails_generators/culerity/templates/config/environments/culerity.rb
70
72
  - rails_generators/culerity/templates/config/environments/culerity_continuousintegration.rb
71
- - rails_generators/culerity/templates/config/environments/culerity_development.rb
72
73
  - rails_generators/culerity/templates/features/step_definitions/culerity_steps.rb
73
74
  - rails_generators/culerity/templates/features/support/env.rb
74
75
  - rails_generators/culerity/templates/lib/tasks/culerity.rake