Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

164 lines (130 sloc) 6.396 kb
# encoding : utf-8
# this file generated by script/generate pickle
# create a model
Given(/^#{capture_model} exists?(?: with #{capture_fields})?$/) do |name, fields|
create_model(name, fields)
end
Given(/^(?:|que )(?:|um |uma )#{capture_model} existe?(?: com #{capture_fields})?$/) do |name, fields|
create_model(name, fields)
end
# create n models
Given(/^(\d+) #{capture_plural_factory} exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
count.to_i.times { create_model(plural_factory.singularize, fields) }
end
Given(/^(?:|que )(\d+) #{capture_plural_factory} existe(?:|m)(?: com #{capture_fields})?$/) do |count, plural_factory, fields|
count.to_i.times { create_model(plural_factory.singularize, fields) }
end
# create models from a table
Given(/^the following #{capture_plural_factory} exists?:?$/) do |plural_factory, table|
name = plural_factory.singularize
table.hashes.each { |hash| create_model(name, hash) }
end
Given(/^(os|as) seguintes #{capture_plural_factory} existem?:?$/) do |plural_factory, table|
name = plural_factory.singularize
table.hashes.each { |hash| create_model(name, hash) }
end
# find a model
Then(/^#{capture_model} should exist(?: with #{capture_fields})?$/) do |name, fields|
find_model!(name, fields)
end
Then(/^(?:|o |a |um |uma )#{capture_model} deve existir(?: com #{capture_fields})?$/) do |name, fields|
find_model!(name, fields)
end
# not find a model
Then(/^#{capture_model} should not exist(?: with #{capture_fields})?$/) do |name, fields|
find_model(name, fields).should be_nil
end
Then(/^(?:|o | a)#{capture_model} não deve existir(?: com #{capture_fields})?$/) do |name, fields|
find_model(name, fields).should be_nil
end
# find models with a table
Then(/^the following #{capture_plural_factory} should exists?:?$/) do |plural_factory, table|
name = plural_factory.singularize
table.hashes.each { |hash| find_model!(name, hash)}
end
Then(/^(os|as) seguintes #{capture_plural_factory} devem existir?:?$/) do |plural_factory, table|
name = plural_factory.singularize
table.hashes.each { |hash| find_model!(name, hash)}
end
# find exactly n models
Then(/^(\d+) #{capture_plural_factory} should exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
find_models(plural_factory.singularize, fields).size.should == count.to_i
end
Then(/^(\d+) #{capture_plural_factory} devem existir(?: com #{capture_fields})?$/) do |count, plural_factory, fields|
find_models(plural_factory.singularize, fields).size.should == count.to_i
end
# assert equality of models
Then(/^#{capture_model} should be #{capture_model}$/) do |a, b|
model!(a).should == model!(b)
end
Then(/^(?:|a |o )#{capture_model} deve ser igual (a|ao|o) #{capture_model}$/) do |a, b|
model!(a).should == model!(b)
end
# assert model is in another model's has_many assoc
Then(/^#{capture_model} should be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
model!(owner).send(association).should include(model!(target))
end
Then(/^(?:|o |a )#{capture_model} deve (?:|estar |ser )(?:em|um dos|uma das|entre|pertencer a) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
model!(owner).send(association).should include(model!(target))
end
# assert model is not in another model's has_many assoc
Then(/^#{capture_model} should not be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
model!(owner).send(association).should_not include(model!(target))
end
Then(/^(?:|o |a )#{capture_model} não deve (?:|estar |ser )(?:em|um dos|uma das|entre|pertencer a) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
model!(owner).send(association).should_not include(model!(target))
end
# assert model is another model's has_one/belongs_to assoc
Then(/^#{capture_model} should be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
model!(owner).send(association).should == model!(target)
end
Then(/^#{capture_model} deve (ter|pertencer) (um |uma |a um |a uma )#{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
model!(owner).send(association).should == model!(target)
end
# assert model is not another model's has_one/belongs_to assoc
Then(/^#{capture_model} should not be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
model!(owner).send(association).should_not == model!(target)
end
Then(/^#{capture_model} não deve (ter|pertencer) (um |uma |a um |a uma )#{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
model!(owner).send(association).should_not == model!(target)
end
# assert model.predicate?
Then(/^#{capture_model} should (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
model!(name).should send("be_#{predicate.gsub(' ', '_')}")
end
Then(/^#{capture_model} deve (?:ser|ter) (?:|um |uma | )?#{capture_predicate}$/) do |name, predicate|
model!(name).should send("be_#{predicate.gsub(' ', '_')}")
end
# assert not model.predicate?
Then(/^#{capture_model} should not (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
end
Then(/^#{capture_model} não deve (?:ser|ter) (?:|um |uma | )?#{capture_predicate}$/) do |name, predicate|
model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
end
# model.attribute.should eql(value)
# model.attribute.should_not eql(value)
Then(/^#{capture_model}'s (\w+) (should(?: not)?) be #{capture_value}$/) do |name, attribute, expectation, expected|
actual_value = model(name).send(attribute)
expectation = expectation.gsub(' ', '_')
case expected
when 'nil', 'true', 'false'
actual_value.send(expectation, send("be_#{expected}"))
when /^-?[0-9_]+$/
actual_value.send(expectation, eql(expected.to_i))
else
actual_value.to_s.send(expectation, eql(expected))
end
end
Then(/^(?:|o |a )(\w+) (do|da|de) #{capture_model} (?:não )deve ser #{capture_value}$/) do |attribute, name, expectation, expected|
actual_value = model(name).send(attribute)
expectation = expectation.gsub(' ', '_')
case expected
when 'nil', 'true', 'false'
actual_value.send(expectation, send("be_#{expected}"))
when /^-?[0-9_]+$/
actual_value.send(expectation, eql(expected.to_i))
else
actual_value.to_s.send(expectation, eql(expected))
end
end
Jump to Line
Something went wrong with that request. Please try again.