module SpecStacker
Allows testing of multiple columns in a database for a single trait
Public Instance Methods
it_should(value, action)
click to toggle source
it should test value for action
value
-
symbol for a column name
action
-
symbol for an action (eg.
validate_presence_of
)
# File lib/rails_model_stacker/spec_stacker.rb, line 10 def it_should value, action it { should send(action, value) } end
should_all(attributes, action)
click to toggle source
test attributes with action
attributes
-
array of symbols of columns names
action
-
the action to check, see
it_should
# File lib/rails_model_stacker/spec_stacker.rb, line 18 def should_all attributes, action attributes.each { |k| it_should(k, action) } end
should_all_be_present(attributes)
click to toggle source
test if attributes are present
attributes
-
array of symbols of column names
# File lib/rails_model_stacker/spec_stacker.rb, line 25 def should_all_be_present attributes should_all attributes, :validate_presence_of end
should_all_belong_to(attributes)
click to toggle source
test if attributes belong_to
attribtes
-
array of symbols of attributes
# File lib/rails_model_stacker/spec_stacker.rb, line 41 def should_all_belong_to attributes should_all attributes, :belong_to end
should_all_have_many(attributes)
click to toggle source
test if model has_many attributes
attributes
-
array of symbols of attributes
# File lib/rails_model_stacker/spec_stacker.rb, line 48 def should_all_have_many attributes should_all attributes, :have_many end
should_all_join(attributes)
click to toggle source
test if all attributes have_and_belong_to_many
attributes
-
array of symbols of attributes
the normal identifier is too long.
# File lib/rails_model_stacker/spec_stacker.rb, line 34 def should_all_join attributes should_all attributes, :have_and_belong_to_many end
should_all_nest(attributes)
click to toggle source
test for nested attributes
attributes
-
array of symbols of attributes
# File lib/rails_model_stacker/spec_stacker.rb, line 55 def should_all_nest attributes should_all attributes, :accept_nested_attributes_for end