Sha256: e015282f693ff9e95dd70445b250e78563a9e32e8348703e8c1520e623deb308

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require "spec_helper"

describe Override do

  before(:each) do
    @example_model = ModelToOverride.create({:name => "Name", :description => "Description"})
    @valid_override_attributes = {
        :context_name => "website",
        :field_name => "name",
      :field_value => "New Name" }
  end

  it "should create an override given valid attributes" do
    @example_model.overrides.new(@valid_override_attributes)
    @example_model.should be_valid
  end

  it "should not create an override without a field name" do
    no_field_attributes = @valid_override_attributes.merge(:field_name => "")
    @example_model.overrides.new(no_field_attributes).should_not be_valid
  end

  it "should not create an override without a context name" do
    no_context_attributes = @valid_override_attributes.merge(:context_name => "")
    @example_model.overrides.new(no_context_attributes).should_not be_valid
  end

  it "should not create an override if the field name does not exist on the model" do
    no_field_attributes = @valid_override_attributes.merge(:field_name => "nonexistent_field")
    @example_model.overrides.new(no_field_attributes).should_not be_valid
  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
two_faced-0.0.2 spec/override_spec.rb
two_faced-0.0.2.alpha spec/override_spec.rb