forked from aiwilliams/dataset
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Dataset | ||
module Extensions # :nodoc: | ||
|
||
module CucumberWorld # :nodoc: | ||
def dataset(*datasets, &block) | ||
add_dataset(*datasets, &block) | ||
|
||
load = nil | ||
$__cucumber_toplevel.Before do | ||
load = dataset_session.load_datasets_for(self.class) | ||
extend_from_dataset_load(load) | ||
end | ||
# Makes sure the datasets are reloaded after each scenario | ||
Cucumber::Rails.use_transactional_fixtures | ||
end | ||
end | ||
|
||
end | ||
end | ||
Cucumber::Rails::World.extend Dataset::Extensions::CucumberWorld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
|
||
$:.unshift(File.dirname(__FILE__) + '/../stubs') | ||
require "mini_rails" | ||
|
||
require 'cucumber/rails/world' | ||
require 'cucumber/rails/rspec' | ||
Cucumber::Rails::World.class_eval do | ||
include Dataset | ||
end | ||
|
||
describe Cucumber::Rails::World do | ||
|
||
it 'should have a dataset method' do | ||
world = Class.new(Cucumber::Rails::World) | ||
world.should respond_to(:dataset) | ||
end | ||
|
||
it 'should load the dataset when the feature is run' do | ||
load_count = 0 | ||
my_dataset = Class.new(Dataset::Base) do | ||
define_method(:load) do | ||
load_count += 1 | ||
end | ||
end | ||
|
||
step_mother = Object.new | ||
step_mother.extend(Cucumber::StepMother) | ||
$__cucumber_toplevel = step_mother | ||
step_mother.World do |world| | ||
world = Cucumber::Rails::World.new | ||
world.class.dataset(my_dataset) | ||
world | ||
end | ||
step_mother.Given /true is true/ do |n| | ||
true.should == true | ||
end | ||
visitor = Cucumber::Ast::Visitor.new(step_mother) | ||
|
||
scenario = Cucumber::Ast::Scenario.new( | ||
background=nil, | ||
comment=Cucumber::Ast::Comment.new(""), | ||
tags=Cucumber::Ast::Tags.new(98, []), | ||
line=99, | ||
keyword="", | ||
name="", | ||
steps=[ | ||
Cucumber::Ast::Step.new(8, "Given", "true is true") | ||
]) | ||
visitor.visit_feature_element(scenario) | ||
|
||
load_count.should be(1) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Define some stubs to fake Rails... | ||
module ActiveRecord | ||
class Base | ||
end | ||
end | ||
|
||
module ActionController | ||
class Dispatcher | ||
end | ||
|
||
class Base | ||
end | ||
|
||
class IntegrationTest | ||
def self.use_transactional_fixtures=(x) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# This file is loaded by rails/world.rb |