Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

improved tests for mapping: issue #2

  • Loading branch information...
commit a4a52e6f267e08bddab21425f4f1682fdb63e8a2 1 parent c4aab22
Vijendra Rao vijendra authored

Showing 1 changed file with 35 additions and 0 deletions. Show diff stats Hide diff stats

  1. +35 0 spec/models/mapping_spec.rb
35 spec/models/mapping_spec.rb
... ... @@ -1,6 +1,41 @@
1 1 require 'spec_helper'
2 2
3 3 describe Mapping do
  4 + before :each do
  5 + @mapping = Factory(:mapping, :company_id => 'a company')
  6 + Factory(:mapping_element, mapping: @mapping)
  7 + Factory(:gender_mapping_element, mapping: @mapping)
  8 + Factory(:birthday_mapping_element, mapping: @mapping)
  9 + end
  10 +
4 11 it { should have_many(:mapping_elements).dependent(:destroy) }
5 12 it { should have_many(:attachments).dependent(:nullify) }
  13 +
  14 + describe ".by_company" do
  15 + it "includes mappings belongs to company" do
  16 + Mapping.by_company('a company').should include(@mapping)
  17 + end
  18 +
  19 + it "excludes mappings belongs to other company" do
  20 + another_mapping = Factory(:mapping, :company_id => 'another company')
  21 + Mapping.by_company('a company').should_not include(another_mapping)
  22 + end
  23 + end
  24 +
  25 + describe ".with_fields" do
  26 + it "includes mappings with more than one mapping element defined" do
  27 + Mapping.with_fields.should include(@mapping)
  28 + end
  29 +
  30 + it "excludes mappings belongs to other company" do
  31 + another_mapping = Factory(:mapping, :company_id => 'another company')
  32 + Mapping.with_fields.should_not include(another_mapping)
  33 + end
  34 + end
  35 +
  36 + describe '#title' do
  37 + it 'should return mapping details' do
  38 + @mapping.title.should == '3 fields: organization, gender, and birthday'
  39 + end
  40 + end
6 41 end

0 comments on commit a4a52e6

Please sign in to comment.
Something went wrong with that request. Please try again.