@@ -1861,50 +1861,59 @@ class Foo < ActiveRecord::Base
1861
1861
end
1862
1862
end
1863
1863
1864
- describe '#resolve_filename' do
1865
- it 'should return the test path for a model' do
1866
- filename_template = 'test/unit/%MODEL_NAME%_test.rb'
1867
- model_name = 'example_model'
1868
- table_name = 'example_models'
1869
-
1870
- filename = AnnotateModels . resolve_filename ( filename_template , model_name , table_name )
1871
- expect ( filename ) . to eq 'test/unit/example_model_test.rb'
1864
+ describe '.resolve_filename' do
1865
+ subject do
1866
+ AnnotateModels . resolve_filename ( filename_template , model_name , table_name )
1872
1867
end
1873
1868
1874
- it 'should return the additional glob' do
1875
- filename_template = '/foo/bar/%MODEL_NAME%/testing.rb'
1876
- model_name = 'example_model'
1877
- table_name = 'example_models'
1869
+ context 'When model_name is "example_model" and table_name is "example_models"' do
1870
+ let ( :model_name ) { 'example_model' }
1871
+ let ( :table_name ) { 'example_models' }
1878
1872
1879
- filename = AnnotateModels . resolve_filename ( filename_template , model_name , table_name )
1880
- expect ( filename ) . to eq '/foo/bar/example_model/testing.rb'
1881
- end
1873
+ context "when filename_template is 'test/unit/%MODEL_NAME%_test.rb'" do
1874
+ let ( :filename_template ) { 'test/unit/%MODEL_NAME%_test.rb' }
1882
1875
1883
- it 'should return the additional glob ' do
1884
- filename_template = '/foo/bar/%PLURALIZED_MODEL_NAME%/testing .rb'
1885
- model_name = 'example_model'
1886
- table_name = 'example_models'
1876
+ it 'returns the test path for a model ' do
1877
+ is_expected . to eq 'test/unit/example_model_test .rb'
1878
+ end
1879
+ end
1887
1880
1888
- filename = AnnotateModels . resolve_filename ( filename_template , model_name , table_name )
1889
- expect ( filename ) . to eq '/foo/bar/example_models/testing.rb'
1890
- end
1881
+ context "when filename_template is '/foo/bar/%MODEL_NAME%/testing.rb'" do
1882
+ let ( :filename_template ) { '/foo/bar/%MODEL_NAME%/testing.rb' }
1883
+
1884
+ it 'returns the additional glob' do
1885
+ is_expected . to eq '/foo/bar/example_model/testing.rb'
1886
+ end
1887
+ end
1891
1888
1892
- it 'should return the fixture path for a model' do
1893
- filename_template = 'test/fixtures/%TABLE_NAME%.yml'
1894
- model_name = 'example_model'
1895
- table_name = 'example_models'
1889
+ context "when filename_template is '/foo/bar/%PLURALIZED_MODEL_NAME%/testing.rb'" do
1890
+ let ( :filename_template ) { '/foo/bar/%PLURALIZED_MODEL_NAME%/testing.rb' }
1896
1891
1897
- filename = AnnotateModels . resolve_filename ( filename_template , model_name , table_name )
1898
- expect ( filename ) . to eq 'test/fixtures/example_models.yml'
1892
+ it 'returns the additional glob' do
1893
+ is_expected . to eq '/foo/bar/example_models/testing.rb'
1894
+ end
1895
+ end
1896
+
1897
+ context "when filename_template is 'test/fixtures/%TABLE_NAME%.yml'" do
1898
+ let ( :filename_template ) { 'test/fixtures/%TABLE_NAME%.yml' }
1899
+
1900
+ it 'returns the fixture path for a model' do
1901
+ is_expected . to eq 'test/fixtures/example_models.yml'
1902
+ end
1903
+ end
1899
1904
end
1900
1905
1901
- it 'should return the fixture path for a nested model' do
1902
- filename_template = 'test/fixtures/%PLURALIZED_MODEL_NAME%.yml'
1903
- model_name = 'parent/child'
1904
- table_name = 'parent_children'
1906
+ context 'When model_name is "parent/child" and table_name is "parent_children"' do
1907
+ let ( :model_name ) { 'parent/child' }
1908
+ let ( :table_name ) { 'parent_children' }
1909
+
1910
+ context "when filename_template is 'test/fixtures/%PLURALIZED_MODEL_NAME%.yml'" do
1911
+ let ( :filename_template ) { 'test/fixtures/%PLURALIZED_MODEL_NAME%.yml' }
1905
1912
1906
- filename = AnnotateModels . resolve_filename ( filename_template , model_name , table_name )
1907
- expect ( filename ) . to eq 'test/fixtures/parent/children.yml'
1913
+ it 'returns the fixture path for a nested model' do
1914
+ is_expected . to eq 'test/fixtures/parent/children.yml'
1915
+ end
1916
+ end
1908
1917
end
1909
1918
end
1910
1919
0 commit comments