openehr-rails 0.0.2 → 0.1.0

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +13 -0
  3. data/Rakefile +1 -16
  4. data/lib/generators/openehr/assets/assets_generator.rb +28 -0
  5. data/lib/generators/openehr/assets/templates/javascript.js +1 -0
  6. data/lib/generators/openehr/assets/templates/stylesheet.css.scss +3 -0
  7. data/lib/generators/openehr/controller/controller_generator.rb +10 -9
  8. data/lib/generators/openehr/controller/templates/controller.rb +71 -10
  9. data/lib/generators/openehr/helper/helper_generator.rb +17 -0
  10. data/lib/generators/openehr/helper/templates/helper.rb +2 -0
  11. data/lib/generators/openehr/i18n/i18n_generator.rb +29 -33
  12. data/lib/generators/openehr/i18n/templates/i18n.rb +3 -3
  13. data/lib/generators/openehr/i18n/templates/language.yml +8 -3
  14. data/lib/generators/openehr/install/install_generator.rb +6 -9
  15. data/lib/generators/openehr/migration/migration_generator.rb +24 -9
  16. data/lib/generators/openehr/migration/templates/archetypes.rb +10 -0
  17. data/lib/generators/openehr/migration/templates/rms.rb +16 -0
  18. data/lib/generators/openehr/model/model_generator.rb +108 -7
  19. data/lib/generators/openehr/model/templates/activemodel.rb +71 -0
  20. data/lib/generators/openehr/model/templates/archetype.rb +3 -0
  21. data/lib/generators/openehr/model/templates/rm.rb +3 -0
  22. data/lib/generators/openehr/scaffold/scaffold_generator.rb +182 -109
  23. data/lib/generators/openehr/scaffold/templates/_form.html.erb +1 -1
  24. data/lib/generators/openehr/scaffold/templates/application.html.erb +14 -0
  25. data/lib/generators/openehr/scaffold/templates/application_controller.rb +1 -0
  26. data/lib/generators/openehr/scaffold/templates/edit.html.erb +3 -3
  27. data/lib/generators/openehr/scaffold/templates/index.html.erb +4 -4
  28. data/lib/generators/openehr/scaffold/templates/inflections.rb +3 -0
  29. data/lib/generators/openehr/scaffold/templates/layout.css.scss +4 -0
  30. data/lib/generators/openehr/scaffold/templates/new.html.erb +5 -0
  31. data/lib/generators/openehr/scaffold/templates/show.html.erb +2 -2
  32. data/lib/generators/openehr.rb +67 -49
  33. data/lib/openehr-rails/version.rb +1 -1
  34. data/lib/openehr-rails.rb +1 -1
  35. data/openehr-rails.gemspec +1 -5
  36. data/spec/generator_helper.rb +3 -0
  37. data/spec/generators/openehr/archetyped_base_spec.rb +53 -35
  38. data/spec/generators/openehr/assets/assets_generator_spec.rb +37 -0
  39. data/spec/generators/openehr/controller/controller_generator_spec.rb +20 -4
  40. data/spec/generators/openehr/helper/helper_generator_spec.rb +23 -0
  41. data/spec/generators/openehr/i18n/i18n_generator_spec.rb +49 -50
  42. data/spec/generators/openehr/install/install_generator_spec.rb +3 -3
  43. data/spec/generators/openehr/migration/migration_generator_spec.rb +18 -7
  44. data/spec/generators/openehr/model/model_generator_spec.rb +54 -0
  45. data/spec/generators/openehr/scaffold/scaffold_generator_spec.rb +121 -48
  46. data/spec/spec_helper.rb +6 -6
  47. metadata +26 -68
  48. data/Guardfile +0 -15
  49. data/db/seeds.rb +0 -7
  50. data/lib/assets/.gitkeep +0 -0
@@ -1,47 +1,65 @@
1
1
  require 'spec_helper'
2
2
  require 'generators/openehr'
3
+ require 'generator_helper'
3
4
 
