culerity 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +106 -0
- data/Rakefile +43 -0
- data/VERSION.yml +4 -0
- data/culerity.gemspec +78 -0
- data/features/fixtures/sample_feature +14 -0
- data/features/installing_culerity.feature +46 -0
- data/features/running_cucumber_without_explicitly_running_external_services.feature +24 -0
- data/features/step_definitions/common_steps.rb +175 -0
- data/features/step_definitions/culerity_setup_steps.rb +7 -0
- data/features/step_definitions/jruby_steps.rb +11 -0
- data/features/step_definitions/rails_setup_steps.rb +26 -0
- data/features/support/common.rb +32 -0
- data/features/support/env.rb +24 -0
- data/features/support/matchers.rb +11 -0
- data/init.rb +1 -0
- data/lib/culerity.rb +60 -0
- data/lib/culerity/celerity_server.rb +81 -0
- data/lib/culerity/remote_browser_proxy.rb +58 -0
- data/lib/culerity/remote_object_proxy.rb +76 -0
- data/rails/init.rb +1 -0
- data/rails_generators/culerity/culerity_generator.rb +25 -0
- data/rails_generators/culerity/templates/config/environments/culerity_continuousintegration.rb +28 -0
- data/rails_generators/culerity/templates/config/environments/culerity_development.rb +17 -0
- data/rails_generators/culerity/templates/features/step_definitions/common_celerity_steps.rb +93 -0
- data/rails_generators/culerity/templates/lib/tasks/culerity.rake +38 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/celerity_server_spec.rb +97 -0
- data/spec/remote_browser_proxy_spec.rb +62 -0
- data/spec/remote_object_proxy_spec.rb +63 -0
- data/spec/spec_helper.rb +7 -0
- metadata +110 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Alexander Lang
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
h2. Introduction
|
2
|
+
|
3
|
+
Culerity integrates Cucumber and Celerity in order to test your application's full stack.
|
4
|
+
|
5
|
+
Culerity lets you:
|
6
|
+
* run Celerity from within Cucumber which allows you to test the full stack of your Rails (or other web) application from Database to in browser JavaScript
|
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
|
+
* reuse existing Webrat-Style step definitions
|
9
|
+
|
10
|
+
h2. Getting Started
|
11
|
+
|
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
|
+
|
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
|
+
|
16
|
+
<pre><code> export PATH=$HOME/jruby/bin:$PATH</code></pre>
|
17
|
+
|
18
|
+
... or by creating a symlink from your bin directory:
|
19
|
+
|
20
|
+
<pre><code> ln -s $HOME/jruby/bin/jruby /usr/bin/jruby</code></pre>
|
21
|
+
|
22
|
+
Now (assuming you have a Rails application set up already) install Culerity as a Rails Plugin:
|
23
|
+
|
24
|
+
<pre><code> cd RAILS_ROOT
|
25
|
+
git clone git://github.com/langalex/culerity.git</code></pre>
|
26
|
+
|
27
|
+
or as a gem: (definitely preferred)
|
28
|
+
|
29
|
+
<pre><code> gem install langalex-culerity --source http://gems.github.com</code></pre>
|
30
|
+
|
31
|
+
Run the RSpec, Cucumber and Culerity generators:
|
32
|
+
|
33
|
+
<pre><code>
|
34
|
+
cd RAILS_ROOT
|
35
|
+
script/generate rspec
|
36
|
+
script/generate cucumber
|
37
|
+
script/generate culerity
|
38
|
+
</code></pre>
|
39
|
+
|
40
|
+
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
|
+
|
42
|
+
Culerity is a Ruby-side interface to celerity running on JRuby. To install it:
|
43
|
+
|
44
|
+
<pre><code> rake culerity:install</code></pre>
|
45
|
+
|
46
|
+
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
|
+
|
48
|
+
<pre><code> rake culerity:rails:start
|
49
|
+
cucumber features/my_feature.feature
|
50
|
+
</code></pre>
|
51
|
+
|
52
|
+
The Rails instance uses a special environment culerity_development.
|
53
|
+
|
54
|
+
When you have finished running culerity/cucumber you can turn off the Rails instance:
|
55
|
+
|
56
|
+
NOTE: The default port for this server is 3001. You can change this in features/step_definitions/common_celerity.rb
|
57
|
+
|
58
|
+
<pre><code> rake culerity:rails:stop</code></pre>
|
59
|
+
|
60
|
+
h2. How does it work
|
61
|
+
|
62
|
+
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
|
+
h2. Troubleshooting
|
65
|
+
|
66
|
+
I get a broken pipe error:
|
67
|
+
* make sure JRuby is installed and in your path: running _jruby -v_ should not produce an error
|
68
|
+
|
69
|
+
I get _Connection Refused_ errors
|
70
|
+
* make sure you have started a server in the test environment that runs on port 3001
|
71
|
+
|
72
|
+
My application can't find the data I create in my steps
|
73
|
+
* make sure you have disabled transactional fixtures in your env.rb
|
74
|
+
|
75
|
+
My database is not cleared automatically between scenarios
|
76
|
+
* 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
|
+
|
78
|
+
<pre><code>Before do
|
79
|
+
[User, .... all your models].each do |model|
|
80
|
+
mode.delete_all
|
81
|
+
end
|
82
|
+
end
|
83
|
+
</code></pre>
|
84
|
+
|
85
|
+
I want to test emails but the ActionMailer::Base.deliveries array is always empty.
|
86
|
+
* 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
|
+
|
88
|
+
|
89
|
+
h2. Links to Celerity documentation
|
90
|
+
|
91
|
+
* "How to select elements":http://celerity.rubyforge.org/yard/Celerity/Container.html
|
92
|
+
* "FAQ":http://wiki.github.com/jarib/celerity/faq
|
93
|
+
* "Tutorial":http://wiki.github.com/jarib/celerity/getting-started
|
94
|
+
* "API docs":http://celerity.rubyforge.org/yard/
|
95
|
+
|
96
|
+
h2. Links
|
97
|
+
|
98
|
+
* "cucumber":http://github.com/aslakhellesoy/cucumber/wikis
|
99
|
+
* "celerity":http://celerity.rubyforge.org
|
100
|
+
* "jruby":http://jruby.codehaus.org
|
101
|
+
* "rspec":http://rspec.info
|
102
|
+
* "htmlunit":http://htmlunit.sourceforge.net/
|
103
|
+
|
104
|
+
h2. Contact
|
105
|
+
|
106
|
+
Written 2009 by Alexander Lang, contact alex[at]upstream-berlin.com or http://github.com/langalex, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
# require 'rcov/rcovtask'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
8
|
+
require 'jeweler'
|
9
|
+
Jeweler::Tasks.new do |s|
|
10
|
+
s.name = "culerity"
|
11
|
+
s.summary = %Q{Culerity integrates Cucumber and Celerity in order to test your application's full stack.}
|
12
|
+
s.email = "alex@upstream-berlin.com"
|
13
|
+
s.homepage = "http://github.com/langalex/culerity"
|
14
|
+
s.description = "Culerity integrates Cucumber and Celerity in order to test your application's full stack."
|
15
|
+
s.authors = ["Alexander Lang"]
|
16
|
+
s.add_dependency 'cucumber'
|
17
|
+
s.add_dependency 'rspec'
|
18
|
+
end
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
21
|
+
end
|
22
|
+
|
23
|
+
Rake::TestTask.new do |t|
|
24
|
+
t.libs << 'lib'
|
25
|
+
t.pattern = 'spec/**/*_spec.rb'
|
26
|
+
t.verbose = false
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake::RDocTask.new do |rdoc|
|
30
|
+
rdoc.rdoc_dir = 'rdoc'
|
31
|
+
rdoc.title = 'Culerity'
|
32
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
33
|
+
rdoc.rdoc_files.include('README*')
|
34
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
35
|
+
end
|
36
|
+
|
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
|
data/VERSION.yml
ADDED
data/culerity.gemspec
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{culerity}
|
5
|
+
s.version = "0.2.3"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Alexander Lang"]
|
9
|
+
s.date = %q{2009-09-08}
|
10
|
+
s.description = %q{Culerity integrates Cucumber and Celerity in order to test your application's full stack.}
|
11
|
+
s.email = %q{alex@upstream-berlin.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"README.textile"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".gitignore",
|
17
|
+
"MIT-LICENSE",
|
18
|
+
"README.textile",
|
19
|
+
"Rakefile",
|
20
|
+
"VERSION.yml",
|
21
|
+
"culerity.gemspec",
|
22
|
+
"features/fixtures/sample_feature",
|
23
|
+
"features/installing_culerity.feature",
|
24
|
+
"features/running_cucumber_without_explicitly_running_external_services.feature",
|
25
|
+
"features/step_definitions/common_steps.rb",
|
26
|
+
"features/step_definitions/culerity_setup_steps.rb",
|
27
|
+
"features/step_definitions/jruby_steps.rb",
|
28
|
+
"features/step_definitions/rails_setup_steps.rb",
|
29
|
+
"features/support/common.rb",
|
30
|
+
"features/support/env.rb",
|
31
|
+
"features/support/matchers.rb",
|
32
|
+
"init.rb",
|
33
|
+
"lib/culerity.rb",
|
34
|
+
"lib/culerity/celerity_server.rb",
|
35
|
+
"lib/culerity/remote_browser_proxy.rb",
|
36
|
+
"lib/culerity/remote_object_proxy.rb",
|
37
|
+
"rails/init.rb",
|
38
|
+
"rails_generators/culerity/culerity_generator.rb",
|
39
|
+
"rails_generators/culerity/templates/config/environments/culerity_continuousintegration.rb",
|
40
|
+
"rails_generators/culerity/templates/config/environments/culerity_development.rb",
|
41
|
+
"rails_generators/culerity/templates/features/step_definitions/common_celerity_steps.rb",
|
42
|
+
"rails_generators/culerity/templates/lib/tasks/culerity.rake",
|
43
|
+
"script/console",
|
44
|
+
"script/destroy",
|
45
|
+
"script/generate",
|
46
|
+
"spec/celerity_server_spec.rb",
|
47
|
+
"spec/remote_browser_proxy_spec.rb",
|
48
|
+
"spec/remote_object_proxy_spec.rb",
|
49
|
+
"spec/spec_helper.rb"
|
50
|
+
]
|
51
|
+
s.homepage = %q{http://github.com/langalex/culerity}
|
52
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
53
|
+
s.require_paths = ["lib"]
|
54
|
+
s.rubygems_version = %q{1.3.5}
|
55
|
+
s.summary = %q{Culerity integrates Cucumber and Celerity in order to test your application's full stack.}
|
56
|
+
s.test_files = [
|
57
|
+
"spec/celerity_server_spec.rb",
|
58
|
+
"spec/remote_browser_proxy_spec.rb",
|
59
|
+
"spec/remote_object_proxy_spec.rb",
|
60
|
+
"spec/spec_helper.rb"
|
61
|
+
]
|
62
|
+
|
63
|
+
if s.respond_to? :specification_version then
|
64
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
65
|
+
s.specification_version = 3
|
66
|
+
|
67
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
68
|
+
s.add_runtime_dependency(%q<cucumber>, [">= 0"])
|
69
|
+
s.add_runtime_dependency(%q<rspec>, [">= 0"])
|
70
|
+
else
|
71
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
72
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
73
|
+
end
|
74
|
+
else
|
75
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
76
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: Check that default Rails index.html shows information
|
2
|
+
In order to value
|
3
|
+
As a role
|
4
|
+
I want feature
|
5
|
+
|
6
|
+
Scenario: Check javascript runs on static file
|
7
|
+
Given I go to the homepage
|
8
|
+
Then I should not see "Rails version"
|
9
|
+
When I follow "About your application’s environment"
|
10
|
+
And I wait for the AJAX call to finish
|
11
|
+
Then I should see "No route matches"
|
12
|
+
|
13
|
+
|
14
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
Feature: Installing culerity
|
2
|
+
In order to not have to use f@#$ing selenium and receive hate into our lives
|
3
|
+
As a self-respective Rails/JavaScript developer
|
4
|
+
I want to install culerity into my Rails app
|
5
|
+
|
6
|
+
Background:
|
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"
|
12
|
+
When I run executable "script/generate" with arguments "culerity"
|
13
|
+
And I setup load path to local code
|
14
|
+
|
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
|
+
Scenario: Install culerity and test the rails start + stop tasks
|
21
|
+
When I invoke task "rake culerity:rails:start"
|
22
|
+
Then file "tmp/culerity_rails_server.pid" is created
|
23
|
+
And I invoke task "rake culerity:rails:stop"
|
24
|
+
Then file "tmp/culerity_rails_server.pid" is not created
|
25
|
+
|
26
|
+
Scenario: Install culerity into a Rails app and check it works
|
27
|
+
Then file "features/step_definitions/common_celerity_steps.rb" is created
|
28
|
+
Then file "config/environments/culerity_development.rb" is created
|
29
|
+
Then file "config/environments/culerity_continuousintegration.rb" is created
|
30
|
+
|
31
|
+
And I run executable "cucumber" with arguments "features/"
|
32
|
+
Then I should see "0 scenarios"
|
33
|
+
And I should see "0 steps"
|
34
|
+
|
35
|
+
Given I invoke task "rake culerity:rails:start"
|
36
|
+
|
37
|
+
When I add a feature file to test Rails index.html default file
|
38
|
+
And I run executable "cucumber" with arguments "features/"
|
39
|
+
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
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Feature: Running cucumber without explicitly running external services
|
2
|
+
In order to reduce learning cost of using culerity
|
3
|
+
As a rails developer
|
4
|
+
I want the headless browser and rails processes to launch and shutdown automatically
|
5
|
+
|
6
|
+
Background:
|
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"
|
12
|
+
When I run executable "script/generate" with arguments "culerity"
|
13
|
+
And I setup load path to local code
|
14
|
+
|
15
|
+
Scenario: Successfully run scenarios without requiring celerity or rails processes running
|
16
|
+
When I add a feature file to test Rails index.html default file
|
17
|
+
And I run executable "cucumber" with arguments "features/"
|
18
|
+
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
|
+
|
@@ -0,0 +1,175 @@
|
|
1
|
+
Given /^this project is active project folder/ do
|
2
|
+
@active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^env variable \$([\w_]+) set to "(.*)"/ do |env_var, value|
|
6
|
+
ENV[env_var] = value
|
7
|
+
end
|
8
|
+
|
9
|
+
Given /I delete (folder|file) "([^\"]*)"/ do |type, folder|
|
10
|
+
in_project_folder { FileUtils.rm_rf folder }
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, arguments|
|
14
|
+
@stdout = StringIO.new
|
15
|
+
in_project_folder do
|
16
|
+
if Object.const_defined?("APP_ROOT")
|
17
|
+
APP_ROOT.replace(FileUtils.pwd)
|
18
|
+
else
|
19
|
+
APP_ROOT = FileUtils.pwd
|
20
|
+
end
|
21
|
+
run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
|
22
|
+
end
|
23
|
+
File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
|
24
|
+
@stdout.rewind
|
25
|
+
f << @stdout.read
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
30
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
31
|
+
in_project_folder do
|
32
|
+
system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
37
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
38
|
+
in_project_folder do
|
39
|
+
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
44
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
45
|
+
executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
|
46
|
+
in_project_folder do
|
47
|
+
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
When /^I invoke task "rake (.*)"/ do |task|
|
52
|
+
@stdout = File.expand_path(File.join(@tmp_root, "rake.out"))
|
53
|
+
@stderr = File.expand_path(File.join(@tmp_root, "rake.err"))
|
54
|
+
in_project_folder do
|
55
|
+
system "rake #{task} --trace > #{@stdout} 2> #{@stderr}"
|
56
|
+
end
|
57
|
+
File.read(@stderr).should_not =~ /rake aborted!/
|
58
|
+
end
|
59
|
+
|
60
|
+
Then /^folder "(.*)" (is|is not) created/ do |folder, is|
|
61
|
+
in_project_folder do
|
62
|
+
File.exists?(folder).should(is == 'is' ? be_true : be_false)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
Then /^file "(.*)" (is|is not) created/ do |file, is|
|
67
|
+
in_project_folder do
|
68
|
+
File.exists?(file).should(is == 'is' ? be_true : be_false)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
Then /^file with name matching "(.*)" is created/ do |pattern|
|
73
|
+
in_project_folder do
|
74
|
+
Dir[pattern].should_not be_empty
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
Then /^file "(.*)" contents (does|does not) match \/(.*)\// do |file, does, regex|
|
79
|
+
in_project_folder do
|
80
|
+
actual_output = File.read(file)
|
81
|
+
(does == 'does') ?
|
82
|
+
actual_output.should(match(/#{regex}/)) :
|
83
|
+
actual_output.should_not(match(/#{regex}/))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file, project_file|
|
88
|
+
File.exists?(gem_file).should be_true
|
89
|
+
File.exists?(project_file).should be_true
|
90
|
+
gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
|
91
|
+
project_file_contents = File.read(File.join(@active_project_folder, project_file))
|
92
|
+
project_file_contents.should == gem_file_contents
|
93
|
+
end
|
94
|
+
|
95
|
+
Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator|
|
96
|
+
actual_output = File.read(@stdout)
|
97
|
+
does_invoke == "does" ?
|
98
|
+
actual_output.should(match(/dependency\s+#{generator}/)) :
|
99
|
+
actual_output.should_not(match(/dependency\s+#{generator}/))
|
100
|
+
end
|
101
|
+
|
102
|
+
Then /help options "(.*)" and "(.*)" are displayed/ do |opt1, opt2|
|
103
|
+
actual_output = File.read(@stdout)
|
104
|
+
actual_output.should match(/#{opt1}/)
|
105
|
+
actual_output.should match(/#{opt2}/)
|
106
|
+
end
|
107
|
+
|
108
|
+
Then /^I should see "([^\"]*)"$/ do |text|
|
109
|
+
actual_output = File.read(@stdout)
|
110
|
+
actual_output.should contain(text)
|
111
|
+
end
|
112
|
+
|
113
|
+
Then /^I should not see "([^\"]*)"$/ do |text|
|
114
|
+
actual_output = File.read(@stdout)
|
115
|
+
actual_output.should_not contain(text)
|
116
|
+
end
|
117
|
+
|
118
|
+
Then /^I should see$/ do |text|
|
119
|
+
actual_output = File.read(@stdout)
|
120
|
+
actual_output.should contain(text)
|
121
|
+
end
|
122
|
+
|
123
|
+
Then /^I should not see$/ do |text|
|
124
|
+
actual_output = File.read(@stdout)
|
125
|
+
actual_output.should_not contain(text)
|
126
|
+
end
|
127
|
+
|
128
|
+
Then /^I should see exactly$/ do |text|
|
129
|
+
actual_output = File.read(@stdout)
|
130
|
+
actual_output.should == text
|
131
|
+
end
|
132
|
+
|
133
|
+
Then /^I should see all (\d+) tests pass/ do |expected_test_count|
|
134
|
+
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
|
135
|
+
actual_output = File.read(@stdout)
|
136
|
+
actual_output.should match(expected)
|
137
|
+
end
|
138
|
+
|
139
|
+
Then /^I should see all (\d+) examples pass/ do |expected_test_count|
|
140
|
+
expected = %r{^#{expected_test_count} examples?, 0 failures}
|
141
|
+
actual_output = File.read(@stdout)
|
142
|
+
actual_output.should match(expected)
|
143
|
+
end
|
144
|
+
|
145
|
+
Then /^yaml file "(.*)" contains (\{.*\})/ do |file, yaml|
|
146
|
+
in_project_folder do
|
147
|
+
yaml = eval yaml
|
148
|
+
YAML.load(File.read(file)).should == yaml
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
Then /^Rakefile can display tasks successfully/ do
|
153
|
+
@stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
|
154
|
+
in_project_folder do
|
155
|
+
system "rake -T > #{@stdout} 2> #{@stdout}"
|
156
|
+
end
|
157
|
+
actual_output = File.read(@stdout)
|
158
|
+
actual_output.should match(/^rake\s+\w+\s+#\s.*/)
|
159
|
+
end
|
160
|
+
|
161
|
+
Then /^task "rake (.*)" is executed successfully/ do |task|
|
162
|
+
@stdout.should_not be_nil
|
163
|
+
actual_output = File.read(@stdout)
|
164
|
+
actual_output.should_not match(/^Don't know how to build task '#{task}'/)
|
165
|
+
actual_output.should_not match(/Error/i)
|
166
|
+
end
|
167
|
+
|
168
|
+
Then /^gem spec key "(.*)" contains \/(.*)\// do |key, regex|
|
169
|
+
in_project_folder do
|
170
|
+
gem_file = Dir["pkg/*.gem"].first
|
171
|
+
gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
|
172
|
+
spec_value = gem_spec.send(key.to_sym)
|
173
|
+
spec_value.to_s.should match(/#{regex}/)
|
174
|
+
end
|
175
|
+
end
|