puppet-repl 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8726c62a0923768b64cf07c7a4a020d331a6dbb4
4
- data.tar.gz: 483b212a7d21da6bc76264b2c4efae120b72ba74
3
+ metadata.gz: 4d8ce23921a5f416b32187a87b404f5175f4bd37
4
+ data.tar.gz: a510663097037ec81141e66552f253817cb6d9c3
5
5
  SHA512:
6
- metadata.gz: ee46f50573a316eb2f92a5bd4ff16af968ae691b3d39d1a5f26957d1a71c1f32d22a169df3a8f0511fd8e5a724290c6179484700d5b750d6b71c8e559eb11450
7
- data.tar.gz: 61f17a2d77901d5321a996c0fb4bbb0824fd088473ca0e733990d05b0036626c4c0c30168d3becda2384f31812b82d2364bd36a92a4cea2c9a2c35b4460fa6ad
6
+ metadata.gz: 125c9d2e1024849306165a4371d5468f39179c6adb660cbefe0801343111ae85bb25a1070b8f669893a8efc4d26cd34432192ac1d971bf7ae68c6c803d577b90
7
+ data.tar.gz: 48d7203e5f8db5a73cc76e4ce3b3be1af12b935955d24a349ef19379e961f36791366fb1fd7a650b818f705ed5092be2264d6095c554fa9206ba99cd9e2af4ac
data/.gitlab-ci.yml CHANGED
@@ -16,8 +16,6 @@ web_trigger_staging:
16
16
  type: web_deploy
17
17
  variables:
18
18
  REF: staging
19
- only:
20
- - tags
21
19
  script:
22
20
  - "curl -X POST -F token=$PREPL_BUILD_TRIGGER_TOKEN -F ref=$REF https://gitlab.com/api/v3/projects/1146764/trigger/builds"
23
21
 
@@ -25,6 +23,8 @@ web_trigger_production:
25
23
  type: web_deploy
26
24
  variables:
27
25
  REF: production
26
+ only:
27
+ - tags
28
28
  script:
29
29
  - "curl -X POST -F token=$PREPL_BUILD_TRIGGER_TOKEN -F ref=$REF https://gitlab.com/api/v3/projects/1146764/trigger/builds"
30
30
 
@@ -112,3 +112,9 @@ puppet_45_ruby22:
112
112
  PUPPET_GEM_VERSION: "~> 4.5"
113
113
  <<: *puppet_job_def
114
114
  <<: *ruby22
115
+
116
+ puppet_46_ruby22:
117
+ variables:
118
+ PUPPET_GEM_VERSION: "~> 4.6"
119
+ <<: *puppet_job_def
120
+ <<: *ruby22
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.3.1
2
+ * Fixes #28 - puppet 4.6 support
3
+ * Fixes #27 - repl should throw puppet error message instead of stacktrace
4
+ * adds support for customizing facterdb filter
5
+ * adds support for puppet 4.6
6
+ * Fixes #26 - allow configuration of facter version and facterdb filter
7
+
1
8
  ## 0.3.0
2
9
  * Fixes #23 - add quiet flag to suppress banner
3
10
  * Fixes #11 - cannot declare and use a class or define
@@ -5,8 +12,8 @@
5
12
  * fixes #21 - type display causes error
6
13
  ## 0.2.2
7
14
  * adds better support for playing back puppet code
8
- * this now allows playback of any manifest
9
- * allows mixed puppet code and repl commands
15
+ * this now allows playback of any manifest
16
+ * allows mixed puppet code and repl commands
10
17
  ## 0.2.1
11
18
  * Fixes #2 - adds support for multiline input
12
19
 
data/Gemfile CHANGED
@@ -4,6 +4,8 @@ gem 'facterdb', "~> 0.3"
4
4
  gem 'awesome_print', "~> 1.6"
5
5
 
6
6
  group :test do
7
+ # ruby versions prior to 2.0 cannot install json_pure 2.0.2+
8
+ gem 'json_pure', '<= 2.0.1'
7
9
  gem "rdoc", "~> 3.12"
8
10
  gem "rspec"
9
11
  gem "bundler"
data/Gemfile.lock CHANGED
@@ -2,49 +2,48 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  CFPropertyList (2.2.8)
5
- awesome_print (1.6.1)
5
+ awesome_print (1.7.0)
6
6
  coderay (1.1.1)
7
7
  diff-lcs (1.2.5)
8
8
  docile (1.1.5)
