copycat 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +6 -0
  3. data/app/models/copycat_translation.rb +37 -45
  4. data/lib/copycat/version.rb +1 -1
  5. data/spec/dummy/config/application.rb +2 -0
  6. data/spec/dummy/config/initializers/copycat.rb +2 -2
  7. data/spec/dummy/db/development.sqlite3 +0 -0
  8. data/spec/dummy/db/migrate/{20120320194234_create_copycat_translations.copycat_engine.rb → 20150824125132_create_copycat_translations.copycat_engine.rb} +0 -0
  9. data/spec/dummy/db/schema.rb +1 -1
  10. data/spec/dummy/db/test.sqlite3 +0 -0
  11. data/spec/dummy/log/development.log +18 -2052
  12. data/spec/dummy/log/test.log +841 -27512
  13. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/5pjjE7UQ1zT-W3Rm7l8onDEWZV9b-lyRmeW9nFAbLoU.cache +2 -0
  14. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/9ZnyF5L7jalLFn0sk_WNwUCeeXBylJBp2yRgFPQE3ho.cache +1 -0
  15. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/IfC1KmXTw1ppvrXEYn3N4C2stMo3ing1GipxNQ0oML4.cache +0 -0
  16. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/YQfOnucF3bHs51e6OOpX6Gh8ih98sfqcSc88X90cxYg.cache +1 -0
  17. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/bUaVNTYJb9Cp-33TI2vIHrdmO8U0fOh3szyB6M4K7BY.cache +3 -0
  18. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/j2gYDVPsuXlIFLdHtvLu9pJtjz2Z1dmLFVDQp9jNEwc.cache +0 -0
  19. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/qGrLWZnG1ElHmKVImQl1l5olVVtVeDSZ13_9Ll1qeYU.cache +1 -0
  20. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/zQEVaz1UlfTQQY8e-XT2PRLny8dybtFJeuDtPTwwS2E.cache +1 -0
  21. data/spec/factories/copycat_translations.rb +3 -3
  22. data/spec/{integration → features}/copycat_spec.rb +78 -78
  23. data/spec/features/dummy_spec.rb +92 -0
  24. data/spec/lib/copycat_spec.rb +5 -5
  25. data/spec/models/copycat_translation_spec.rb +50 -69
  26. data/spec/spec_helper.rb +5 -2
  27. data/spec/support/export.yml +10 -0
  28. metadata +143 -47
  29. data/spec/dummy/tmp/cache/assets/C19/060/sprockets%2F125436f53217b7f564aa5016d1168709 +0 -0
  30. data/spec/dummy/tmp/cache/assets/CB3/6E0/sprockets%2F0f4c96b04436bf7ae900561753947d4c +0 -0
  31. data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  32. data/spec/dummy/tmp/cache/assets/D09/190/sprockets%2Fb2bddd007999a56d8b20c92301ea1983 +0 -0
  33. data/spec/dummy/tmp/cache/assets/D1A/DB0/sprockets%2F26d700197b8d25f954d56d8f31f2c8bc +0 -0
  34. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  35. data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  36. data/spec/dummy/tmp/cache/assets/DA4/EE0/sprockets%2Fcd39e3d56788faea331e0f5bac67329b +0 -0
  37. data/spec/dummy/tmp/cache/assets/DBD/220/sprockets%2F0cbff5c1a349439c1c444cbb4a57acc4 +0 -0
  38. data/spec/dummy/tmp/cache/assets/DDD/780/sprockets%2Fe7880b84c3ecb507fabc99b9ef6b70e3 +0 -0
  39. data/spec/dummy/tmp/cache/assets/DF8/310/sprockets%2Fccb12c4009c2f876d51dee8bae4c64ec +0 -0
  40. data/spec/integration/dummy_spec.rb +0 -92
