Sha256: 2a92a47d5d270b74f0e9115f6cf5af23f0298d5b3f479e2da3bfca3b8c70248d

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

#Scenario: Create a simple fixture, push it and rollback
#  Given a collection visitors
#  And a collection aliens
#  And a collection visits
#  And a file "test/fixtures/simple/visitors.yaml" with:
#    """
#    anonymous:
#      name: V
#      email: v@for.vendetta
#    """
#  And a file "test/fixtures/simple/aliens.yaml" with:
#    """
#    yourfavouritemartian:
#      race: Zerg
#    """
#  And a file "test/fixtures/simple/visits.yaml" with:
#    """
#    v2yfm:
#      alien_id: 1
#      visitor_id: 1
#    """
#  When I load the simple fixture
#  Then I should see 1 record in visitors with name "V" and email "v@for.vendetta"
#  And I should see 1 record in aliens with race "Zerg"
#  And I should see 1 record in visits with alien_id 1 and visitor_id 1
#  When I rollback
#  Then I should see 0 records in visitors
#  And I should see 0 records in aliens
#  And I should see 0 records in visits

Given /^a collection (\w+)$/ do |collection|
  @DB[collection]
end

And /^a file "(.+?)" with:$/ do |file, content|
  Fast.file.write file, content
end

When /^I load the (\w+) fixture$/ do |fixture|
  #binding.pry
  @fixture = Mongo::Fixture.new fixture.to_sym, @DB
end

Then /^I should see (\d+) record in (\w+) with (\w+) "([^"]+)" and (\w+) "(.+?)"$/ do 
  |amount, collection, field1, data1, field2, data2|
  
  @DB[collection].find( field1 => data1, field2 => data2 ).count.should == amount.to_i
end

And /^I should see (\d+) record in (\w+) with (\w+) "([^"]+)"$/ do 
  |amount, collection, field, data|
  
  @DB[collection].find( field => data ).count.should == amount.to_i
end

Then /^I should see (\d+) record in (\w+) with (\w+) (\d+) and (\w+) (\d+)$/ do 
  |amount, collection, field1, data1, field2, data2|
  
  @DB[collection].find( field1 => data1.to_i, field2 => data2.to_i ).count.should == amount.to_i
end

When /^I rollback$/ do
  @fixture.rollback
end

Then /^I should see (\d+) records in (\w+)$/ do |amount, collection|
  @DB[collection].count.should == amount.to_i
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo-fixture-0.0.4 features/stepdefs/play_around_with_fixtures/create_a_simple_fixture_push_it_and_rollback.rb