9
9
  facter (2.4.6)
10
10
  CFPropertyList (~> 2.2.6)
11
- facterdb (0.3.5)
11
+ facterdb (0.3.6)
12
12
  facter
13
13
  jgrep
14
- hiera (3.2.0)
15
- json_pure
14
+ hiera (3.2.1)
16
15
  jgrep (1.4.1)
17
16
  json
18
17
  json (1.8.3)
19
- json_pure (2.0.1)
18
+ json_pure (1.8.3)
20
19
  method_source (0.8.2)
21
- pry (0.10.3)
20
+ pry (0.10.4)
22
21
  coderay (~> 1.1.0)
23
22
  method_source (~> 0.8.1)
24
23
  slop (~> 3.4)
25
- puppet (4.5.2)
24
+ puppet (4.6.0)
26
25
  facter (> 2.0, < 4)
27
26
  hiera (>= 2.0, < 4)
28
- json_pure
29
- rake (11.1.2)
27
+ json_pure (~> 1.8)
28
+ rake (11.2.2)
30
29
  rdoc (3.12.2)
31
30
  json (~> 1.4)
32
- rspec (3.4.0)
33
- rspec-core (~> 3.4.0)
34
- rspec-expectations (~> 3.4.0)
35
- rspec-mocks (~> 3.4.0)
36
- rspec-core (3.4.4)
37
- rspec-support (~> 3.4.0)
38
- rspec-expectations (3.4.0)
31
+ rspec (3.5.0)
32
+ rspec-core (~> 3.5.0)
33
+ rspec-expectations (~> 3.5.0)
34
+ rspec-mocks (~> 3.5.0)
35
+ rspec-core (3.5.2)
36
+ rspec-support (~> 3.5.0)
37
+ rspec-expectations (3.5.0)
39
38
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.4.0)
41
- rspec-mocks (3.4.1)
39
+ rspec-support (~> 3.5.0)
40
+ rspec-mocks (3.5.0)
42
41
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.4.0)
44
- rspec-support (3.4.1)
45
- simplecov (0.11.2)
42
+ rspec-support (~> 3.5.0)
43
+ rspec-support (3.5.0)
44
+ simplecov (0.12.0)
46
45
  docile (~> 1.1.0)
47
- json (~> 1.8)
46
+ json (>= 1.8, < 3)
48
47
  simplecov-html (~> 0.10.0)
49
48
  simplecov-html (0.10.0)
50
49
  slop (3.6.0)
@@ -56,6 +55,7 @@ DEPENDENCIES
56
55
  awesome_print (~> 1.6)
57
56
  bundler
58
57
  facterdb (~> 0.3)
58
+ json_pure (<= 2.0.1)
59
59
  pry
60
60
  puppet (>= 3.8)
61
61
  rake
data/README.md CHANGED
@@ -199,7 +199,6 @@ pe specific modules in your development environment. Not doing this step will r
199
199
 
200
200
  ```
201
201
 
202
-
203
202
  ### Usage
204
203
  There are two ways of using the remote node feature. You can either
205
204
  pass in the node name from the command line or set the node name from the repl session.
@@ -223,6 +222,22 @@ Press the tab key to engage the auto complete functionality.
223
222
 
224
223
  Currently native functions are not available in auto complete. See #24
225
224
 
225
+ ## FacterDB and using different fact sets
226
+ The puppet-repl internally leverages the [facterdb](https://github.com/camptocamp/facterdb/) gem to load pre-cached facts into the repl session. At some point you
227
+ may need to override the repl's default fact set with something of your own choosing. You can do this by setting one of the environment variables below.
228
+
229
+ * `REPL_FACTERDB_FILTER` Sets the entire filter
230
+ * `REPL_FACTER_OS_VERSION` Sets the OS version (only works with RHEL clones and Fedora)
231
+ * `REPL_FACTER_OS_NAME` Sets the OS name (only works with RHEL clones and Fedora)
232
+ * `REPL_FACTER_VERSION` Sets the facter version to use in the repl session (uses facter 3.1 for puppet 4.4+ and facter 2.4 for 3.8-4.4)
233
+
234
+ By default it looks something like `operatingsystem=Fedora and operatingsystemrelease=23 and architecture=x86_64 and facterversion=/^3\\.1/`
235
+ depending on the puppet version currently running.
236
+
237
+ You can display the current facterdb filter by running `facterdb_filter` from the repl session.
238
+
239
+ Why do facter versions matter? While facter and puppet work independently just fine, newer forge modules utilize certain data structures found only in newer versions of facter. So its really up to the puppet code you use. With facter 3, almost every fact is now a data structure. So if you are having issues with facts not existing in the repl you may need to change the facter version `REPL_FACTER_VERSION` to something different.
240
+
226
241
  ## Playback support
227
242
  Puppet-repl now supports playing back files or urls and loading the content into the repl session. This means if you want to start a repl session from an existing file or url you can play the content back in the repl.
228
243
  You can also playback a file that contains puppet code and repl commands.
@@ -233,13 +248,14 @@ or
233
248
 
234
249
  `prepl -p https://gist.githubusercontent.com/logicminds/f9b1ac65a3a440d562b0/raw`