@@ -0,0 +1,2 @@
1
+ [o:Set:
2
+ @hash{ I"environment-version:ETTI"environment-paths;TTI"0processors:type=text/css&file_type=text/css;TTI"cfile-digest:///Users/andrewross/code/copycat/spec/dummy/app/assets/stylesheets/application.css;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"Sfile-digest:///Users/andrewross/code/copycat/spec/dummy/app/assets/stylesheets;TT
@@ -0,0 +1 @@
1
+ I"�file:///Users/andrewross/code/copycat/spec/dummy/app/assets/stylesheets/application.css?type=text/css&id=44a81ee07e41d721880da38bef491b2aae63a506c3b4b40084eea75e9fc78e98:ET
@@ -0,0 +1 @@
1
+ I"�file:///Users/andrewross/code/copycat/spec/dummy/app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=4bfd9c65970fe06b4964470bbf20c1c68255b2420fa04d5b4a39a9999e0057c5:ET
@@ -0,0 +1,3 @@
1
+ [o:Set:
2
+ @hash{
3
+ I"environment-version:ETTI"environment-paths;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"cfile-digest:///Users/andrewross/code/copycat/spec/dummy/app/assets/stylesheets/application.css;TTI"Sfile-digest:///Users/andrewross/code/copycat/spec/dummy/app/assets/stylesheets;TT
@@ -0,0 +1 @@
1
+ "%9�#�U�-���Jnݶ�W��Gx5>T�u�\x��:�
@@ -0,0 +1 @@
1
+ "%��Rm�v�S3.��O�L���ڹc�ƕq�=_j�
@@ -2,10 +2,10 @@ FactoryGirl.define do
2
2
  sequence :string do |n|
3
3
  "string%09d" % n
4
4
  end
5
-
5
+
6
6
  factory :copycat_translation do
7
- key { FactoryGirl.generate(:string) }
8
- value { FactoryGirl.generate(:string) }
7
+ key { generate(:string) }
8
+ value { generate(:string) }
9
9
  locale I18n.default_locale
10
10
  end
11
11
  end
@@ -4,9 +4,9 @@ require 'spec_helper'
4
4
 
5
5
 
6
6
  feature "copycat index" do
7
-
7
+
8
8
  before do
9
- FactoryGirl.create(:copycat_translation, :key => "foo", :value => "bar")
9
+ create(:copycat_translation, :key => "foo", :value => "bar")
10
10
  page.driver.browser.basic_authorize Copycat.username, Copycat.password
11
11
  visit copycat_translations_path
12
12
  end
@@ -18,59 +18,59 @@ feature "copycat index" do
18
18
  end
19
19
 
20
20
  it "doesn't show any tokens by default" do
21
- page.should_not have_content 'foo'
22
- page.should_not have_content 'bar'
21
+ expect(page).not_to have_content 'foo'
22
+ expect(page).not_to have_content 'bar'
23
23
  end
24
24
 
25
25
  it "allows search by key" do
26
26
  fill_in 'search', :with => 'foo'
27
27
  click_button 'Search'
28
- page.should have_content 'foo'
29
- page.should have_content 'bar'
28
+ expect(page).to have_content 'foo'
29
+ expect(page).to have_content 'bar'
30
30
  end
31
31
 
32
32
  it "allows search by key" do
33
33
  fill_in 'search', :with => 'xfoo'
34
34
  click_button 'Search'
35
- page.should_not have_content 'foo'
36
- page.should_not have_content 'bar'
35
+ expect(page).not_to have_content 'foo'
36
+ expect(page).not_to have_content 'bar'
37
37
  end
38
38
 
39
39
  it "allows search by value" do
40
40
  fill_in 'search', :with => 'bar'
41
41
  click_button 'Search'
42
- page.should have_content 'foo'
43
- page.should have_content 'bar'
42
+ expect(page).to have_content 'foo'
43
+ expect(page).to have_content 'bar'
44
44
  end
45
45
 
46
46
  it "allows search by value" do
47
47
  fill_in 'search', :with => 'xbar'
48
48
  click_button 'Search'
49
- page.should_not have_content 'foo'
50
- page.should_not have_content 'bar'
49
+ expect(page).not_to have_content 'foo'
50
+ expect(page).not_to have_content 'bar'
51
51
  end
52
-
52
+
53
53
  it "searches in the middles of strings" do
54
- FactoryGirl.create(:copycat_translation, :key => "site.index.something")
54
+ create(:copycat_translation, :key => "site.index.something")
55
55
  fill_in 'search', :with => 'index'
56
56
  click_button 'Search'
57
- page.should have_content 'site.index.something'
57
+ expect(page).to have_content 'site.index.something'
58
58
  end
59
59
 
60
60
  it "can show all" do
61
- FactoryGirl.create(:copycat_translation, :key => "foe", :value => "beer")
61
+ create(:copycat_translation, :key => "foe", :value => "beer")
62
62
  click_button 'Search'
63
- page.should have_content 'foo'
64
- page.should have_content 'foe'
63
+ expect(page).to have_content 'foo'
64
+ expect(page).to have_content 'foe'
65
65
  end
66
66
 
67
67
  context "more than one locale" do
68
68
 
69
69
  before do
70
70
  CopycatTranslation.destroy_all
71
- FactoryGirl.create(:copycat_translation, key: "foo", value: "bar1", locale: "en")
72
- FactoryGirl.create(:copycat_translation, key: "foo", value: "bar2", locale: "fa")
73
- FactoryGirl.create(:copycat_translation, key: "foo", value: "bar3", locale: "it")
71
+ create(:copycat_translation, key: "foo", value: "bar1", locale: "en")
72
+ create(:copycat_translation, key: "foo", value: "bar2", locale: "fa")
73
+ create(:copycat_translation, key: "foo", value: "bar3", locale: "it")
74
74
  end
75
75
 
76
76
  #locale
@@ -95,100 +95,100 @@ feature "copycat index" do
95
95
 
96
96
  it "nil locale, nil search" do
97
97
  visit copycat_translations_path
98
- page.should_not have_content 'foo'
98
+ expect(page).not_to have_content 'foo'
99
99
  end
100
100
 
101
101
  it "nil locale, blank search" do
102
102
  # impossible for user to replicate this case
103
103
  visit copycat_translations_path('search' => '', 'commit' => 'Search')
104
- page.should have_content 'bar1'
105
- page.should_not have_content 'bar2'
106
- page.should_not have_content 'bar3'
104
+ expect(page).to have_content 'bar1'
105
+ expect(page).not_to have_content 'bar2'
106
+ expect(page).not_to have_content 'bar3'
107
107
  end
108
108
 
109
109
  it "nil locale, present search" do
110
110
  # impossible for user to replicate this case
111
111
  visit copycat_translations_path('search' => 'foo', 'commit' => 'Search')
112
- page.should have_content 'bar1'
113
- page.should_not have_content 'bar2'
114
- page.should_not have_content 'bar3'
112
+ expect(page).to have_content 'bar1'
113
+ expect(page).not_to have_content 'bar2'
114
+ expect(page).not_to have_content 'bar3'
115
115
  visit copycat_translations_path('search' => 'fuu', 'commit' => 'Search')
116
- page.should_not have_content 'foo'
116
+ expect(page).not_to have_content 'foo'
117
117
  end
118
118
 
119
119
  it "blank locale, nil search" do
120
120
  # impossible for user to replicate this case
121
121
  visit copycat_translations_path('locale' => '', 'commit' => 'Search')
122
- page.should_not have_content 'foo'
122
+ expect(page).not_to have_content 'foo'
123
123
  end
124
124
 
125
125
  it "blank locale, blank search" do
126
126
  select '', :from => 'locale'
127
127
  click_button 'Search'
128
- page.should have_content 'bar1'
129
- page.should have_content 'bar2'
130
- page.should have_content 'bar3'
128
+ expect(page).to have_content 'bar1'
129
+ expect(page).to have_content 'bar2'
130
+ expect(page).to have_content 'bar3'
131
131
  end
132
132
 
133
133
  it "blank locale, present search" do
134
134
  select '', :from => 'locale'
135
135
  fill_in 'search', :with => 'foo'
136
136
  click_button 'Search'
137
- page.should have_content 'bar1'
138
- page.should have_content 'bar2'
139
- page.should have_content 'bar3'
137
+ expect(page).to have_content 'bar1'
138
+ expect(page).to have_content 'bar2'
139
+ expect(page).to have_content 'bar3'
140
140
  fill_in 'search', :with => 'fuu'
141
141
  click_button 'Search'
142
- page.should_not have_content 'foo'
142
+ expect(page).not_to have_content 'foo'
143
143
  end
144
144
 
145
145
  it "present locale, nil search" do
146
146
  # impossible for user to replicate this case
147
147
  visit copycat_translations_path('locale' => 'en', 'commit' => 'Search')
148
- page.should_not have_content 'foo'
148
+ expect(page).not_to have_content 'foo'
149
149
  end
150
150
 
151
151
  it "present locale, blank search" do
152
152
  select 'en', :from => 'locale'
153
153
  click_button 'Search'
154
- page.should have_content 'bar1'
155
- page.should_not have_content 'bar2'
156
- page.should_not have_content 'bar3'
154
+ expect(page).to have_content 'bar1'
155
+ expect(page).not_to have_content 'bar2'
156
+ expect(page).not_to have_content 'bar3'
157
157
  select 'fa', :from => 'locale'
158
158
  click_button 'Search'
159
- page.should_not have_content 'bar1'
160
- page.should have_content 'bar2'
161
- page.should_not have_content 'bar3'
159
+ expect(page).not_to have_content 'bar1'
160
+ expect(page).to have_content 'bar2'
161
+ expect(page).not_to have_content 'bar3'
162
162
  select 'it', :from => 'locale'
163
163
  click_button 'Search'
164
- page.should_not have_content 'bar1'
165
- page.should_not have_content 'bar2'
166
- page.should have_content 'bar3'
164
+ expect(page).not_to have_content 'bar1'
165
+ expect(page).not_to have_content 'bar2'
166
+ expect(page).to have_content 'bar3'
167
167
  end
168
168
 
169
169
  it "present locale, present search" do
170
170
  select 'en', :from => 'locale'
171
171
  fill_in 'search', :with => 'foo'
172
172
  click_button 'Search'
173
- page.should have_content 'bar1'
174
- page.should_not have_content 'bar2'
175
- page.should_not have_content 'bar3'
173
+ expect(page).to have_content 'bar1'
174
+ expect(page).not_to have_content 'bar2'
175
+ expect(page).not_to have_content 'bar3'
176
176
  select 'fa', :from => 'locale'
177
177
  fill_in 'search', :with => 'foo'
178
178
  click_button 'Search'
179
- page.should_not have_content 'bar1'
180
- page.should have_content 'bar2'
181
- page.should_not have_content 'bar3'
179
+ expect(page).not_to have_content 'bar1'
180
+ expect(page).to have_content 'bar2'
181
+ expect(page).not_to have_content 'bar3'
182
182
  select 'it', :from => 'locale'
183
183
  fill_in 'search', :with => 'foo'
184
184
  click_button 'Search'
185
- page.should_not have_content 'bar1'
186
- page.should_not have_content 'bar2'
187
- page.should have_content 'bar3'
185
+ expect(page).not_to have_content 'bar1'
186
+ expect(page).not_to have_content 'bar2'
187
+ expect(page).to have_content 'bar3'
188
188
  select 'en', :from => 'locale'
189
189
  fill_in 'search', :with => 'fuu'
190
190
  click_button 'Search'
191
- page.should_not have_content 'foo'
191
+ expect(page).not_to have_content 'foo'
192
192
  end
193
193
 
194
194
  end
@@ -197,7 +197,7 @@ end
197
197
 
198
198
  feature "copycat edit" do
199
199
  before do
200
- FactoryGirl.create(:copycat_translation, :key => "foo", :value => "bar")
200
+ create(:copycat_translation, :key => "foo", :value => "bar")
201
201
  page.driver.browser.basic_authorize Copycat.username, Copycat.password
202
202
  visit copycat_translations_path
203
203
  end
@@ -212,7 +212,7 @@ end
212
212
 
213
213
  feature "copycat update, delete" do
214
214
  before do
215
- FactoryGirl.create(:copycat_translation, :key => "foo", :value => "bar")
215
+ create(:copycat_translation, :key => "foo", :value => "bar")
216
216
  page.driver.browser.basic_authorize Copycat.username, Copycat.password
217
217
  visit copycat_translations_path
218
218
  fill_in 'search', :with => 'foo'
@@ -223,16 +223,16 @@ feature "copycat update, delete" do
223
223
  scenario "update" do
224
224
  fill_in "copycat_translation[value]", :with => 'baz'
225
225
  click_button "Update"
226
- current_path.should == copycat_translations_path
227
- CopycatTranslation.find_by_key("foo").value.should == 'baz'
228
- page.should have_content "foo updated!"
226
+ expect(current_path).to eq(copycat_translations_path)
227
+ expect(CopycatTranslation.find_by_key("foo").value).to eq('baz')
228
+ expect(page).to have_content "foo updated!"
229
229
  end
230
230
 
231
231
  scenario "delete" do
232
232
  click_button "Delete this item"
233
- current_path.should == copycat_translations_path
234
- CopycatTranslation.find_by_key("foo").should be_nil
235
- page.should have_content "foo deleted!"
233
+ expect(current_path).to eq(copycat_translations_path)
234
+ expect(CopycatTranslation.find_by_key("foo")).to be_nil
235
+ expect(page).to have_content "foo deleted!"
236
236
  end
237
237
  end
238
238
 
@@ -242,11 +242,11 @@ feature "downloading and uploading yaml files" do
242
242
  end
243
243
 
244
244
  it "round-trips the YAML" do
245
- FactoryGirl.create(:copycat_translation, :key => "a.foo1", :value => "bar1")
246
- FactoryGirl.create(:copycat_translation, :key => "a.foo2:", :value => "bar2")
247
- FactoryGirl.create(:copycat_translation, :key => "a.b.foo3", :value => "bar3")
248
- FactoryGirl.create(:copycat_translation, :key => "c.foo4", :value => "bar4")
249
- FactoryGirl.create(:copycat_translation, :key => 2, :value => "bar5")
245
+ create(:copycat_translation, :key => "a.foo1", :value => "bar1")
246
+ create(:copycat_translation, :key => "a.foo2:", :value => "bar2")
247
+ create(:copycat_translation, :key => "a.b.foo3", :value => "bar3")
248
+ create(:copycat_translation, :key => "c.foo4", :value => "bar4")
249
+ create(:copycat_translation, :key => 2, :value => "bar5")
250
250
  assert CopycatTranslation.count == 5
251
251
 
252
252
  visit import_export_copycat_translations_path
@@ -254,7 +254,7 @@ feature "downloading and uploading yaml files" do
254
254
  CopycatTranslation.destroy_all
255
255
  assert CopycatTranslation.count == 0
256
256
 
257
- yaml = page.text
257
+ yaml = page.body
258
258
  file = Tempfile.new 'copycat'
259
259
  file.write yaml
260
260
  file.close
@@ -274,13 +274,13 @@ feature "downloading and uploading yaml files" do
274
274
 
275
275
  it "round-trips the yaml with complicated text" do
276
276
  value = "“hello world“ üokåa®fgsdf;::fs;kdf"
277
- FactoryGirl.create(:copycat_translation, :key => "a.foo", :value => value)
277
+ create(:copycat_translation, :key => "a.foo", :value => value)
278
278
 
279
279
  visit import_export_copycat_translations_path
280
280
  click_link 'Download as YAML'
281
281
  CopycatTranslation.destroy_all
282
282
 
283
- yaml = page.text
283
+ yaml = page.body
284
284
  file = Tempfile.new 'copycat'
285
285
  file.write yaml
286
286
  file.close
@@ -301,8 +301,8 @@ feature "downloading and uploading yaml files" do
301
301
  attach_file "file", file.path
302
302
  click_button "Upload"
303
303
  file.unlink
304
- page.status_code.should == 400
305
- page.should have_content("There was an error processing your upload!")
304
+ expect(page.status_code).to eq(400)
305
+ expect(page).to have_content("There was an error processing your upload!")
306
306
  assert CopycatTranslation.count == 0
307
307
  end
308
308
 
@@ -339,13 +339,13 @@ feature "locales" do
339
339
  end
340
340
 
341
341
  it "exports yaml containing multiple locales" do
342
- FactoryGirl.create(:copycat_translation, locale: 'en', key: 'hello', value: 'world')
343
- FactoryGirl.create(:copycat_translation, locale: 'es', key: 'hello', value: 'mundo')
342
+ create(:copycat_translation, locale: 'en', key: 'hello', value: 'world')
343
+ create(:copycat_translation, locale: 'es', key: 'hello', value: 'mundo')
344
344
 
345
345
  visit download_copycat_translations_path
346
346
  yaml = page.text
347
347
  assert yaml =~ /en:\s*hello: world/
348
- assert yaml =~ /es:\s*hello: mundo/
348
+ assert yaml =~ /es:\s*hello: mundo/
349
349
  end
350
350
 
351
351
  end
@@ -0,0 +1,92 @@
1
+ #encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ feature "use #t" do
6
+
7
+ it "the dummy app has a translation for site.index.header but not site.index.intro" do
8
+ expect(I18n.t('site.index.header')).to eq('The Header')
9
+ expect(I18n.t('site.index.intro')).to eq("translation missing: en.site.index.intro")
10
+ end
11
+
12
+ it "uses i18n.t" do
13
+ visit root_path
14
+ expect(page).to have_content 'The Header'
15
+ expect(page).to have_content 'Intro' #ActionView::Helpers::TranslationHelper#translate wrapper
16
+ end
17
+
18
+ it "creates a copycat_translation if the yaml has an entry" do
19
+ expect(CopycatTranslation.find_by_key('site.index.header')).to be_nil
20
+ visit root_path
21
+ expect(CopycatTranslation.find_by_key('site.index.header')).not_to be_nil
22
+ end
23
+
24
+ it "creates a copycat_translation if the yaml does not have an entry" do
25
+ expect(CopycatTranslation.find_by_key('site.index.intro')).to be_nil
26
+ visit root_path
27
+ expect(CopycatTranslation.find_by_key('site.index.intro')).not_to be_nil
28
+ end
29
+
30
+ it "shows the copycat_translation instead of the yaml" do
31
+ create(:copycat_translation, key: 'site.index.header', value: 'A different header')
32
+ visit root_path
33
+ expect(page).not_to have_content 'The Header'
34
+ expect(page).to have_content 'A different header'
35
+ end
36
+
37
+ end
38
+
39
+ feature "locales" do
40
+
41
+ it "displays different text based on users' locale" do
42
+ create(:copycat_translation, locale: 'en', key: 'site.index.intro', value: 'world')
43
+ create(:copycat_translation, locale: 'es', key: 'site.index.intro', value: 'mundo')
44
+
45
+ I18n.locale = :en
46
+ visit root_path
47
+ expect(page).to have_content 'world'
48
+ expect(page).not_to have_content 'mundo'
49
+
50
+ I18n.locale = :es
51
+ visit root_path
52
+ expect(page).to have_content 'mundo'
53
+ expect(page).not_to have_content 'world'
54
+
55
+ I18n.locale = :fa
56
+ visit root_path
57
+ expect(page).not_to have_content 'world'
58
+ expect(page).not_to have_content 'mundo'
59
+
60
+ I18n.locale = :en # reset
61
+ end
62
+
63
+ end
64
+
65
+ feature "yaml" do
66
+
67
+ it "round-trips both translations correctly (and doesn't export nils)" do
68
+ visit root_path
69
+ expect(CopycatTranslation.find_by_key('site.index.intro').value).to be_nil
70
+ expect(CopycatTranslation.find_by_key('site.index.header').value).to eq('The Header')
71
+ expect(CopycatTranslation.count).to eq(2)
72
+
73
+ page.driver.browser.basic_authorize Copycat.username, Copycat.password
74
+ visit import_export_copycat_translations_path
75
+ click_link 'Download as YAML'
76
+ CopycatTranslation.destroy_all
77
+ expect(CopycatTranslation.count).to eq(0)
78
+ yaml = page.body
79
+ file = Tempfile.new 'copycat'
80
+ file.write yaml
81
+ file.close
82
+ visit import_export_copycat_translations_path
83
+ attach_file "file", file.path
84
+ click_button "Upload"
85
+ file.unlink
86
+
87
+ expect(CopycatTranslation.count).to eq(1)
88
+ expect(CopycatTranslation.find_by_key('site.index.intro')).to be_nil
89
+ expect(CopycatTranslation.find_by_key('site.index.header').value).to eq('The Header')
90
+ end
91
+
92
+ end