merb_cucumber 0.5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Generators +5 -0
- data/LICENSE +20 -0
- data/README.textile +52 -0
- data/Rakefile +55 -0
- data/TODO +3 -0
- data/lib/generators/cucumber.rb +37 -0
- data/lib/generators/cucumber/templates/autotest/cucumber_merb_rspec.rb +8 -0
- data/lib/generators/cucumber/templates/cucumber.yml +1 -0
- data/lib/generators/cucumber/templates/features/authentication/login.feature +19 -0
- data/lib/generators/cucumber/templates/features/authentication/steps/login_steps.rb +3 -0
- data/lib/generators/cucumber/templates/features/steps/result_steps.rb +15 -0
- data/lib/generators/cucumber/templates/features/steps/webrat_steps.rb +38 -0
- data/lib/generators/cucumber/templates/features/support/env.rb +27 -0
- data/lib/generators/cucumber/templates/lib/tasks/cucumber.rake +33 -0
- data/lib/generators/feature.rb +37 -0
- data/lib/generators/feature/templates/feature.rbt +20 -0
- data/lib/generators/feature/templates/feature_steps.rb +23 -0
- data/lib/merb_cucumber.rb +0 -0
- data/lib/merb_cucumber/helpers/activerecord.rb +39 -0
- data/lib/merb_cucumber/helpers/datamapper.rb +36 -0
- data/lib/merb_cucumber/world/base.rb +12 -0
- data/lib/merb_cucumber/world/simple.rb +15 -0
- data/lib/merb_cucumber/world/webrat.rb +18 -0
- data/spec/cucumber_setup_generator_spec.rb +109 -0
- data/spec/feature_generator_spec.rb +62 -0
- data/spec/spec_helper.rb +15 -0
- metadata +104 -0
data/Generators
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 David Leal
|
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,52 @@
|
|
1
|
+
h1. merb_cucumber
|
2
|
+
|
3
|
+
Merb + Cucumber integration with Webrat support.
|
4
|
+
|
5
|
+
h2. Migrating to merb_cucumber 0.5.0
|
6
|
+
|
7
|
+
merb_cucumber 0.5.0 now requires a version greater than cucumber 0.1.13, which introduces some breaking changes. If you were already using merb_cucumber, you'll need to do the following:
|
8
|
+
|
9
|
+
* Change the last line of bin/cucumber to be:
|
10
|
+
|
11
|
+
Cucumber::CLI.execute ARGV
|
12
|
+
|
13
|
+
* Add a cucumber.yml to your Merb.root with the following contents:
|
14
|
+
|
15
|
+
default: --format pretty features
|
16
|
+
|
17
|
+
If you experience any problems, please contact me (roman) on github.
|
18
|
+
|
19
|
+
h2. Requirements
|
20
|
+
|
21
|
+
* merb-core >= 1.0.9
|
22
|
+
* cucumber >= 0.2.0
|
23
|
+
* webrat >= 0.4.3 (Optional)
|
24
|
+
|
25
|
+
h2. First Time
|
26
|
+
|
27
|
+
Include the gem in your dependencies. In your dependencies.rb file include:
|
28
|
+
|
29
|
+
dependency "roman-merb_cucumber", :require_as => nil
|
30
|
+
|
31
|
+
Inside your merb project root, run
|
32
|
+
|
33
|
+
$ merb-gen cucumber
|
34
|
+
|
35
|
+
For Webrat support, run
|
36
|
+
|
37
|
+
$ merb-gen cucumber --session-type webrat
|
38
|
+
|
39
|
+
This will also install a sample login feature that should pass if you're using merb-auth.
|
40
|
+
|
41
|
+
h2. Usage
|
42
|
+
|
43
|
+
To execute all the features run
|
44
|
+
|
45
|
+
$ rake features
|
46
|
+
|
47
|
+
h2. Notes
|
48
|
+
|
49
|
+
* If you are working with bundled Gems on your project, and having problems to make it through, check this "post":http://blog.romanandreg.com/post/87698159/merb-cucumber-as-a-bundled-gem-on-merb-projects
|
50
|
+
* When you are implementing the steps of an scenario, please use the new request test helper, if you try to use the
|
51
|
+
dispatch_to method, it won't work as expected.
|
52
|
+
* Webrat methods other than 'visits' are now singular only.
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
require 'merb-core'
|
5
|
+
require 'merb-core/tasks/merb'
|
6
|
+
|
7
|
+
GEM_NAME = "merb_cucumber"
|
8
|
+
GEM_VERSION = "0.5.1.2"
|
9
|
+
AUTHOR = ["Roman Gonzalez", "David Leal"]
|
10
|
+
EMAIL = ["romanandreg@gmail.com", "dgleal@gmail.com"]
|
11
|
+
HOMEPAGE = "http://github.com/david/merb_cucumber"
|
12
|
+
SUMMARY = "Cucumber integration for Merb"
|
13
|
+
|
14
|
+
spec = Gem::Specification.new do |s|
|
15
|
+
s.rubyforge_project = 'merb'
|
16
|
+
s.name = GEM_NAME
|
17
|
+
s.version = GEM_VERSION
|
18
|
+
s.platform = Gem::Platform::RUBY
|
19
|
+
s.has_rdoc = true
|
20
|
+
s.extra_rdoc_files = ["README.textile", "LICENSE", 'TODO']
|
21
|
+
s.summary = SUMMARY
|
22
|
+
s.description = s.summary
|
23
|
+
s.authors = AUTHOR
|
24
|
+
s.email = EMAIL
|
25
|
+
s.homepage = HOMEPAGE
|
26
|
+
s.add_dependency('merb-core', '~> 1.0')
|
27
|
+
s.add_dependency('cucumber', '>= 0.1.14')
|
28
|
+
s.require_path = 'lib'
|
29
|
+
s.files = %w(LICENSE README.textile Rakefile TODO Generators) + Dir.glob("{lib,spec}/**/*")
|
30
|
+
end
|
31
|
+
|
32
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
33
|
+
pkg.gem_spec = spec
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "install the plugin as a gem"
|
37
|
+
task :install do
|
38
|
+
Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Uninstall the gem"
|
42
|
+
task :uninstall do
|
43
|
+
Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Create a gemspec file"
|
47
|
+
task :gemspec do
|
48
|
+
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
49
|
+
file.puts spec.to_ruby
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
require 'spec/rake/spectask'
|
54
|
+
require 'spec/rake/spectask'
|
55
|
+
require 'merb-core/test/tasks/spectasks'
|
data/TODO
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Merb::Generators
|
2
|
+
|
3
|
+
class CucumberGenerator < Generator
|
4
|
+
|
5
|
+
desc <<-DESC
|
6
|
+
Generates setup code for cucumber feature framework
|
7
|
+
DESC
|
8
|
+
|
9
|
+
def self.source_root
|
10
|
+
File.join(File.dirname(__FILE__), 'cucumber', 'templates')
|
11
|
+
end
|
12
|
+
|
13
|
+
option :orm, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)'
|
14
|
+
option :session_type, :default => :simple, :desc => 'Session type to use (one of: simple, webrat)'
|
15
|
+
|
16
|
+
template(:env) { |t| t.source = t.destination = "features/support/env.rb" }
|
17
|
+
template(:rake) { |t| t.source = t.destination = "lib/tasks/cucumber.rake" }
|
18
|
+
template(:autotest) { |t| t.source = t.destination = "autotest/cucumber_merb_rspec.rb" }
|
19
|
+
template(:result_steps) { |t| t.source = t.destination = "features/steps/result_steps.rb" }
|
20
|
+
|
21
|
+
template(:example_feature, :session_type => :webrat) { |t| t.source = t.destination = "features/authentication/login.feature" }
|
22
|
+
template(:example_feature_steps, :session_type => :webrat) do |t|
|
23
|
+
t.source = t.destination = "features/authentication/steps/login_steps.rb"
|
24
|
+
end
|
25
|
+
template(:webrat_steps, :session_type => :webrat) do |t|
|
26
|
+
t.source = t.destination = "features/steps/webrat_steps.rb"
|
27
|
+
end
|
28
|
+
template(:cucumber_yml) { |t| t.source = t.destination = "cucumber.yml" }
|
29
|
+
|
30
|
+
def chmod(action)
|
31
|
+
File.chmod(0755, action.destination)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
add :cucumber, CucumberGenerator
|
37
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
default: -r features/steps -r features/support --format pretty features
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Login
|
2
|
+
To ensure the safety of the application
|
3
|
+
A regular user of the system
|
4
|
+
Must authenticate before using the app
|
5
|
+
|
6
|
+
Scenario Outline: Failed Login
|
7
|
+
Given I am not authenticated
|
8
|
+
When I go to /login
|
9
|
+
And I fill in "login" with "<mail>"
|
10
|
+
And I fill in "password" with "<password>"
|
11
|
+
And I press "Log In"
|
12
|
+
Then the login request should fail
|
13
|
+
Then I should see an error message
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
| mail | password |
|
17
|
+
| not_an_address | nil |
|
18
|
+
| not@not | 123455 |
|
19
|
+
| 123@abc.com | wrong_paasword |
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Then /^I should see "(.*)"$/ do |text|
|
2
|
+
webrat_session.response.body.to_s.should =~ /#{text}/m
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^I should not see "(.*)"$/ do |text|
|
6
|
+
webrat_session.response.body.to_s.should_not =~ /#{text}/m
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^I should see an? (\w+) message$/ do |message_type|
|
10
|
+
webrat_session.response.should have_xpath("//*[@class='#{message_type}']")
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^the (.*) ?request should fail/ do |_|
|
14
|
+
webrat_session.response.should_not be_successful
|
15
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Commonly used webrat steps
|
2
|
+
# http://github.com/brynary/webrat
|
3
|
+
|
4
|
+
When /^I go to (.*)$/ do |path|
|
5
|
+
visit path
|
6
|
+
end
|
7
|
+
|
8
|
+
When /^I press "(.*)"$/ do |button|
|
9
|
+
click_button(button)
|
10
|
+
end
|
11
|
+
|
12
|
+
When /^I follow "(.*)"$/ do |link|
|
13
|
+
click_link(link)
|
14
|
+
end
|
15
|
+
|
16
|
+
When /^I fill in "(.*)" with "(.*)"$/ do |field, value|
|
17
|
+
fill_in(field, :with => value)
|
18
|
+
end
|
19
|
+
|
20
|
+
When /^I select "(.*)" from "(.*)"$/ do |value, field|
|
21
|
+
select(value, :from => field)
|
22
|
+
end
|
23
|
+
|
24
|
+
When /^I check "(.*)"$/ do |field|
|
25
|
+
check(field)
|
26
|
+
end
|
27
|
+
|
28
|
+
When /^I uncheck "(.*)"$/ do |field|
|
29
|
+
uncheck(field)
|
30
|
+
end
|
31
|
+
|
32
|
+
When /^I choose "(.*)"$/ do |field|
|
33
|
+
choose(field)
|
34
|
+
end
|
35
|
+
|
36
|
+
When /^I attach the file at "(.*)" to "(.*)" $/ do |path, field|
|
37
|
+
attach_file(field, path)
|
38
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Sets up the Merb environment for Cucumber (thanks to krzys and roman)
|
2
|
+
require "rubygems"
|
3
|
+
|
4
|
+
# Add the local gems dir if found within the app root; any dependencies loaded
|
5
|
+
# hereafter will try to load from the local gems before loading system gems.
|
6
|
+
if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
|
7
|
+
$BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
|
8
|
+
end
|
9
|
+
|
10
|
+
require "merb-core"
|
11
|
+
require 'spec/expectations'
|
12
|
+
require "merb_cucumber/world/<%= session_type %>"
|
13
|
+
<% if orm == :datamapper -%>
|
14
|
+
require "merb_cucumber/helpers/datamapper"
|
15
|
+
<% elsif orm == :activerecord -%>
|
16
|
+
require "merb_cucumber/helpers/activerecord"
|
17
|
+
<% end -%>
|
18
|
+
|
19
|
+
# Uncomment if you want transactional fixtures
|
20
|
+
# Merb::Test::World::Base.use_transactional_fixtures
|
21
|
+
|
22
|
+
# Quick fix for post features running Rspec error, see
|
23
|
+
# http://gist.github.com/37930
|
24
|
+
def Spec.run? ; true; end
|
25
|
+
|
26
|
+
Merb.start_environment(:testing => true, :adapter => 'runner', :environment => ENV['MERB_ENV'] || 'test')
|
27
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'cucumber/rake/task'
|
2
|
+
|
3
|
+
cucumber_options = lambda do |t|
|
4
|
+
# if you want to pass some custom options to cucumber, pass them here
|
5
|
+
t.binary = Merb.root / 'bin' / 'cucumber' if File.exist?(Merb.root / 'bin' / 'cucumber')
|
6
|
+
# We need use fork cucumber since cucumber > 0.3.4
|
7
|
+
t.fork = true
|
8
|
+
|
9
|
+
# Add all requirement like before cucumber<0.3.4
|
10
|
+
t.cucumber_opts = ''
|
11
|
+
require_list = Array(FileList[File.join(File.dirname(__FILE__),"../../features/**/*.rb")])
|
12
|
+
require_list.each do |step_file|
|
13
|
+
t.cucumber_opts << '--require'
|
14
|
+
t.cucumber_opts << step_file
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Cucumber::Rake::Task.new(:features, &cucumber_options)
|
19
|
+
Cucumber::Rake::FeatureTask.new(:feature, &cucumber_options)
|
20
|
+
namespace :merb_cucumber do
|
21
|
+
task :test_env do
|
22
|
+
Merb.start_environment(:environment => "test", :adapter => 'runner')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
<% if orm == :datamapper %>
|
27
|
+
dependencies = ['merb_cucumber:test_env', 'db:automigrate']
|
28
|
+
task :features => dependencies
|
29
|
+
task :feature => dependencies
|
30
|
+
<% else %>
|
31
|
+
task :features => 'merb_cucumber:test_env'
|
32
|
+
task :feature => 'merb_cucumber:test_env'
|
33
|
+
<% end %>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Merb::Generators
|
2
|
+
class CucumberFeatureGenerator < NamedGenerator
|
3
|
+
|
4
|
+
desc <<-DESC
|
5
|
+
Generates cucumber feature files
|
6
|
+
DESC
|
7
|
+
|
8
|
+
def self.source_root
|
9
|
+
File.join(File.dirname(__FILE__), 'feature', 'templates')
|
10
|
+
end
|
11
|
+
|
12
|
+
def underscored_file_name(name)
|
13
|
+
name.gsub(/\s+/, "_")
|
14
|
+
end
|
15
|
+
|
16
|
+
first_argument :name, :required => true
|
17
|
+
|
18
|
+
option :goal, :desc => 'Goal used in the story: To [tighten the feedback loop, protect the revenue, ...]',
|
19
|
+
:as => :string, :default => "[accomplish some goal]"
|
20
|
+
option :role, :desc => 'Role used in the story: A [subscriber, account administrator, ...]',
|
21
|
+
:as => :string, :default => "[role]"
|
22
|
+
option :steps, :desc => "Also generate a steps file",
|
23
|
+
:as => :boolean, :default => false
|
24
|
+
|
25
|
+
template :feature do |t|
|
26
|
+
t.source = "feature.rbt"
|
27
|
+
t.destination = "features/#{underscored_file_name(name)}.feature"
|
28
|
+
end
|
29
|
+
|
30
|
+
file :steps, :steps => true do |t|
|
31
|
+
t.source = "feature_steps.rb"
|
32
|
+
t.destination = "features/steps/#{underscored_file_name(name)}_steps.rb"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
add :feature, CucumberFeatureGenerator
|
37
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Feature: <%= name.gsub("_", " ") %>
|
2
|
+
To <%= goal %>
|
3
|
+
A <%= role %>
|
4
|
+
Does [something]
|
5
|
+
|
6
|
+
Scenario: [first scenario]
|
7
|
+
Given [precondition]
|
8
|
+
And [another precondition]
|
9
|
+
When [event happens]
|
10
|
+
And [another event happens]
|
11
|
+
Then [outcome]
|
12
|
+
And [another outcome]
|
13
|
+
|
14
|
+
Scenario: [other scenario]
|
15
|
+
Given [precondition]
|
16
|
+
And [another precondition]
|
17
|
+
When [event happens]
|
18
|
+
And [another event happens]
|
19
|
+
Then [outcome]
|
20
|
+
And [another outcome]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Add your steps here
|
2
|
+
#
|
3
|
+
# A few examples:
|
4
|
+
#
|
5
|
+
# Given %r{^I was registered with ([^/\s]+)/(\S+)}i do |email, password|
|
6
|
+
# @current_person = Person.generate(:email => email, :password => password))
|
7
|
+
# end
|
8
|
+
#
|
9
|
+
# Given %r{^I am authenticated as ([^/\s]+)/(\S+)}i do |email, password|
|
10
|
+
# Given %{I was registered with #{email}/#{password}}
|
11
|
+
# Then %{I can log in as #{email}/#{password}}
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# Then %r{^I can log in as ([^/\s]+)/(\S+)}i do |email, password|
|
15
|
+
# When %{I try to log in as #{email}/#{password}}
|
16
|
+
# Then %{I should be redirected to /dashboard}
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# Then %r{^I can not log in as ([^/\s]+)/(\S+)}i do |email, password|
|
20
|
+
# When %{I try to log in as #{email}/#{password}}
|
21
|
+
# Then %{I should be redirected to /sessions}
|
22
|
+
# And %{I should see "Wrong e-mail or password!"}
|
23
|
+
# end
|
File without changes
|
@@ -0,0 +1,39 @@
|
|
1
|
+
$main = self # This must be included in the env.rb file!
|
2
|
+
|
3
|
+
module Merb
|
4
|
+
module Test
|
5
|
+
module Helpers
|
6
|
+
module ActiveRecord
|
7
|
+
module ClassMethods
|
8
|
+
def use_transactional_fixtures
|
9
|
+
# Let's set a transaction on the ActiveRecord connection when starting a new scenario
|
10
|
+
$main.Before do
|
11
|
+
if ::ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
|
12
|
+
::ActiveRecord::Base.connection.increment_open_transactions
|
13
|
+
else
|
14
|
+
::ActiveRecord::Base.send :increment_open_transactions
|
15
|
+
end
|
16
|
+
::ActiveRecord::Base.connection.begin_db_transaction
|
17
|
+
end
|
18
|
+
|
19
|
+
# Going with a rollback after every step in the scenario is executed
|
20
|
+
$main.After do
|
21
|
+
::ActiveRecord::Base.connection.rollback_db_transaction
|
22
|
+
if ::ActiveRecord::Base.connection.respond_to?(:decrement_open_transactions)
|
23
|
+
::ActiveRecord::Base.connection.decrement_open_transactions
|
24
|
+
else
|
25
|
+
::ActiveRecord::Base.send :decrement_open_transactions
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
module World
|
34
|
+
module Base
|
35
|
+
extend Helpers::ActiveRecord::ClassMethods
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
$main = self # This must be included in the env.rb file!
|
2
|
+
|
3
|
+
module Merb
|
4
|
+
module Test
|
5
|
+
module Helpers
|
6
|
+
module DataMapper
|
7
|
+
module ClassMethods
|
8
|
+
def use_transactional_fixtures
|
9
|
+
$main.Before do
|
10
|
+
repository(:default) do
|
11
|
+
transaction = ::DataMapper::Transaction.new(repository)
|
12
|
+
transaction.begin
|
13
|
+
repository.adapter.push_transaction(transaction)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
$main.After do
|
18
|
+
repository(:default) do
|
19
|
+
while repository.adapter.current_transaction
|
20
|
+
repository.adapter.current_transaction.rollback
|
21
|
+
repository.adapter.pop_transaction
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module World
|
31
|
+
module Base
|
32
|
+
extend Helpers::DataMapper::ClassMethods
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'base')
|
2
|
+
require 'webrat'
|
3
|
+
require 'webrat/adapters/merb'
|
4
|
+
|
5
|
+
module Merb
|
6
|
+
module Test
|
7
|
+
module World
|
8
|
+
class Webrat
|
9
|
+
include Base
|
10
|
+
include ::Webrat::Methods
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
World do
|
17
|
+
Merb::Test::World::Webrat.new
|
18
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'generators', 'cucumber')
|
3
|
+
|
4
|
+
describe "common files generator", :shared => true do
|
5
|
+
|
6
|
+
it "should generate the features/support/env.rb file" do
|
7
|
+
@generator.should create('/tmp/features/support/env.rb')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should generate the cucumber.yml file" do
|
11
|
+
@generator.should create('/tmp/cucumber.yml')
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should generate the autotest/cucumber_merb_rspec.rb file" do
|
15
|
+
@generator.should create('/tmp/autotest/cucumber_merb_rspec.rb')
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should generate the features/steps/result_steps.rb file" do
|
19
|
+
@generator.should create('/tmp/features/steps/result_steps.rb')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should generate the lib/tasks/cucumber.rake" do
|
23
|
+
@generator.should create('/tmp/lib/tasks/cucumber.rake')
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should render templates successfully" do
|
27
|
+
@generator.render!
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe Merb::Generators::CucumberGenerator do
|
34
|
+
|
35
|
+
describe "with datamapper as the orm" do
|
36
|
+
|
37
|
+
before(:each) do
|
38
|
+
@generator = Merb::Generators::CucumberGenerator.new('/tmp', {:orm => :datamapper })
|
39
|
+
end
|
40
|
+
|
41
|
+
it_should_behave_like "common files generator"
|
42
|
+
|
43
|
+
it "should have a requirement to the datamapper helper" do
|
44
|
+
@generator.render!
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "with activerecord as the orm" do
|
50
|
+
|
51
|
+
before(:each) do
|
52
|
+
@generator = Merb::Generators::CucumberGenerator.new('/tmp', {:orm => :activerecord})
|
53
|
+
end
|
54
|
+
|
55
|
+
it_should_behave_like "common files generator"
|
56
|
+
|
57
|
+
it "should have a requirement to the activerecord helper" do
|
58
|
+
@generator.render!
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "on simple session" do
|
64
|
+
|
65
|
+
before(:each) do
|
66
|
+
@generator = Merb::Generators::CucumberGenerator.new('/tmp', {:orm => :datamapper})
|
67
|
+
end
|
68
|
+
|
69
|
+
it_should_behave_like "common files generator"
|
70
|
+
|
71
|
+
it "should not generate the features/authentication/login.feature file" do
|
72
|
+
@generator.should_not create('/tmp/features/authentication/login.feature')
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should not generate the features/authentication/steps/login_steps.rb file" do
|
76
|
+
@generator.should_not create('/tmp/features/authentication/steps/login_steps.rb')
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should not generate the features/steps/webrat_steps.rb file" do
|
80
|
+
@generator.should_not create('/tmp/features/steps/webrat_steps.rb')
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should have a requirement to the simple session type on the env.rb file"
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "on webrat session" do
|
88
|
+
|
89
|
+
before(:each) do
|
90
|
+
@generator = Merb::Generators::CucumberGenerator.new('/tmp', {:orm => :datamapper, :session_type => :webrat})
|
91
|
+
end
|
92
|
+
|
93
|
+
it_should_behave_like "common files generator"
|
94
|
+
|
95
|
+
it "should generate the features/authentication/login.feature file" do
|
96
|
+
@generator.should create('/tmp/features/authentication/login.feature')
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should generate the features/authentication/steps/login_steps.rb file" do
|
100
|
+
@generator.should create('/tmp/features/authentication/steps/login_steps.rb')
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should generate the features/steps/webrat_steps.rb file" do
|
104
|
+
@generator.should create('/tmp/features/steps/webrat_steps.rb')
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should have a requirement to the webrat session type on the env.rb file"
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'generators', 'feature')
|
3
|
+
|
4
|
+
def underscored_file_name(name)
|
5
|
+
name.gsub(/\s+/, "_")
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
describe "feature generator", :shared => true do
|
10
|
+
it "generates features/NAME.feature" do
|
11
|
+
@generator.should create("/tmp/features/#{underscored_file_name(@name)}.feature")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "renders templates successfully" do
|
15
|
+
lambda { @generator.render! }.should_not raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
describe Merb::Generators::CucumberFeatureGenerator, "#render!" do
|
21
|
+
describe "with name includes spaces" do
|
22
|
+
before(:each) do
|
23
|
+
@name = "account termination"
|
24
|
+
@generator = Merb::Generators::CucumberFeatureGenerator.new('/tmp', {:steps => true}, @name)
|
25
|
+
end
|
26
|
+
|
27
|
+
it_should_behave_like "feature generator"
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "with name includes spaces and underscores" do
|
31
|
+
before(:each) do
|
32
|
+
@name = "how about some_snake_case"
|
33
|
+
@generator = Merb::Generators::CucumberFeatureGenerator.new('/tmp', {:steps => true}, @name)
|
34
|
+
end
|
35
|
+
|
36
|
+
it_should_behave_like "feature generator"
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "with --role='customer' given" do
|
40
|
+
before(:each) do
|
41
|
+
@name = "account termination"
|
42
|
+
@generator = Merb::Generators::CucumberFeatureGenerator.new('/tmp', {:role => "customer"}, @name)
|
43
|
+
end
|
44
|
+
|
45
|
+
it_should_behave_like "feature generator"
|
46
|
+
|
47
|
+
it "uses given role in the story text"
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "with --steps given" do
|
51
|
+
before(:each) do
|
52
|
+
@name = "signup"
|
53
|
+
@generator = Merb::Generators::CucumberFeatureGenerator.new('/tmp', {:steps => true}, @name)
|
54
|
+
end
|
55
|
+
|
56
|
+
it_should_behave_like "feature generator"
|
57
|
+
|
58
|
+
it "generates steps file" do
|
59
|
+
@generator.should create("/tmp/features/steps/#{underscored_file_name(@name)}_steps.rb")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
require 'merb-gen'
|
4
|
+
|
5
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
|
7
|
+
require 'templater/spec/helpers'
|
8
|
+
|
9
|
+
Merb.disable(:initfile)
|
10
|
+
|
11
|
+
Spec::Runner.configure do |config|
|
12
|
+
config.include Templater::Spec::Helpers
|
13
|
+
end
|
14
|
+
|
15
|
+
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: merb_cucumber
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Roman Gonzalez
|
8
|
+
- David Leal
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-11-02 00:00:00 -08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: merb-core
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "1.0"
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: cucumber
|
28
|
+
type: :runtime
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.1.14
|
35
|
+
version:
|
36
|
+
description: Cucumber integration for Merb
|
37
|
+
email:
|
38
|
+
- romanandreg@gmail.com
|
39
|
+
- dgleal@gmail.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files:
|
45
|
+
- README.textile
|
46
|
+
- LICENSE
|
47
|
+
- TODO
|
48
|
+
files:
|
49
|
+
- LICENSE
|
50
|
+
- README.textile
|
51
|
+
- Rakefile
|
52
|
+
- TODO
|
53
|
+
- Generators
|
54
|
+
- lib/generators/cucumber/templates/autotest/cucumber_merb_rspec.rb
|
55
|
+
- lib/generators/cucumber/templates/cucumber.yml
|
56
|
+
- lib/generators/cucumber/templates/features/authentication/login.feature
|
57
|
+
- lib/generators/cucumber/templates/features/authentication/steps/login_steps.rb
|
58
|
+
- lib/generators/cucumber/templates/features/steps/result_steps.rb
|
59
|
+
- lib/generators/cucumber/templates/features/steps/webrat_steps.rb
|
60
|
+
- lib/generators/cucumber/templates/features/support/env.rb
|
61
|
+
- lib/generators/cucumber/templates/lib/tasks/cucumber.rake
|
62
|
+
- lib/generators/cucumber.rb
|
63
|
+
- lib/generators/feature/templates/feature.rbt
|
64
|
+
- lib/generators/feature/templates/feature_steps.rb
|
65
|
+
- lib/generators/feature.rb
|
66
|
+
- lib/merb_cucumber/helpers/activerecord.rb
|
67
|
+
- lib/merb_cucumber/helpers/datamapper.rb
|
68
|
+
- lib/merb_cucumber/world/base.rb
|
69
|
+
- lib/merb_cucumber/world/simple.rb
|
70
|
+
- lib/merb_cucumber/world/webrat.rb
|
71
|
+
- lib/merb_cucumber.rb
|
72
|
+
- spec/cucumber_setup_generator_spec.rb
|
73
|
+
- spec/feature_generator_spec.rb
|
74
|
+
- spec/spec_helper.rb
|
75
|
+
has_rdoc: true
|
76
|
+
homepage: http://github.com/david/merb_cucumber
|
77
|
+
licenses: []
|
78
|
+
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
version:
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
95
|
+
version:
|
96
|
+
requirements: []
|
97
|
+
|
98
|
+
rubyforge_project: merb
|
99
|
+
rubygems_version: 1.3.5
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: Cucumber integration for Merb
|
103
|
+
test_files: []
|
104
|
+
|