openehr-rails 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +13 -0
- data/Rakefile +1 -16
- data/lib/generators/openehr/assets/assets_generator.rb +28 -0
- data/lib/generators/openehr/assets/templates/javascript.js +1 -0
- data/lib/generators/openehr/assets/templates/stylesheet.css.scss +3 -0
- data/lib/generators/openehr/controller/controller_generator.rb +10 -9
- data/lib/generators/openehr/controller/templates/controller.rb +71 -10
- data/lib/generators/openehr/helper/helper_generator.rb +17 -0
- data/lib/generators/openehr/helper/templates/helper.rb +2 -0
- data/lib/generators/openehr/i18n/i18n_generator.rb +29 -33
- data/lib/generators/openehr/i18n/templates/i18n.rb +3 -3
- data/lib/generators/openehr/i18n/templates/language.yml +8 -3
- data/lib/generators/openehr/install/install_generator.rb +6 -9
- data/lib/generators/openehr/migration/migration_generator.rb +24 -9
- data/lib/generators/openehr/migration/templates/archetypes.rb +10 -0
- data/lib/generators/openehr/migration/templates/rms.rb +16 -0
- data/lib/generators/openehr/model/model_generator.rb +108 -7
- data/lib/generators/openehr/model/templates/activemodel.rb +71 -0
- data/lib/generators/openehr/model/templates/archetype.rb +3 -0
- data/lib/generators/openehr/model/templates/rm.rb +3 -0
- data/lib/generators/openehr/scaffold/scaffold_generator.rb +182 -109
- data/lib/generators/openehr/scaffold/templates/_form.html.erb +1 -1
- data/lib/generators/openehr/scaffold/templates/application.html.erb +14 -0
- data/lib/generators/openehr/scaffold/templates/application_controller.rb +1 -0
- data/lib/generators/openehr/scaffold/templates/edit.html.erb +3 -3
- data/lib/generators/openehr/scaffold/templates/index.html.erb +4 -4
- data/lib/generators/openehr/scaffold/templates/inflections.rb +3 -0
- data/lib/generators/openehr/scaffold/templates/layout.css.scss +4 -0
- data/lib/generators/openehr/scaffold/templates/new.html.erb +5 -0
- data/lib/generators/openehr/scaffold/templates/show.html.erb +2 -2
- data/lib/generators/openehr.rb +67 -49
- data/lib/openehr-rails/version.rb +1 -1
- data/lib/openehr-rails.rb +1 -1
- data/openehr-rails.gemspec +1 -5
- data/spec/generator_helper.rb +3 -0
- data/spec/generators/openehr/archetyped_base_spec.rb +53 -35
- data/spec/generators/openehr/assets/assets_generator_spec.rb +37 -0
- data/spec/generators/openehr/controller/controller_generator_spec.rb +20 -4
- data/spec/generators/openehr/helper/helper_generator_spec.rb +23 -0
- data/spec/generators/openehr/i18n/i18n_generator_spec.rb +49 -50
- data/spec/generators/openehr/install/install_generator_spec.rb +3 -3
- data/spec/generators/openehr/migration/migration_generator_spec.rb +18 -7
- data/spec/generators/openehr/model/model_generator_spec.rb +54 -0
- data/spec/generators/openehr/scaffold/scaffold_generator_spec.rb +121 -48
- data/spec/spec_helper.rb +6 -6
- metadata +26 -68
- data/Guardfile +0 -15
- data/db/seeds.rb +0 -7
- 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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
37
|
+
it 'includes at0005, too' do
|
38
|
+
@archetyped_base.send(:index_data).should include 'at0005'
|
39
|
+
end
|
26
40
|
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
37
|
-
|
46
|
+
# context 'show data' do
|
47
|
+
# subject { @archetyped_base. }
|
48
|
+
|
49
|
+
# it { should have_key :protocol }
|
50
|
+
# end
|
38
51
|
|
39
|
-
|
40
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
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
|
6
|
-
module
|
7
|
-
|
8
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
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 '
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
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
|
-
|
5
|
-
|
4
|
+
module Openehr
|
5
|
+
module Generators
|
6
|
+
describe MigrationGenerator do
|
7
|
+
destination File.expand_path('../../../../../tmp', __FILE__)
|
6
8
|
|
7
|
-
|
9
|
+
before(:each) do
|
10
|
+
prepare_destination
|
11
|
+
run_generator
|
12
|
+
end
|
8
13
|
|
9
|
-
|
10
|
-
|
14
|
+
context 'default archetype db migration' do
|
15
|
+
subject { file('db/migrate/create_archetypes.rb') }
|
11
16
|
|
12
|
-
|
17
|
+
it { should be_a_migration }
|
18
|
+
end
|
13
19
|
|
14
|
-
|
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
|
5
|
-
module
|
6
|
-
|
7
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
16
|
-
subject { file('
|
22
|
+
context 'generate archetype migration' do
|
23
|
+
subject { file('db/migrate/create_archetypes.rb') }
|
17
24
|
|
18
|
-
it { should
|
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
|
-
|
28
|
-
|
29
|
+
|
30
|
+
context 'generate rm model' do
|
31
|
+
subject { file('app/models/open_ehr_ehr_observation_blood_pressure_v1.rb') }
|
29
32
|
|
30
|
-
|
31
|
-
|
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
|
-
|
38
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
45
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
53
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
63
|
+
it { should exist }
|
64
|
+
it { should contain "Editing <%= t('.at0000')"}
|
65
|
+
end
|
58
66
|
|
59
|
-
|
60
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
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
|
|