dr-merb_cucumber 0.6

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.
@@ -0,0 +1,4 @@
1
+ == 0.7 "?" ?
2
+
3
+ * Updated to the latest Merb structure and Jeweler
4
+ * Created Merb::Sequel::VERSION
@@ -0,0 +1,5 @@
1
+ scope 'merb-gen' do
2
+ generators_dir = File.join(File.dirname(__FILE__), 'lib', 'generators')
3
+ Merb.add_generators File.join(generators_dir, 'cucumber')
4
+ Merb.add_generators File.join(generators_dir, 'feature')
5
+ end
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.
@@ -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 config/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.
@@ -0,0 +1,50 @@
1
+ require "rubygems"
2
+ require "rake"
3
+
4
+ # Assume a typical dev checkout to fetch the current merb-core version
5
+ #require File.expand_path('../../merb/merb-core/lib/merb-core/version', __FILE__)
6
+
7
+ # Load this library's version information
8
+ require File.expand_path('../lib/merb_cucumber/version', __FILE__)
9
+
10
+ begin
11
+ require 'jeweler'
12
+
13
+ Jeweler::Tasks.new do |gemspec|
14
+ gemspec.version = Merb::Cucumber::VERSION
15
+ gemspec.name = "dr-merb_cucumber"
16
+ gemspec.description = "Cucumber integration for Merb"
17
+ gemspec.summary = "Cucumber integration for Merb"
18
+ gemspec.authors = [ "Roman Gonzalez", "David Leal", "Jacques Crocker" ]
19
+ gemspec.email = "merbjedi@gmail.com"
20
+ gemspec.homepage = "http://github.com/merb/merb_cucumber"
21
+ gemspec.files = %w(CHANGELOG LICENSE Rakefile README.textile TODO Generators) + Dir['{lib,spec}/**/*']
22
+ # Runtime dependencies
23
+ gemspec.add_dependency "merb-core", ">= 1.1.0.pre"
24
+ gemspec.add_dependency "cucumber", ">= 0.4.0"
25
+ gemspec.add_dependency "merb-gen", ">= 1.1.0.pre"
26
+ # Development dependencies
27
+ gemspec.add_development_dependency "rspec", ">= 1.2.9"
28
+ end
29
+
30
+ Jeweler::GemcutterTasks.new
31
+
32
+ rescue LoadError
33
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
34
+ end
35
+
36
+ require 'spec/rake/spectask'
37
+ Spec::Rake::SpecTask.new(:spec) do |spec|
38
+ spec.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
39
+ spec.libs << 'lib' << 'spec'
40
+ spec.spec_files = FileList['spec/**/*_spec.rb']
41
+ end
42
+
43
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
44
+ spec.libs << 'lib' << 'spec'
45
+ spec.pattern = 'spec/**/*_spec.rb'
46
+ spec.rcov = true
47
+ end
48
+
49
+ desc 'Default: run spec examples'
50
+ task :default => 'spec'
data/TODO ADDED
@@ -0,0 +1,3 @@
1
+ TODO:
2
+ Fix the problem when reading generated files on /tmp on the CucumberGenerator spec
3
+ Start the documentation
@@ -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 => :webrat, :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 = "config/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,8 @@
1
+ require File.join( File.dirname(__FILE__), 'merb_rspec' )
2
+ require "autotest/cucumber_mixin"
3
+ class Autotest::CucumberMerbRspec < Autotest::MerbRspec
4
+ include CucumberMixin
5
+ def cucumber
6
+ `which cucumber`.chomp
7
+ end
8
+ end
@@ -0,0 +1 @@
1
+ default: -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,3 @@
1
+ Given /^I am not authenticated$/ do
2
+ # yay!
3
+ end
@@ -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
+ require "merb-core"
5
+ require 'spec/expectations'
6
+ require "merb_cucumber/world/<%= session_type %>"
7
+ <% if orm == :datamapper -%>
8
+ require "merb_cucumber/helpers/datamapper"
9
+ <% elsif orm == :activerecord -%>
10
+ require "merb_cucumber/helpers/activerecord"
11
+ <% end -%>
12
+
13
+ # Recursively Load all steps defined within features/**/*_steps.rb
14
+ Dir["#{Merb.root}" / "features" / "**" / "*_steps.rb"].each { |f| require f }
15
+
16
+ # Uncomment if you want transactional fixtures
17
+ # Merb::Test::World::Base.use_transactional_fixtures
18
+
19
+ # Quick fix for post features running Rspec error, see
20
+ # http://gist.github.com/37930
21
+ def Spec.run? ; true; end
22
+
23
+ Merb.start_environment(:testing => true, :adapter => 'runner', :environment => ENV['MERB_ENV'] || 'test')
24
+
25
+ <% if orm == :datamapper -%>
26
+ DataMapper.auto_migrate!
27
+ <% end -%>
@@ -0,0 +1,38 @@
1
+ begin
2
+ require 'cucumber/rake/task'
3
+
4
+ # Use vendored cucumber binary if possible. If it's not vendored,
5
+ # Cucumber::Rake::Task will automatically use installed gem's cucumber binary
6
+ vendored_cucumber_binary = Merb.root / 'bin' / 'cucumber' if File.exist?(Merb.root / 'bin' / 'cucumber')
7
+
8
+ namespace :cucumber do
9
+ Cucumber::Rake::Task.new(:ok, 'Run features that should pass') do |t|
10
+ t.binary = vendored_cucumber_binary if vendored_cucumber_binary
11
+ t.fork = true # You may get faster startup if you set this to false
12
+ t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
13
+ end
14
+
15
+ Cucumber::Rake::Task.new(:wip, 'Run features that are being worked on') do |t|
16
+ t.binary = vendored_cucumber_binary if vendored_cucumber_binary
17
+ t.fork = true # You may get faster startup if you set this to false
18
+ t.cucumber_opts = "--color --tags @wip:2 --wip --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
19
+ end
20
+
21
+ desc 'Run all features'
22
+ task :all => [:ok, :wip]
23
+ end
24
+ desc 'Alias for cucumber:ok'
25
+ task :cucumber => 'cucumber:ok'
26
+
27
+ task :default => :cucumber
28
+
29
+ task :features => :cucumber do
30
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
31
+ end
32
+
33
+ rescue LoadError
34
+ desc 'cucumber rake task not available (cucumber not installed)'
35
+ task :cucumber do
36
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
37
+ end
38
+ 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,5 @@
1
+ module Merb
2
+ module Cucumber
3
+ VERSION = "0.6".freeze
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ module Merb
2
+ module Test
3
+ module World
4
+ module Base
5
+ include ::Merb::Test::Matchers
6
+ include ::Merb::Test::ControllerHelper
7
+ include ::Merb::Test::RouteHelper
8
+ include ::Merb::Test::ViewHelper
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ require File.join(File.dirname(__FILE__), 'base')
2
+
3
+ module Merb
4
+ module Test
5
+ module World
6
+ class Simple
7
+ include Base
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+ World do
14
+ Merb::Test::World::Simple.new
15
+ end
@@ -0,0 +1,18 @@
1
+ require File.join(File.dirname(__FILE__), 'base')
2
+ require 'webrat'
3
+ require 'cucumber/webrat/element_locator'
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 config/cucumber.yml file" do
11
+ @generator.should create('/tmp/config/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, :session_type => :simple})
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})
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
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+
3
+ # Use current merb-core sources if running from a typical dev checkout.
4
+ lib = File.expand_path('../../../merb/merb-core/lib', __FILE__)
5
+ $LOAD_PATH.unshift(lib) if File.directory?(lib)
6
+ require 'merb-core'
7
+ require 'merb-gen'
8
+
9
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
+
11
+ require 'templater/spec/helpers'
12
+
13
+ Merb.disable(:initfile)
14
+
15
+ Spec::Runner.configure do |config|
16
+ config.include Templater::Spec::Helpers
17
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dr-merb_cucumber
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.6"
5
+ platform: ruby
6
+ authors:
7
+ - Roman Gonzalez
8
+ - David Leal
9
+ - Jacques Crocker
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2009-12-12 00:00:00 -06:00
15
+ default_executable:
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: merb-core
19
+ type: :runtime
20
+ version_requirement:
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 1.1.0.pre
26
+ version:
27
+ - !ruby/object:Gem::Dependency
28
+ name: cucumber
29
+ type: :runtime
30
+ version_requirement:
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 0.4.0
36
+ version:
37
+ - !ruby/object:Gem::Dependency
38
+ name: merb-gen
39
+ type: :runtime
40
+ version_requirement:
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 1.1.0.pre
46
+ version:
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ type: :development
50
+ version_requirement:
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 1.2.9
56
+ version:
57
+ description: Cucumber integration for Merb
58
+ email: merbjedi@gmail.com
59
+ executables: []
60
+
61
+ extensions: []
62
+
63
+ extra_rdoc_files:
64
+ - LICENSE
65
+ - README.textile
66
+ - TODO
67
+ files:
68
+ - CHANGELOG
69
+ - Generators
70
+ - LICENSE
71
+ - README.textile
72
+ - Rakefile
73
+ - TODO
74
+ - lib/generators/cucumber.rb
75
+ - lib/generators/cucumber/templates/autotest/cucumber_merb_rspec.rb
76
+ - lib/generators/cucumber/templates/config/cucumber.yml
77
+ - lib/generators/cucumber/templates/features/authentication/login.feature
78
+ - lib/generators/cucumber/templates/features/authentication/steps/login_steps.rb
79
+ - lib/generators/cucumber/templates/features/steps/result_steps.rb
80
+ - lib/generators/cucumber/templates/features/steps/webrat_steps.rb
81
+ - lib/generators/cucumber/templates/features/support/env.rb
82
+ - lib/generators/cucumber/templates/lib/tasks/cucumber.rake
83
+ - lib/generators/feature.rb
84
+ - lib/generators/feature/templates/feature.rbt
85
+ - lib/generators/feature/templates/feature_steps.rb
86
+ - lib/merb_cucumber.rb
87
+ - lib/merb_cucumber/helpers/activerecord.rb
88
+ - lib/merb_cucumber/helpers/datamapper.rb
89
+ - lib/merb_cucumber/version.rb
90
+ - lib/merb_cucumber/world/base.rb
91
+ - lib/merb_cucumber/world/simple.rb
92
+ - lib/merb_cucumber/world/webrat.rb
93
+ - spec/cucumber_setup_generator_spec.rb
94
+ - spec/feature_generator_spec.rb
95
+ - spec/spec_helper.rb
96
+ has_rdoc: true
97
+ homepage: http://github.com/merb/merb_cucumber
98
+ licenses: []
99
+
100
+ post_install_message:
101
+ rdoc_options:
102
+ - --charset=UTF-8
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: "0"
110
+ version:
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: "0"
116
+ version:
117
+ requirements: []
118
+
119
+ rubyforge_project:
120
+ rubygems_version: 1.3.5
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: Cucumber integration for Merb
124
+ test_files:
125
+ - spec/cucumber_setup_generator_spec.rb
126
+ - spec/feature_generator_spec.rb
127
+ - spec/spec_helper.rb