4
- describe OpenEHR::Rails::Generators::ArchetypedBase do
5
- before (:each) do
6
- adl_file = File.expand_path '../../templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl', __FILE__
7
- @archetyped_base = OpenEHR::Rails::Generators::ArchetypedBase.new([adl_file])
8
- end
5
+ module Openehr
6
+ module Generators
7
+ describe ArchetypedBase do
8
+ before (:each) do
9
+ @archetyped_base = Openehr::Generators::ArchetypedBase.new([archetype])
10
+ end
9
11
 
10
- context 'archtype path' do
11
- it 'archetype_path is app/archetypes' do
12
- @archetyped_base.archetype_path.should == 'app/archetypes'
13
- end
14
- end
12
+ context 'archetype file' do
13
+ it 'archetype file is adl_file' do
14
+ adl_file = File.expand_path '../../templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl', __FILE__
15
+ archetyped_base = Openehr::Generators::ArchetypedBase.new([adl_file])
16
+ archetyped_base.send(:archetype_file).should == File.expand_path('../../templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl', __FILE__)
17
+ end
18
+ end
15
19
 
16
- context 'data_tree' do
17
- it 'rm_attribute_name.should data' do
18
- @archetyped_base.data_tree.rm_attribute_name.should == 'data'
19
- end
20
- end
20
+ context 'archetype path' do
21
+ it 'archetype_path is app/archetypes' do
22
+ @archetyped_base.send(:archetype_path).should == 'app/archetypes'
23
+ end
24
+ end
25
+
26
+ context 'data_tree' do
27
+ it 'rm_attribute_name.should data' do
28
+ @archetyped_base.send(:data_tree).rm_attribute_name.should == 'data'
29
+ end
30
+ end
31
+
32
+ context 'index data' do
33
+ it 'includes value data' do
34
+ @archetyped_base.send(:index_data).should include 'at0004'
35
+ end
21
36
 
22
- context 'index data' do
23
- it 'includes value data' do
24
- @archetyped_base.index_data.should include 'at0004'
25
- end
37
+ it 'includes at0005, too' do
38
+ @archetyped_base.send(:index_data).should include 'at0005'
39
+ end
26
40
 
27
- it 'includes at0005, too' do
28
- @archetyped_base.index_data.should include 'at0005'
29
- end
30
-
31
- it 'does not include at0006' do
32
- @archetyped_base.index_data.should_not include 'at0006'
33
- end
34
- end
41
+ it 'does not include at0006' do
42
+ @archetyped_base.send(:index_data).should_not include 'at0006'
43
+ end
44
+ end
35
45
 
36
- # context 'show data' do
37
- # subject { @archetyped_base. }
46
+ # context 'show data' do
47
+ # subject { @archetyped_base. }
48
+
49
+ # it { should have_key :protocol }
50
+ # end
38
51
 
39
- # it { should have_key :protocol }
40
- # end
52
+ context 'model name' do
53
+ it 'is origined form archetype id' do
54
+ expect(@archetyped_base.send(:model_name)).to eq 'open_ehr_ehr_observation_blood_pressure_v1'
55
+ end
56
+ end
41
57
 
42
- context 'model name' do
43
- it 'is origined form archetype id' do
44
- expect(@archetyped_base.model_name).to eq 'open_ehr_ehr_observation_blood_pressure_v1'
45
- end
58
+ context 'controller_name' do
59
+ it 'is originated from archtype id' do
60
+ expect(@archetyped_base.send(:controller_name)).to eq 'open_ehr_ehr_observation_blood_pressure_v1'
61
+ end
62
+ end
63
+ end
46
64
  end
47
65
  end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+ require 'generators/openehr/assets/assets_generator'
