openehr-rails 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/generators/openehr.rb +1 -1
- data/lib/openehr-rails/version.rb +1 -1
- data/openehr-rails.gemspec +1 -1
- data/spec/generator_helper.rb +2 -1
- data/spec/generators/openehr/archetyped_base_spec.rb +17 -16
- data/spec/generators/openehr/assets/assets_generator_spec.rb +4 -4
- data/spec/generators/openehr/controller/controller_generator_spec.rb +2 -2
- data/spec/generators/openehr/helper/helper_generator_spec.rb +2 -2
- data/spec/generators/openehr/i18n/i18n_generator_spec.rb +22 -22
- data/spec/generators/openehr/install/install_generator_spec.rb +1 -1
- data/spec/generators/openehr/migration/migration_generator_spec.rb +2 -2
- data/spec/generators/openehr/model/model_generator_spec.rb +24 -24
- data/spec/generators/openehr/scaffold/scaffold_generator_spec.rb +39 -39
- data/spec/generators/templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl +2990 -1021
- data/spec/rcomponents/relement_spec.rb +3 -3
- data/spec/rcomponents/robservation_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +3 -18
- data/lib/openehr/rails.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edebd8ffbc62aa73c4a68c3228cd620785d9d5da
|
4
|
+
data.tar.gz: 8adab5b662a5e326cfa8f789b94edad7f01a47a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14bc325f51ef06ace5fbcea0d809d1eb584f98107382552709b2b16bb16078e7768d7ec5dc76a8d55a625a0157dd1df026dbeb6b49ede8993c22ebc0adacf23c
|
7
|
+
data.tar.gz: bba6b194d42a8ab8223141a210a55f1eb3a366fa85289f84f415dfeafb3585ff33868ed5fda7defa60142dd590a65faddbcbd7e7aa05409ab2117de3f90891ba
|
data/Gemfile
CHANGED
data/lib/generators/openehr.rb
CHANGED
data/openehr-rails.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
21
|
|
22
22
|
gem.require_paths = ["lib"]
|
23
|
-
gem.add_dependency('openehr')
|
23
|
+
# gem.add_dependency('openehr')
|
24
24
|
gem.add_dependency('rails', '~> 4.1.0')
|
25
25
|
gem.add_dependency('ckm_client')
|
26
26
|
|
data/spec/generator_helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
1
|
def archetype
|
2
|
-
@archetype ||= OpenEHR::Parser::ADLParser.new('
|
2
|
+
@archetype ||= OpenEHR::Parser::ADLParser.new(File.join(File.dirname(__FILE__), 'generators/templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl')).parse
|
3
3
|
end
|
4
|
+
# let(:archetype) {OpenEHR::Parser::ADLParser.new('spec/generators/templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl').parse}
|
@@ -5,33 +5,34 @@ require 'generator_helper'
|
|
5
5
|
module Openehr
|
6
6
|
module Generators
|
7
7
|
describe ArchetypedBase do
|
8
|
-
|
9
|
-
@archetyped_base = Openehr::Generators::ArchetypedBase.new([archetype])
|
10
|
-
end
|
8
|
+
let(:adl_file) { File.expand_path('../../templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl', __FILE__) }
|
11
9
|
|
12
10
|
context 'archetype file' do
|
13
11
|
it 'archetype file is adl_file' do
|
14
|
-
adl_file = File.expand_path '../../templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl', __FILE__
|
15
12
|
archetyped_base = Openehr::Generators::ArchetypedBase.new([adl_file])
|
16
|
-
archetyped_base.send(:archetype_file).
|
13
|
+
expect(archetyped_base.send(:archetype_file)).to eq(File.expand_path('../../templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl', __FILE__))
|
17
14
|
end
|
18
15
|
end
|
19
16
|
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
describe 'protected values' do
|
18
|
+
let(:archetyped_base) {Openehr::Generators::ArchetypedBase.new([archetype])}
|
19
|
+
|
20
|
+
context 'archetype path' do
|
21
|
+
it 'archetype_path is app/archetypes' do
|
22
|
+
expect(archetyped_base.send(:archetype_path)).to eq('app/archetypes')
|
23
|
+
end
|
23
24
|
end
|
24
|
-
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
context 'model name' do
|
27
|
+
it 'is origined form archetype id' do
|
28
|
+
expect(archetyped_base.send(:model_name)).to eq 'open_ehr_ehr_observation_blood_pressure_v1'
|
29
|
+
end
|
29
30
|
end
|
30
|
-
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
context 'controller_name' do
|
33
|
+
it 'is originated from archtype id' do
|
34
|
+
expect(archetyped_base.send(:controller_name)).to eq 'open_ehr_ehr_observation_blood_pressure_v1'
|
35
|
+
end
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
@@ -17,20 +17,20 @@ module Openehr
|
|
17
17
|
context 'scaffold.css' do
|
18
18
|
subject { file('app/assets/stylesheets/scaffold.css') }
|
19
19
|
|
20
|
-
it {
|
21
|
-
it {
|
20
|
+
it { is_expected.to exist }
|
21
|
+
it { is_expected.to contain /body {/}
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'generate scss file' do
|
25
25
|
subject { file('app/assets/stylesheets/open_ehr_ehr_observation_blood_pressure_v1.css.scss') }
|
26
26
|
|
27
|
-
it {
|
27
|
+
it { is_expected.to exist }
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'generate coffeescript' do
|
31
31
|
subject { file('app/assets/javascripts/open_ehr_ehr_observation_blood_pressure_v1.js.coffee') }
|
32
32
|
|
33
|
-
it {
|
33
|
+
it { is_expected.to exist }
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -16,9 +16,9 @@ module Openehr
|
|
16
16
|
|
17
17
|
subject { file('app/controllers/open_ehr_ehr_observation_blood_pressure_v1_controller.rb') }
|
18
18
|
|
19
|
-
it {
|
19
|
+
it { is_expected.to exist }
|
20
20
|
|
21
|
-
it {
|
21
|
+
it { is_expected.to contain /^class OpenEhrEhrObservationBloodPressureV1Controller < ApplicationController$/ }
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -15,8 +15,8 @@ module Openehr
|
|
15
15
|
context 'helper generation' do
|
16
16
|
subject { file('app/helpers/open_ehr_ehr_observation_blood_pressure_v1_helper.rb') }
|
17
17
|
|
18
|
-
it {
|
19
|
-
it {
|
18
|
+
it { is_expected.to exist }
|
19
|
+
it { is_expected.to contain /module OpenEhrEhrObservationBloodPressureV1Helper/ }
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -17,43 +17,43 @@ module Openehr
|
|
17
17
|
describe 'i18n.rb generation' do
|
18
18
|
subject { file('config/initializers/i18n.rb') }
|
19
19
|
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
24
|
-
it {
|
25
|
-
it {
|
20
|
+
it { is_expected.to exist }
|
21
|
+
it { is_expected.to contain /I18n\.default_locale = :en/ }
|
22
|
+
it { is_expected.to contain /LANGUAGES/ }
|
23
|
+
it { is_expected.to contain /\['English', 'en'\],/ }
|
24
|
+
it { is_expected.to contain /\['Japanese', 'ja'\]/ }
|
25
|
+
it { is_expected.to contain /\['Dutch', 'nl'\],/ }
|
26
26
|
end
|
27
27
|
|
28
28
|
describe 'en.yml generation' do
|
29
29
|
subject { file('config/locales/en.yml') }
|
30
30
|
|
31
|
-
it {
|
32
|
-
it {
|
33
|
-
it {
|
34
|
-
it {
|
35
|
-
it {
|
36
|
-
it {
|
37
|
-
it {
|
38
|
-
it {
|
39
|
-
it {
|
40
|
-
it {
|
41
|
-
it {
|
42
|
-
it {
|
31
|
+
it { is_expected.to exist }
|
32
|
+
it { is_expected.to contain /en:/ }
|
33
|
+
it { is_expected.to contain /layouts:/ }
|
34
|
+
it { is_expected.to contain /application:/ }
|
35
|
+
it { is_expected.to contain /open_ehr_ehr_observation_blood_pressure_v1/ }
|
36
|
+
it { is_expected.to contain /index: &ontology/ }
|
37
|
+
it { is_expected.to contain /at0000: "Blood Pressure"/ }
|
38
|
+
it { is_expected.to contain /at0001: "history"/ }
|
39
|
+
it { is_expected.to contain /new: \*ontology/ }
|
40
|
+
it { is_expected.to contain /form: \*ontology/ }
|
41
|
+
it { is_expected.to contain /show: \*ontology/ }
|
42
|
+
it { is_expected.to contain /edit: \*ontology/ }
|
43
43
|
end
|
44
44
|
|
45
45
|
describe 'ja.yml generation' do
|
46
46
|
subject { file('config/locales/ja.yml')}
|
47
47
|
|
48
|
-
it {
|
49
|
-
it {
|
48
|
+
it { is_expected.to exist }
|
49
|
+
it { is_expected.to contain /ja:/ }
|
50
50
|
end
|
51
51
|
|
52
52
|
describe 'nl.yml generation' do
|
53
53
|
subject { file('config/locales/nl.yml') }
|
54
54
|
|
55
|
-
it {
|
56
|
-
it {
|
55
|
+
it { is_expected.to exist }
|
56
|
+
it { is_expected.to contain /nl:/ }
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -14,13 +14,13 @@ module Openehr
|
|
14
14
|
context 'default archetype db migration' do
|
15
15
|
subject { file('db/migrate/create_archetypes.rb') }
|
16
16
|
|
17
|
-
it {
|
17
|
+
it { is_expected.to be_a_migration }
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'default rm db migration' do
|
21
21
|
subject { file('db/migrate/create_rms.rb') }
|
22
22
|
|
23
|
-
it {
|
23
|
+
it { is_expected.to be_a_migration }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -15,40 +15,40 @@ module Openehr
|
|
15
15
|
context 'rm.rb generation' do
|
16
16
|
subject { file('app/models/rm.rb') }
|
17
17
|
|
18
|
-
it {
|
19
|
-
it {
|
20
|
-
it {
|
18
|
+
it { is_expected.to exist }
|
19
|
+
it { is_expected.to contain 'class Rm < ActiveRecord::Base' }
|
20
|
+
it { is_expected.to contain 'belongs_to :archetype' }
|
21
21
|
end
|
22
22
|
|
23
23
|
context 'archetype.rb generation' do
|
24
24
|
subject { file('app/models/archetype.rb') }
|
25
25
|
|
26
|
-
it {
|
27
|
-
it {
|
28
|
-
it {
|
26
|
+
it { is_expected.to exist }
|
27
|
+
it { is_expected.to contain 'class Archetype < ActiveRecord::Base' }
|
28
|
+
it { is_expected.to contain 'has_many :rms, dependent: :destroy' }
|
29
29
|
end
|
30
30
|
|
31
31
|
context 'interim model generation' do
|
32
32
|
subject { file('app/models/open_ehr_ehr_observation_blood_pressure_v1.rb') }
|
33
33
|
|
34
|
-
it {
|
35
|
-
it {
|
36
|
-
it {
|
37
|
-
it {
|
38
|
-
it {
|
39
|
-
it {
|
40
|
-
it {
|
41
|
-
it {
|
42
|
-
it {
|
43
|
-
it {
|
44
|
-
it {
|
45
|
-
it {
|
46
|
-
it {
|
47
|
-
it {
|
48
|
-
it {
|
49
|
-
it {
|
50
|
-
it {
|
51
|
-
it {
|
34
|
+
it { is_expected.to exist }
|
35
|
+
it { is_expected.to contain 'class OpenEhrEhrObservationBloodPressureV1' }
|
36
|
+
it { is_expected.to contain 'OpenEhrEhrObservationBloodPressureV1.new(archetype: archetype)' }
|
37
|
+
it { is_expected.to contain 'OpenEhrEhrObservationBloodPressureV1.new(archetype: Archetype.find(id))' }
|
38
|
+
it { is_expected.to contain "def self.build(params)\n OpenEhrEhrObservationBloodPressureV1.new(params)"}
|
39
|
+
it { is_expected.to contain 'archetype.rms.inject(archetype.save, :&) {|rm| rm.save' }
|
40
|
+
it { is_expected.to contain "def update(attributes)\n self.attributes=attributes" }
|
41
|
+
it { is_expected.to contain "@archetype ||= Archetype.new(archetypeid: 'openEHR-EHR-OBSERVATION.blood_pressure.v1', uid: SecureRandom.uuid)" }
|
42
|
+
it { is_expected.to contain /def at0004$/ }
|
43
|
+
it { is_expected.to contain /at0004model.num_value$/}
|
44
|
+
it { is_expected.to contain 'def at0004=(at0004)' }
|
45
|
+
it { is_expected.to contain 'at0004model.num_value = at0004'}
|
46
|
+
it { is_expected.to contain 'at0004model.save'}
|
47
|
+
it { is_expected.to contain 'translate(at0008model.text_value)'}
|
48
|
+
it { is_expected.to contain 'def confat(node_id, path)'}
|
49
|
+
it { is_expected.to contain 'archetype.rms.build(:node_id => node_id, :path => path)' }
|
50
|
+
it { is_expected.to contain 'I18n.translate("open_ehr_ehr_observation_blood_pressure_v1.index.#{term}")'}
|
51
|
+
it { is_expected.to contain "def persisted?\n archetype.persisted?"}
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -16,13 +16,13 @@ module Openehr
|
|
16
16
|
context 'generate rm migration' do
|
17
17
|
subject { file('db/migrate/create_rms.rb') }
|
18
18
|
|
19
|
-
it {
|
19
|
+
it { is_expected.to be_a_migration}
|
20
20
|
end
|
21
21
|
|
22
22
|
context 'generate archetype migration' do
|
23
23
|
subject { file('db/migrate/create_archetypes.rb') }
|
24
24
|
|
25
|
-
it {
|
25
|
+
it { is_expected.to be_a_migration }
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -30,113 +30,113 @@ module Openehr
|
|
30
30
|
context 'generate rm model' do
|
31
31
|
subject { file('app/models/open_ehr_ehr_observation_blood_pressure_v1.rb') }
|
32
32
|
|
33
|
-
it {
|
33
|
+
it { is_expected.to exist}
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'invoke index.html.erb template engine' do
|
37
37
|
subject { file('app/views/open_ehr_ehr_observation_blood_pressure_v1/index.html.erb') }
|
38
38
|
|
39
|
-
it {
|
40
|
-
it {
|
41
|
-
it {
|
42
|
-
it {
|
43
|
-
it {
|
44
|
-
it {
|
45
|
-
it {
|
46
|
-
it {
|
47
|
-
it {
|
39
|
+
it { is_expected.to exist }
|
40
|
+
it { is_expected.to contain '<h1>Listing <%= t(".at0000") %></h1>' }
|
41
|
+
it { is_expected.to contain '<th><%= t(".at0004") %></th>' }
|
42
|
+
it { is_expected.to contain '<th><%= t(".at0005") %></th>' }
|
43
|
+
it { is_expected.not_to contain '<th><%= t(".at0006") %></th>' }
|
44
|
+
it { is_expected.to contain '<td><%= open_ehr_ehr_observation_blood_pressure_v1.at0004 %></td>' }
|
45
|
+
it { is_expected.to contain "<%= link_to 'Show', open_ehr_ehr_observation_blood_pressure_v1_path(id: open_ehr_ehr_observation_blood_pressure_v1.id) %>"}
|
46
|
+
it { is_expected.to contain "<%= link_to 'Edit', edit_open_ehr_ehr_observation_blood_pressure_v1_path(id: open_ehr_ehr_observation_blood_pressure_v1.id) %>" }
|
47
|
+
it { is_expected.to 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
48
|
end
|
49
49
|
|
50
50
|
context 'invoke show.html.erb template engine' do
|
51
51
|
subject { file('app/views/open_ehr_ehr_observation_blood_pressure_v1/show.html.erb') }
|
52
52
|
|
53
|
-
it {
|
54
|
-
it {
|
55
|
-
it {
|
56
|
-
it {
|
57
|
-
it {
|
53
|
+
it { is_expected.to contain 'Data' }
|
54
|
+
it { is_expected.to contain "<strong><%= t('.at0005') %></strong>: " }
|
55
|
+
it { is_expected.to contain '<%= @open_ehr_ehr_observation_blood_pressure_v1.at0005 %>mm[Hg]<br/>' }
|
56
|
+
it { is_expected.to contain 'Protocol' }
|
57
|
+
it { is_expected.to contain "<strong><%= t('.at0013') %></strong>: <%= @open_ehr_ehr_observation_blood_pressure_v1.at0013 %>"}
|
58
58
|
end
|
59
59
|
|
60
60
|
context 'invoke edit.html.erb template engine' do
|
61
61
|
subject { file('app/views/open_ehr_ehr_observation_blood_pressure_v1/edit.html.erb') }
|
62
62
|
|
63
|
-
it {
|
64
|
-
it {
|
63
|
+
it { is_expected.to exist }
|
64
|
+
it { is_expected.to contain "Editing <%= t('.at0000')"}
|
65
65
|
end
|
66
66
|
|
67
67
|
context 'invoke new.html.erb template engine' do
|
68
68
|
subject { file('app/views/open_ehr_ehr_observation_blood_pressure_v1/new.html.erb')}
|
69
69
|
|
70
|
-
it {
|
71
|
-
it {
|
70
|
+
it { is_expected.to exist}
|
71
|
+
it { is_expected.to contain /New \<%= t\(\".at0000\"\) %\>/ }
|
72
72
|
end
|
73
73
|
|
74
74
|
context 'invoke _form.html.erb template engine' do
|
75
75
|
subject { file('app/views/open_ehr_ehr_observation_blood_pressure_v1/_form.html.erb')}
|
76
76
|
|
77
|
-
it {
|
78
|
-
it {
|
79
|
-
it {
|
77
|
+
it { is_expected.to exist }
|
78
|
+
it { is_expected.to contain "f.select :at0013, t('.at0015') => 'at0015', t('.at0016') => 'at0016'"}
|
79
|
+
it { is_expected.to contain "<%= t('.at0006') %></strong>: <%= f.text_field :at0006 %>" }
|
80
80
|
end
|
81
81
|
|
82
82
|
context 'invoke routing generator' do
|
83
83
|
subject { file('config/routes.rb')}
|
84
84
|
|
85
|
-
it {
|
85
|
+
it { is_expected.to contain 'resources :open_ehr_ehr_observation_blood_pressure_v1'}
|
86
86
|
end
|
87
87
|
|
88
88
|
context 'Insert inflection setting' do
|
89
89
|
subject { file('config/initializers/inflections.rb') }
|
90
90
|
|
91
|
-
it {
|
91
|
+
it { is_expected.to contain 'inflect.uncountable %w( open_ehr_ehr_observation_blood_pressure_v1 )' }
|
92
92
|
end
|
93
93
|
|
94
94
|
context 'invoke assets generator' do
|
95
95
|
subject { file('app/assets/stylesheets/scaffold.css') }
|
96
96
|
|
97
|
-
it {
|
97
|
+
it { is_expected.to exist }
|
98
98
|
end
|
99
99
|
|
100
100
|
context 'i18n generator' do
|
101
101
|
subject { file('config/initializers/i18n.rb') }
|
102
102
|
|
103
|
-
it {
|
103
|
+
it { is_expected.to exist }
|
104
104
|
end
|
105
105
|
|
106
106
|
context 'add locale switcher to application.html.erb' do
|
107
107
|
subject { file('app/views/layouts/application.html.erb') }
|
108
108
|
|
109
|
-
it {
|
110
|
-
it {
|
111
|
-
it {
|
109
|
+
it { is_expected.to exist }
|
110
|
+
it { is_expected.to contain /\<%= select_tag 'locale',/ }
|
111
|
+
it { is_expected.to contain /options_for_select\(LANGUAGES, I18n\.locale.to_s\),/ }
|
112
112
|
end
|
113
113
|
|
114
114
|
context 'layout.css.scss' do
|
115
115
|
subject { file('app/assets/stylesheets/layout.css.scss') }
|
116
116
|
|
117
|
-
it {
|
118
|
-
it {
|
117
|
+
it { is_expected.to exist }
|
118
|
+
it { is_expected.to contain /\.locale {/ }
|
119
119
|
end
|
120
120
|
|
121
121
|
context 'invoke helper generator' do
|
122
122
|
subject { file('app/helpers/open_ehr_ehr_observation_blood_pressure_v1_helper.rb')}
|
123
123
|
|
124
|
-
it {
|
124
|
+
it { is_expected.to exist }
|
125
125
|
end
|
126
126
|
|
127
127
|
describe 'controller generator' do
|
128
128
|
subject { file('app/controllers/open_ehr_ehr_observation_blood_pressure_v1_controller.rb') }
|
129
129
|
|
130
|
-
it {
|
130
|
+
it { is_expected.to exist }
|
131
131
|
end
|
132
132
|
|
133
133
|
describe 'application controller modifier' do
|
134
134
|
subject { file('app/controllers/application_controller.rb') }
|
135
135
|
|
136
|
-
it {
|
137
|
-
it {
|
138
|
-
it {
|
139
|
-
it {
|
136
|
+
it { is_expected.to contain /before_action :set_locale/ }
|
137
|
+
it { is_expected.to contain /def set_locale/ }
|
138
|
+
it { is_expected.to contain /I18n\.locale = params\[:locale\] \|\| session\[:locale\] \|\| I18n\.default_locale/ }
|
139
|
+
it { is_expected.to contain /end$/ }
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|