235
250
 
251
+ or just use STDIN `prepl <some_file>` or `echo "abs(-3)" | prepl`
236
252
 
237
253
  ### Web based playback support
238
254
  If using the [web based repl](https://www.puppet-repl.com) you can playback a shared url
239
255
  which would start a repl session and then load the content from the url or parameter.
240
256
 
241
257
  Example:
242
- https://murmuring-plateau-62715.herokuapp.com/play?url=https://gist.github.com/logicminds/64f0fe9f64339f18f097a9f42acd6276
258
+ https://puppet-repl.com/play?url=https://gist.github.com/logicminds/64f0fe9f64339f18f097a9f42acd6276
243
259
 
244
260
  or for single commands
245
261
 
@@ -95,7 +95,7 @@ module PuppetRepl
95
95
  begin
96
96
  output = ''
97
97
  case input
98
- when /^play|^classification|^facts|^vars|^functions|^classes|^resources|^krt|^environment|^reset|^help/
98
+ when /^play|^classification|^facterdb_filter|^facts|^vars|^functions|^classes|^resources|^krt|^environment|^reset|^help/
99
99
  args = input.split(' ')
100
100
  command = args.shift.to_sym
101
101
  if self.respond_to?(command)
@@ -126,6 +126,8 @@ module PuppetRepl
126
126
  output = e.message.fatal
127
127
  rescue Puppet::ResourceError => e
128
128
  output = e.message.fatal
129
+ rescue Puppet::Error => e
130
+ output = e.message.fatal
129
131
  rescue Puppet::ParseErrorWithIssue => e
130
132
  output = e.message.fatal
131
133
  rescue PuppetRepl::Exception::FatalError => e
@@ -79,19 +79,19 @@ module PuppetRepl
79
79
 
80
80
  def known_resource_types
81
81
  res = {
82
- :hostclasses => scope.known_resource_types.hostclasses.keys,
83
- :definitions => scope.known_resource_types.definitions.keys,
84
- :nodes => scope.known_resource_types.nodes.keys,
82
+ :hostclasses => scope.environment.known_resource_types.hostclasses.keys,
83
+ :definitions => scope.environment.known_resource_types.definitions.keys,
84
+ :nodes => scope.environment.known_resource_types.nodes.keys,
85
85
  }
86
- if sites = scope.known_resource_types.instance_variable_get(:@sites)
87
- res.merge!(:sites => scope.known_resource_types.instance_variable_get(:@sites).first)
86
+ if sites = scope.environment.known_resource_types.instance_variable_get(:@sites)
87
+ res.merge!(:sites => scope.environment.known_resource_types.instance_variable_get(:@sites).first)
88
88
  end
89
- if scope.known_resource_types.respond_to?(:applications)
90
- res.merge!(:applications => scope.known_resource_types.applications.keys)
89
+ if scope.environment.known_resource_types.respond_to?(:applications)
90
+ res.merge!(:applications => scope.environment.known_resource_types.applications.keys)
91
91
  end
92
92
  # some versions of puppet do not support capabilities
93
- if scope.known_resource_types.respond_to?(:capability_mappings)
94
- res.merge!(:capability_mappings => scope.known_resource_types.capability_mappings.keys)
93
+ if scope.environment.known_resource_types.respond_to?(:capability_mappings)
94
+ res.merge!(:capability_mappings => scope.environment.known_resource_types.capability_mappings.keys)
95
95
  end
96
96
  res
97
97
  end
@@ -141,7 +141,7 @@ module PuppetRepl
141
141
  ast = generate_ast(input)
142
142
  Puppet.override( {:global_scope => scope, :loaders => scope.compiler.loaders } , 'For puppet-repl') do
143
143
  # because the repl is not a module we leave the modname blank
144
- scope.known_resource_types.import_ast(ast, '')
144
+ scope.environment.known_resource_types.import_ast(ast, '')
145
145
  parser.evaluate_string(scope, input)
146
146
  end
147
147
  end
@@ -19,6 +19,12 @@ EOF
19
19
  end
20
20
  end
21
21
 
22
+ class BadFilter < FatalError
23
+ def message
24
+ data[:message]
25
+ end
26
+ end
27
+
22
28
  class UndefinedNode < FatalError
23
29
  def message
24
30
  out = <<-EOF
@@ -3,8 +3,35 @@ module PuppetRepl
3
3
  module Facts
4
4
  # in the future we will want to grab real facts from real systems via puppetdb
5
5
  # or enc data
6
- def facterdb_filter
7
- 'operatingsystem=RedHat and operatingsystemrelease=/^7/ and architecture=x86_64 and facterversion=/^2.4\./'
6
+
7
+ # allow the user to specify the facterdb filter
8
+ def dynamic_facterdb_filter
9
+ ENV['REPL_FACTERDB_FILTER'] || default_facterdb_filter
10
+ end
11
+
12
+ def default_facterdb_filter
13
+ "operatingsystem=#{facter_os_name} and operatingsystemrelease=#{facter_os_version} and architecture=x86_64 and facterversion=#{facter_version}"
14
+ end
15
+
16
+ def facter_version
17
+ ENV['REPL_FACTER_VERSION'] || default_facter_version
18
+ end
19
+
20
+ # return the correct supported version of facter facts
21
+ def default_facter_version
22
+ if Gem::Version.new(Puppet.version) >= Gem::Version.new(4.4)
23
+ '/^3\.1/'
24
+ else
25
+ '/^2\.4/'
26
+ end
27
+ end
28
+
29
+ def facter_os_name
30
+ ENV['REPL_FACTER_OS_NAME'] || 'Fedora'
31
+ end
32
+
33
+ def facter_os_version
34
+ ENV['REPL_FACTER_OS_VERSION'] || '23'
8
35
  end
9
36
 
10
37
  def set_facts(value)
@@ -14,18 +41,33 @@ module PuppetRepl
14
41
  # uses facterdb (cached facts) and retrives the facts given a filter
15
42
  # creates a new facts object
16
43
  # we could also use fact_merge to get real facts from the real system or puppetdb
44
+ def node_facts
45
+ node_facts = FacterDB.get_facts(dynamic_facterdb_filter).first
46
+ if node_facts.nil?
47
+ message = <<-EOS
48
+ Using filter: #{facterdb_filter}
49
+ Bad FacterDB filter, please change the filter so it returns a result set.
50
+ See https://github.com/camptocamp/facterdb/#with-a-string-filter
51
+ EOS
52
+ raise PuppetRepl::Exception::BadFilter.new(:message => message)
53
+ end
54
+ # fix for when --show-legacy facts are not part of the facter 3 fact set
55
+ node_facts[:fqdn] = node_facts[:networking].fetch('fqdn',nil) unless node_facts[:fqdn]
56
+ node_facts
57
+ end
58
+
17
59
  def default_facts
18
60
  unless @facts
19
- node_facts = FacterDB.get_facts(facterdb_filter).first
20
61
  values = Hash[ node_facts.map { |k, v| [k.to_s, v] } ]
21
- @facts ||= Puppet::Node::Facts.new(values['fqdn'], values)
62
+ name = values['fqdn']
63
+ @facts ||= Puppet::Node::Facts.new(name, values)
22
64
  end
23
65
  @facts
24
66
  end
25
67
 
26
68
  def server_facts
27
69
  data = {}
28
- data["servername"] = Facter.value("fqdn")
70
+ data["servername"] = Facter.value("fqdn") || Facter.value('networking')['fqdn']
29
71
  data['serverip'] = Facter.value("ipaddress")
30
72
  data["serverversion"] = Puppet.version.to_s
31
73
  data
@@ -3,11 +3,15 @@ module PuppetRepl
3
3
  module InputResponders
4
4
 
5
5
  def static_responder_list
6
- ["exit", "functions", "classification","vars", "krt", "facts",
6
+ ["exit", "functions", "classification","vars", 'facterdb_filter', "krt", "facts",
7
7
  "resources", "classes", "play","reset", "help"
8
8
  ]
9
9
  end
10
10
 
11
+ def facterdb_filter(args=[])
12
+ dynamic_facterdb_filter.ai
13
+ end
14
+
11
15
  def help(args=[])
12
16
  PuppetRepl::Cli.print_repl_desc
13
17
  end
@@ -18,7 +18,8 @@ module PuppetRepl
18
18
  options[:facts] = default_facts
19
19
  options[:classes] = []
20
20
  options[:environment] = puppet_environment
21
- node_obj = Puppet::Node.new(default_facts.values['fqdn'], options)
21
+ name = default_facts.values['fqdn']
22
+ node_obj = Puppet::Node.new(name, options)
22
23
  node_obj.add_server_facts(server_facts) if node_obj.respond_to?(:add_server_facts)
23
24
  node_obj
24
25
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PuppetRepl
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'facts' do
4
+ let(:repl) do
5
+ PuppetRepl::Cli.new(:out_buffer => output)
6
+ end
7
+
8
+ let(:puppet_version) do
9
+ '4.5.3'
10
+ end
11
+
12
+ let(:facter_version) do
13
+ repl.default_facter_version
14
+ end
15
+
16
+ before(:each) do
17
+ allow(Puppet).to receive(:version).and_return(puppet_version)
18
+ end
19
+
20
+ describe '2.4' do
21
+ before(:each) do
22
+ ENV['REPL_FACTERDB_FILTER'] = nil
23
+ end
24
+ let(:puppet_version) do
25
+ '4.2.0'
26
+ end
27
+ it 'returns 2.4' do
28
+ expect(facter_version).to eq('/^2\.4/')
29
+ end
30
+ it 'return default filter' do
31
+ expect(repl.dynamic_facterdb_filter).to eq("operatingsystem=Fedora and operatingsystemrelease=23 and architecture=x86_64 and facterversion=/^2\\.4/")
32
+ end
33
+ it 'get node_facts' do
34
+ expect(repl.node_facts).to be_instance_of(Hash)
35
+ end
36
+ it 'has fqdn' do
37
+ expect(repl.node_facts[:fqdn]).to eq('foo.example.com')
38
+ end
39
+ end
40
+
41
+ describe '3.1' do
42
+ before(:each) do
43
+ ENV['REPL_FACTERDB_FILTER'] = nil
44
+ end
45
+ let(:puppet_version) do
46
+ '4.5.3'
47
+ end
48
+ it 'get node_facts' do
49
+ expect(repl.node_facts).to be_instance_of(Hash)
50
+ end
51
+ it 'has networking fqdn' do
52
+ expect(repl.node_facts[:networking]['fqdn']).to eq('foo.example.com')
53
+ end
54
+ it 'has fqdn' do
55
+ expect(repl.node_facts[:fqdn]).to eq('foo.example.com')
56
+ end
57
+ it 'returns 3.1' do
58
+ expect(facter_version).to eq('/^3\.1/')
59
+ end
60
+ it 'return default filter' do
61
+ expect(repl.dynamic_facterdb_filter).to eq("operatingsystem=Fedora and operatingsystemrelease=23 and architecture=x86_64 and facterversion=/^3\\.1/")
62
+ end
63
+ end
64
+
65
+ describe 'default facts' do
66
+ describe 'bad filter' do
67
+ before(:each) do
68
+ ENV['REPL_FACTERDB_FILTER'] = 'facterversion=/^6\.5/'
69
+ end
70
+ it 'return filter' do
71
+ expect(repl.dynamic_facterdb_filter).to eq("facterversion=/^6\\.5/")
72
+ end
73
+ it 'throws error' do
74
+ expect{repl.default_facts}.to raise_error(PuppetRepl::Exception::BadFilter)
75
+ end
76
+ end
77
+ describe 'good filter' do
78
+ before(:each) do
79
+ ENV['REPL_FACTERDB_FILTER'] = 'facterversion=/^3\.1/'
80
+ end
81
+ it 'return filter' do
82
+ expect(repl.dynamic_facterdb_filter).to eq("facterversion=/^3\\.1/")
83
+ end
84
+ end
85
+ end
86
+ end
@@ -37,19 +37,17 @@ describe "PuppetRepl" do
37
37
  it do
38
38
  repl.handle_input(input)
39
39
  expect(output.string).to eq("\n")
40
- expect(repl.scope.known_resource_types.hostclasses).to include('testfoo')
40
+ expect(repl.known_resource_types[:hostclasses]).to include('testfoo')
41
41
  end
42
42
  it do
43
43
  repl.handle_input(input)
44
- repl.handle_input("class{'testfoo':}")
44
+ repl.handle_input("include testfoo")
45
45
  expect(repl.scope.compiler.catalog.classes).to include('testfoo')
46
- # expect(output.string).to include("\n => Puppet::Type::Component")
47
- # expect(output.string).to include("name => \"Testfoo\"")
48
46
  end
49
47
  it do
50
48
  repl.handle_input(input)
51
- repl.handle_input("include testfoo")
52
- expect(repl.scope.compiler.catalog.classes).to include('testfoo')
49
+ repl.handle_input('include testfoo')
50
+ expect(repl.scope.compiler.catalog.resources.map(&:name)).to include('Testfoo')
53
51
  end
54
52
  end
55
53
  end
@@ -64,7 +62,7 @@ describe "PuppetRepl" do
64
62
  end
65
63
  it do
66
64
  repl.handle_input(input)
67
- expect(repl.scope.known_resource_types.definitions.keys).to include('testfoo')
65
+ expect(repl.scope.environment.known_resource_types.definitions.keys).to include('testfoo')
68
66
  expect(output.string).to eq("\n")
69
67
  end
70
68
  it do
@@ -428,10 +426,7 @@ describe "PuppetRepl" do
428
426
  repl.handle_input("$var1")
429
427
  expect(output.string).to match(/value1/)
430
428
  end
431
- it 'display productname variable' do
432
- repl.handle_input("$productname")
433
- expect(output.string).to match(/VirtualBox/)
434
- end
429
+
435
430
  end
436
431
 
437
432
  describe 'execute functions' do
@@ -450,30 +445,25 @@ describe "PuppetRepl" do
450
445
  end
451
446
  end
452
447
 
453
- # this code no longer works in puppet 4.5+
454
- # describe 'unidentified object' do
455
- # let(:repl_output) { "\n" }
456
- # describe "Node['foot']" do
457
- # let(:input) { subject }
458
- # it 'returns string' do
459
- # repl.handle_input(input)
460
- # expect(output.string).to eq(repl_output)
461
- # end
462
- # end
463
- # describe "Puppet::Pops::Types::PStringType" do
464
- # let(:input) { subject }
465
- # it 'returns string' do
466
- # repl.handle_input(input)
467
- # expect(output.string).to eq(repl_output)
468
- # end
469
- # end
470
- # describe 'Facts' do
471
- # let(:input) { subject }
472
- # it 'returns string' do
473
- # repl.handle_input(input)
474
- # expect(output.string).to eq(repl_output)
475
- # end
476
- # end
477
- # end
448
+ describe 'error message' do
449
+ let(:input) do
450
+ "file{'/tmp/test': ensure => present, contact => 'blah'}"
451
+ end
452
+ p_version = ENV['PUPPET_GEM_VERSION'].split(' ').last
453
+ if Gem::Version.new(p_version) >= Gem::Version.new('4.0')
454
+ it 'show error message' do
455
+ repl_output = /no\ parameter\ named\ 'contact'/
456
+ repl.handle_input(input)
457
+ expect(output.string).to match(repl_output)
458
+ end
459
+ else
460
+ it 'show error message' do
461
+ repl_output = /Invalid\ parameter\ contact/
462
+ repl.handle_input(input)
463
+ expect(output.string).to match(repl_output)
464
+ end
465
+ end
466
+
467
+ end
478
468
 
479
469
  end
data/spec/spec_helper.rb CHANGED
@@ -25,7 +25,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
25
25
 
26
26
  require 'rspec'
27
27
  require 'puppet-repl'
28
-
28
+ ENV['REPL_FACTERDB_FILTER'] = "operatingsystem=Fedora and operatingsystemrelease=23 and architecture=x86_64 and facterversion=/^2\\.4/"
29
29
  # Requires supporting files with custom matchers and macros, etc,
30
30
  # in ./support/ and its subdirectories.
31
31
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-repl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Osman
@@ -104,6 +104,7 @@ files:
104
104
  - lib/version.rb
105
105
  - puppet-repl.gemspec
106
106
  - run_container_test.sh
107
+ - spec/facts_spec.rb
107
108
  - spec/fixtures/environments/production/manifests/site.pp
108
109
  - spec/fixtures/invalid_node_obj.yaml
109
110
  - spec/fixtures/node_obj.yaml