3
+ require 'openehr/am'
4
+ require 'openehr/rm'
5
+ require 'openehr/parser'
6
+ require 'generator_helper'
7
+ module Openehr
8
+ module Generators
9
+ describe AssetsGenerator do
10
+ destination File.expand_path('../../../../../tmp', __FILE__)
11
+
12
+ before(:each) do
13
+ prepare_destination
14
+ run_generator [archetype]
15
+ end
16
+
17
+ context 'scaffold.css' do
18
+ subject { file('app/assets/stylesheets/scaffold.css') }
19
+
20
+ it { should exist }
21
+ it { should contain /body {/}
22
+ end
23
+
24
+ context 'generate scss file' do
25
+ subject { file('app/assets/stylesheets/open_ehr_ehr_observation_blood_pressure_v1.css.scss') }
26
+
27
+ it { should exist }
28
+ end
29
+
30
+ context 'generate coffeescript' do
31
+ subject { file('app/assets/javascripts/open_ehr_ehr_observation_blood_pressure_v1.js.coffee') }
32
+
33
+ it { should exist }
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,9 +1,25 @@
1
1
  require 'spec_helper'
2
2
  require 'generators/openehr/controller/controller_generator'
3
+ require 'generator_helper'
3
4
 
4
- describe OpenEHR::Rails::Generators::ControllerGenerator do
5
+ module Openehr
6
+ module Generators
7
+ describe ControllerGenerator do
8
+ destination File.expand_path("../../../../../tmp", __FILE__)
9
+
10
+ before { prepare_destination }
11
+
12
+ before(:each) do
13
+ prepare_destination
14
+ run_generator [archetype]
15
+ end
16
+
17
+ subject { file('app/controllers/open_ehr_ehr_observation_blood_pressure_v1_controller.rb') }
18
+
19
+ it { should exist }
5
20
 
6
- destination File.expand_path("../../../../../tmp", __FILE__)
7
-
8
- before { prepare_destination }
21
+ it { should contain /^class OpenEhrEhrObservationBloodPressureV1Controller < ApplicationController$/ }
22
+ end
23
+ end
9
24
  end
25
+
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'generators/openehr/helper/helper_generator'
3
+ require 'generator_helper'
4
+
5
+ module Openehr
6
+ module Generators
7
+ describe HelperGenerator do
8
+ destination File.expand_path('../../../../../tmp', __FILE__)
9
+
10
+ before(:each) do
11
+ prepare_destination
12
+ run_generator [archetype]
13
+ end
14
+
15
+ context 'helper generation' do
16
+ subject { file('app/helpers/open_ehr_ehr_observation_blood_pressure_v1_helper.rb') }
17
+
18
+ it { should exist }
19
+ it { should contain /module OpenEhrEhrObservationBloodPressureV1Helper/ }
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,60 +1,59 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'spec_helper'
3
3
  require 'generators/openehr/i18n/i18n_generator'
4
+ require 'generator_helper'
4
5
 
5
- module OpenEHR
6
- module Rails
7
- module Generators
8
- describe I18nGenerator do
9
- destination File.expand_path '../../../../../tmp/', __FILE__
6
+ module Openehr
7
+ module Generators
8
+ describe I18nGenerator do
9
+ destination File.expand_path '../../../../../tmp/', __FILE__
10
10
 
11
- before do
12
- prepare_destination
13
- run_generator %w(spec/generators/templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl)
11
+ before(:each) do
12
+ prepare_destination
13
+ run_generator [archetype]
14
+ end
15
+
16
+ describe 'File generation' do
17
+ describe 'i18n.rb generation' do
18
+ subject { file('config/initializers/i18n.rb') }
19
+
20
+ it { should exist }
21
+ it { should contain /I18n\.default_locale = :en/ }
22
+ it { should contain /LANGUAGES/ }
23
+ it { should contain /\['English', 'en'\],/ }
24
+ it { should contain /\['Japanese', 'ja'\]/ }
25
+ it { should contain /\['Dutch', 'nl'\],/ }
26
+ end
27
+
28
+ describe 'en.yml generation' do
29
+ subject { file('config/locales/en.yml') }
30
+
31
+ it { should exist }
32
+ it { should contain /en:/ }
33
+ it { should contain /layouts:/ }
34
+ it { should contain /application:/ }
35
+ it { should contain /open_ehr_ehr_observation_blood_pressure_v1/ }
36
+ it { should contain /index: &ontology/ }
37
+ it { should contain /at0000: "Blood Pressure"/ }
38
+ it { should contain /at0001: "history"/ }
39
+ it { should contain /new: \*ontology/ }
40
+ it { should contain /form: \*ontology/ }
41
+ it { should contain /show: \*ontology/ }
42
+ it { should contain /edit: \*ontology/ }
14
43
  end
15
44
 
16
- describe 'File generation' do
17
- describe 'i18n.rb generation' do
18
- subject { file('config/initializers/i18n.rb') }
19
-
20
- it { should exist }
21
- it { should contain /I18n\.default_locale = :en/ }
22
- it { should contain /LANGUAGES/ }
23
- it { should contain /\['English', 'en'\],/ }
24
- it { should contain /\['Japanese', 'ja'\]/ }
25
- it { should contain /\['Dutch', 'nl'\],/ }
26
- end
27
-
28
- describe 'en.yml generation' do
29
- subject { file('config/locales/en.yml') }
30
-
31
- it { should exist }
32
- it { should contain /en:/ }
33
- it { should contain /layouts:/ }
34
- it { should contain /application:/ }
35
- it { should contain /open_ehr_ehr_observation.blood_pressure.v1/ }
36
- it { should contain /index: &ontology/ }
37
- it { should contain /at0000: "Blood Pressure"/ }
38
- it { should contain /at0001: "history"/ }
39
- it { should contain /new: \*ontology/ }
40
- it { should contain /form: \*ontology/ }
41
- it { should contain /show: \*ontology/ }
42
- it { should contain /edit: \*ontology/ }
43
- end
44
-
45
- describe 'ja.yml generation' do
46
- subject { file('config/locales/ja.yml')}
47
-
48
- it { should exist }
49
- it { should contain /ja:/ }
50
- end
51
-
52
- describe 'nl.yml generation' do
53
- subject { file('config/locales/nl.yml') }
54
-
55
- it { should exist }
56
- it { should contain /nl:/ }
57
- end
45
+ describe 'ja.yml generation' do
46
+ subject { file('config/locales/ja.yml')}
47
+
48
+ it { should exist }
49
+ it { should contain /ja:/ }
50
+ end
51
+
52
+ describe 'nl.yml generation' do
53
+ subject { file('config/locales/nl.yml') }
54
+
55
+ it { should exist }
56
+ it { should contain /nl:/ }
58
57
  end
59
58
  end
60
59
  end
@@ -1,15 +1,15 @@
1
1
  require 'spec_helper'
2
2
  require 'generators/openehr/install/install_generator'
3
3
 
4
- describe OpenEHR::Rails::Generators::InstallGenerator do
4
+ describe Openehr::Generators::InstallGenerator do
5
5
  destination File.expand_path('../../../../../tmp', __FILE__)
6
6
 
7
- before do
7
+ before(:each) do
8
8
  prepare_destination
9
+ run_generator
9
10
  end
10
11
 
11
12
  it 'makes app/archetypes directory' do
12
- run_generator
13
13
  file('app/archetypes').should exist
14
14
  end
15
15
  end
@@ -1,16 +1,27 @@
1
1
  require 'spec_helper'
2
2
  require 'generators/openehr/migration/migration_generator'
3
3
 
4
- describe OpenEHR::Rails::Generators::MigrationGenerator do
5
- destination File.expand_path(destination_root)
4
+ module Openehr
5
+ module Generators
6
+ describe MigrationGenerator do
7
+ destination File.expand_path('../../../../../tmp', __FILE__)
6
8
 
7
- before { prepare_destination }
9
+ before(:each) do
10
+ prepare_destination
11
+ run_generator
12
+ end
8
13
 
9
- describe 'default rm db migration' do
10
- before { run_generator }
14
+ context 'default archetype db migration' do
15
+ subject { file('db/migrate/create_archetypes.rb') }
11
16
 
12
- # subject {file('db/migration/20121127020800_create_archetype_db')}
17
+ it { should be_a_migration }
18
+ end
13
19
 
14
- # it { should exist }
20
+ context 'default rm db migration' do
21
+ subject { file('db/migrate/create_rms.rb') }
22
+
23
+ it { should be_a_migration }
24
+ end
25
+ end
15
26
  end
16
27
  end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+ require 'generators/openehr/model/model_generator'
3
+ require 'generator_helper'
4
+
5
+ module Openehr
6
+ module Generators
7
+ describe ModelGenerator do
8
+ destination File.expand_path('../../../../../tmp', __FILE__)
9
+
10
+ before(:each) do
11
+ prepare_destination
12
+ run_generator [archetype]
13
+ end
14
+
15
+ context 'rm.rb generation' do
16
+ subject { file('app/models/rm.rb') }
17
+
18
+ it { should exist }
19
+ it { should contain 'class Rm < ActiveRecord::Base' }
20
+ it { should contain 'belongs_to :archetype' }
21
+ end
22
+
23
+ context 'archetype.rb generation' do
24
+ subject { file('app/models/archetype.rb') }
25
+
26
+ it { should exist }
27
+ it { should contain 'class Archetype < ActiveRecord::Base' }
28
+ it { should contain 'has_many :rms, dependent: :destroy' }
29
+ end
30
+
31
+ context 'interim model generation' do
32
+ subject { file('app/models/open_ehr_ehr_observation_blood_pressure_v1.rb') }
33
+
34
+ it { should exist }
35
+ it { should contain 'class OpenEhrEhrObservationBloodPressureV1' }
36
+ it { should contain 'OpenEhrEhrObservationBloodPressureV1.new(archetype: archetype)' }
37
+ it { should contain 'OpenEhrEhrObservationBloodPressureV1.new(archetype: Archetype.find(id))' }
38
+ it { should contain "def self.build(params)\n OpenEhrEhrObservationBloodPressureV1.new(params)"}
39
+ it { should contain 'archetype.rms.inject(archetype.save, :&) {|rm| rm.save' }
40
+ it { should contain "def update(attributes)\n self.attributes=attributes" }
41
+ it { should contain "@archetype ||= Archetype.new(archetypeid: 'openEHR-EHR-OBSERVATION.blood_pressure.v1', uid: SecureRandom.uuid)" }
42
+ it { should contain /def at0004$/ }
43
+ it { should contain /at0004model.num_value$/}
44
+ it { should contain 'def at0004=(at0004)' }
45
+ it { should contain 'at0004model.num_value = at0004'}
46
+ it { should contain 'translate(at0008model.text_value)'}
47
+ it { should contain 'def confat(node_id, path)'}
48
+ it { should contain 'archetype.rms.build(:node_id => node_id, :path => path)' }
49
+ it { should contain 'I18n.translate("open_ehr_ehr_observation_blood_pressure_v1.index.#{term}")'}
50
+ it { should contain "def persisted?\n archetype.persisted?"}
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,69 +1,142 @@
1
1
  require 'spec_helper'
2
2
  require 'generators/openehr/scaffold/scaffold_generator'
3
+ require 'generator_helper'
3
4
 
4
- module OpenEHR
5
- module Rails
6
- module Generators
7
- describe ScaffoldGenerator do
8
- destination File.expand_path('../../../../../tmp', __FILE__)
5
+ module Openehr
6
+ module Generators
7
+ describe ScaffoldGenerator do
8
+ destination File.expand_path('../../../../../tmp', __FILE__)
9
9
 
10
- before do
11
- prepare_destination
12
- run_generator %w(spec/generators/templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl)
10
+ before(:each) do
11
+ prepare_destination
12
+ run_generator [archetype]
13
+ end
14
+
15
+ context 'invoke migration generator' do
16
+ context 'generate rm migration' do
17
+ subject { file('db/migrate/create_rms.rb') }
18
+
19
+ it { should be_a_migration}
13
20
  end
14
21
 
15
- describe 'invoke index.html.erb template engine' do
16
- subject { file('app/views/open_ehr_ehr_observation.blood_pressure.v1/index.html.erb') }
22
+ context 'generate archetype migration' do
23
+ subject { file('db/migrate/create_archetypes.rb') }
17
24
 
18
- it { should exist }
19
- it { should contain /\<h1\>Listing \<%= t\("\.at0000"\) %\>\<\/h1\>/ }
20
- it { should contain /\<th\>\<%= t\("\.at0004"\) %\>\<\/th\>/ }
21
- it { should contain /\<th\>\<%= t\("\.at0005"\) %\>\<\/th\>/ }
22
- it { should_not contain /\<th\>\<%= t\("\.at0006"\) %\>\<\/th\>/ }
23
- it { should contain /\<td\>\<%= open_ehr_ehr_observation_blood_pressure_v1\.at0004 %\>\<\/td\>/ }
24
- it { should contain /link_to \<%= t\("\.at0000"\) %\>/}
25
+ it { should be_a_migration }
25
26
  end
27
+ end
26
28
 
27
- describe 'invoke show.html.erb template engine' do
28
- subject { file('app/views/open_ehr_ehr_observation.blood_pressure.v1/show.html.erb') }
29
+
30
+ context 'generate rm model' do
31
+ subject { file('app/models/open_ehr_ehr_observation_blood_pressure_v1.rb') }
29
32
 
30
- it { should exist }
31
- it { should contain /Observation/ }
32
- it { should contain /t\(\"\.at0000\"\)/ }
33
- it { should contain /Data/ }
34
- it { should contain /Protocol/ }
35
- end
33
+ it { should exist}
34
+ end
36
35
 
37
- describe 'invoke edit.html.erb template engine' do
38
- subject { file('app/views/open_ehr_ehr_observation.blood_pressure.v1/edit.html.erb') }
36
+ context 'invoke index.html.erb template engine' do
37
+ subject { file('app/views/open_ehr_ehr_observation_blood_pressure_v1/index.html.erb') }
39
38
 
40
- it { should exist }
41
- it { should contain /Editing \<%= t\(\"\.at0000\"\) /}
42
- end
39
+ it { should exist }
40
+ it { should contain '<h1>Listing <%= t(".at0000") %></h1>' }
41
+ it { should contain '<th><%= t(".at0004") %></th>' }
42
+ it { should contain '<th><%= t(".at0005") %></th>' }
43
+ it { should_not contain '<th><%= t(".at0006") %></th>' }
44
+ it { should contain '<td><%= open_ehr_ehr_observation_blood_pressure_v1.at0004 %></td>' }
45
+ it { should contain "<%= link_to 'Show', open_ehr_ehr_observation_blood_pressure_v1_path(id: open_ehr_ehr_observation_blood_pressure_v1.id) %>"}
46
+ it { should contain "<%= link_to 'Edit', edit_open_ehr_ehr_observation_blood_pressure_v1_path(id: open_ehr_ehr_observation_blood_pressure_v1.id) %>" }
47
+ it { should contain "<%= link_to 'Destroy', open_ehr_ehr_observation_blood_pressure_v1_path(id: open_ehr_ehr_observation_blood_pressure_v1.id), method: :delete, data: { confirm: 'Are you sure?' } %>"}
48
+ end
43
49
 
44
- describe 'invoke _form.html.erb template engine' do
45
- subject { file('app/views/open_ehr_ehr_observation.blood_pressure.v1/_form.html.erb')}
50
+ context 'invoke show.html.erb template engine' do
51
+ subject { file('app/views/open_ehr_ehr_observation_blood_pressure_v1/show.html.erb') }
46
52
 
47
- it { should exist }
48
- it { should contain // }
49
-
50
- end
53
+ it { should contain 'Data' }
54
+ it { should contain "<strong><%= t('.at0005') %></strong>: " }
55
+ it { should contain '<%= @open_ehr_ehr_observation_blood_pressure_v1.at0005 %>mm[Hg]<br/>' }
56
+ it { should contain 'Protocol' }
57
+ it { should contain "<strong><%= t('.at0013') %></strong>: <%= @open_ehr_ehr_observation_blood_pressure_v1.at0013 %>"}
58
+ end
51
59
 
52
- describe 'invoke routing generator' do
53
- subject { file('config/routes.rb')}
60
+ context 'invoke edit.html.erb template engine' do
61
+ subject { file('app/views/open_ehr_ehr_observation_blood_pressure_v1/edit.html.erb') }
54
62
 
55
- it { should contain /scope "\/:locale" do/ }
56
- it { should contain /resources :open_ehr_ehr_observation.blood_pressure.v1/}
57
- end
63
+ it { should exist }
64
+ it { should contain "Editing <%= t('.at0000')"}
65
+ end
58
66
 
59
- describe 'application controller modifier' do
60
- subject { file('app/controllers/application_controller.rb')}
67
+ context 'invoke new.html.erb template engine' do
68
+ subject { file('app/views/open_ehr_ehr_observation_blood_pressure_v1/new.html.erb')}
61
69
 
62
- it { should contain /before_action :set_locale/ }
63
- it { should contain /def set_locale/ }
64
- it { should contain /I18n\.locale = params\[:locale\] \|\| I18n.default_locale/ }
65
- it { should contain /end$/ }
66
- end
70
+ it { should exist}
71
+ it { should contain /New \<%= t\(\".at0000\"\) %\>/ }
72
+ end
73
+
74
+ context 'invoke _form.html.erb template engine' do
75
+ subject { file('app/views/open_ehr_ehr_observation_blood_pressure_v1/_form.html.erb')}
76
+
77
+ it { should exist }
78
+ it { should contain "f.select :at0013, t('.at0015') => 'at0015', t('.at0016') => 'at0016'"}
79
+ it { should contain "<%= t('.at0006') %></strong>: <%= f.text_field :at0006 %>" }
80
+ end
81
+
82
+ context 'invoke routing generator' do
83
+ subject { file('config/routes.rb')}
84
+
85
+ it { should contain 'resources :open_ehr_ehr_observation_blood_pressure_v1'}
86
+ end
87
+
88
+ context 'Insert inflection setting' do
89
+ subject { file('config/initializers/inflections.rb') }
90
+
91
+ it { should contain 'inflect.uncountable %w( open_ehr_ehr_observation_blood_pressure_v1 )' }
92
+ end
93
+
94
+ context 'invoke assets generator' do
95
+ subject { file('app/assets/stylesheets/scaffold.css') }
96
+
97
+ it { should exist }
98
+ end
99
+
100
+ context 'i18n generator' do
101
+ subject { file('config/initializers/i18n.rb') }
102
+
103
+ it { should exist }
104
+ end
105
+
106
+ context 'add locale switcher to application.html.erb' do
107
+ subject { file('app/views/layouts/application.html.erb') }
108
+
109
+ it { should exist }
110
+ it { should contain /\<%= select_tag 'locale',/ }
111
+ it { should contain /options_for_select\(LANGUAGES, I18n\.locale.to_s\),/ }
112
+ end
113
+
114
+ context 'layout.css.scss' do
115
+ subject { file('app/assets/stylesheets/layout.css.scss') }
116
+
117
+ it { should exist }
118
+ it { should contain /\.locale {/ }
119
+ end
120
+
121
+ context 'invoke helper generator' do
122
+ subject { file('app/helpers/open_ehr_ehr_observation_blood_pressure_v1_helper.rb')}
123
+
124
+ it { should exist }
125
+ end
126
+
127
+ describe 'controller generator' do
128
+ subject { file('app/controllers/open_ehr_ehr_observation_blood_pressure_v1_controller.rb') }
129
+
130
+ it { should exist }
131
+ end
132
+
133
+ describe 'application controller modifier' do
134
+ subject { file('app/controllers/application_controller.rb') }
135
+
136
+ it { should contain /before_action :set_locale/ }
137
+ it { should contain /def set_locale/ }
138
+ it { should contain /I18n\.locale = params\[:locale\] \|\| session\[:locale\] \|\| I18n\.default_locale/ }
139
+ it { should contain /end$/ }
67
140
  end
68
141
  end
69
142
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'rails/all'
2
2
  require 'ammeter/init'
3
- require 'spork'
4
3
 
5
4
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
6
5
  $:.unshift(File.dirname(__FILE__) + '/../lib')
@@ -8,11 +7,12 @@ require 'openehr/rails'
8
7
 
9
8
  require 'simplecov'
10
9
 
11
- Spork.prefork do
12
- SimpleCov.start
13
- end
10
+ SimpleCov.start
11
+ # Spork.prefork do
12
+ #
13
+ # end
14
14
 
15
- Spork.each_run do
15
+ # Spork.each_run do
16
16
 
17
- end
17
+ # end
18
18