rambo_ruby 0.2.0 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0cce940ea2b21f4db0e40bdc31be6e8c8193b0bb
4
- data.tar.gz: d44fe75445872974782a1d0f79b5da966175897d
3
+ metadata.gz: f09eb183f2b9312be39e5780bfb21b0adddb54ed
4
+ data.tar.gz: 77a07451629ce56a2d8b9cc168f254a1bfa06437
5
5
  SHA512:
6
- metadata.gz: 349fbeddb405567e4276791a1b6682c950a56164403a14f4a788ae3afe546c80c09e654e0ce1155f5df0ae8c8dbeb03f849686eaa2c5bf5cfb4327666af39996
7
- data.tar.gz: 355b9f9c0604387b3d4640a853d68bd2cedfbd60016a74d6b9ba3e765ef869550fa0cd7b842af9d7572ce42512ee50f0e46d92991e4eb486b48d708021b06362
6
+ metadata.gz: b9d9bb934fa6db09a6b241b061ef6cf723ad8c3f532394367af25aa596a941fecabf5f734415c28b7ab81c45c40211809c44972e5fd132e81273e2997194a686
7
+ data.tar.gz: 550b5fdef3cfab2337dee2845694352bebe9b71fba814465ecc4c61a9fad13a02cbf751aefcd1624003efdf4aa6f240cc3fd9683e567f249f292575b0b1c6ec2
data/README.md CHANGED
@@ -73,6 +73,8 @@ The two possible keys are:
73
73
  to the root of your project directory, is `doc/raml/foobar.raml`, where `foobar.raml` is the first RAML file found in the `doc/raml` directory.
74
74
  - `rails` - specifies whether your app is a Rails app. The default value is `true`.
75
75
 
76
+ If a `.rambo.yml` file is present and additional options are passed in, the option values that are passed in will override those in the `.rambo.yml` file.
77
+
76
78
  ## Default Behavior
77
79
  In order to provide the best user experience to a majority of users, Rambo comes with some sensible defaults that are easily overridden in an optional `.rambo.yml` file, or by using command line flags or a Ruby option hash (see above).
78
80
 
data/bin/rambo CHANGED
@@ -4,7 +4,7 @@ lib = File.expand_path("../../lib", __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  require "fileutils"
7
- require "rambo/cli"
7
+ require "cli"
8
8
  require "optparse"
9
9
 
10
10
  filename = ARGV[0] ? File.expand_path(ARGV[0], FileUtils.pwd) : nil
@@ -1,5 +1,5 @@
1
1
  require "colorize"
2
- require "rambo/document_generator"
2
+ require "rambo"
3
3
 
4
4
  module Rambo
5
5
  class CLI
@@ -16,7 +16,7 @@ module Rambo
16
16
  print_logo
17
17
 
18
18
  begin
19
- Rambo::DocumentGenerator.generate!(file, options)
19
+ Rambo.generate_contract_tests!(file, options)
20
20
 
21
21
  stdout.puts("Generating contract tests...")
22
22
  sleep 0.4
@@ -53,7 +53,7 @@ module Rambo
53
53
  end
54
54
 
55
55
  def logo
56
- File.read(File.expand_path("../../../assets/logo.txt", __FILE__))
56
+ File.read(File.expand_path("../../assets/logo.txt", __FILE__))
57
57
  end
58
58
  end
59
59
  end
data/lib/rambo.rb CHANGED
@@ -1,12 +1,15 @@
1
+ require "active_support/core_ext/hash"
2
+
1
3
  Dir["#{File.dirname(__FILE__)}/rambo/**/*.rb"].each {|file| require file }
2
4
 
3
5
  module Rambo
4
6
  class << self
5
7
  attr_reader :options, :file
6
8
 
7
- def generate_contract_tests!(file = nil, opts = nil)
8
- @options = opts || yaml_options
9
- @file = file || @options.fetch(:raml, nil) || raml_file
9
+ def generate_contract_tests!(file = nil, opts = {})
10
+ @options = yaml_options.merge(opts)
11
+ @options[:rails] = true unless @options.fetch(:rails, nil) == false
12
+ @file = file || @options.delete(:raml) || raml_file
10
13
 
11
14
  DocumentGenerator.generate!(@file, @options)
12
15
  end
@@ -14,10 +17,10 @@ module Rambo
14
17
  private
15
18
 
16
19
  def yaml_options
17
- opts = YAML.load(File.read(File.expand_path(".rambo.yml")))
20
+ opts = YAML.load(File.read(File.expand_path(".rambo.yml"))).symbolize_keys
18
21
 
19
- if opts && opts.fetch("raml", nil)
20
- opts["raml"] = File.expand_path(opts.fetch("raml"))
22
+ if opts && opts.fetch(:raml, nil)
23
+ opts[:raml] = File.expand_path(opts.fetch(:raml))
21
24
  end
22
25
 
23
26
  opts
@@ -29,8 +32,10 @@ module Rambo
29
32
  # the first one it finds in the "doc" directory.
30
33
 
31
34
  def raml_file
32
- return options.fetch("raml") if options && options.fetch("raml", nil)
33
- Dir.foreach("doc/raml") {|file| return "doc/raml/#{file}" if file.match(/\.raml$/) }
35
+ return options.fetch(:raml) if options && options.fetch(:raml, nil)
36
+
37
+ raml_path = File.expand_path("doc/raml")
38
+ Dir[raml_path].each {|file| return File.join(raml_path, file) if file.match(/\.raml$/) }
34
39
  end
35
40
  end
36
41
  end
data/lib/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Rambo
2
2
  MAJOR = '0'
3
3
  MINOR = '2'
4
- PATCH = '0'
4
+ PATCH = '1'
5
5
 
6
6
  def self.version
7
7
  [Rambo::MAJOR, Rambo::MINOR, Rambo::PATCH].join('.')
data/rambo_ruby.gemspec CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.add_dependency "json_test_data", "~> 1.1", ">= 1.1.1"
19
19
  s.add_dependency "json-schema", "~> 2.6"
20
20
  s.add_dependency "rake", "~> 11.0"
21
+ s.add_dependency "activesupport", "~> 4.0"
21
22
 
22
23
  s.add_development_dependency "cucumber", "~> 2.1"
23
24
  s.add_development_dependency "json", "~> 1.7"
@@ -7,11 +7,11 @@ rails: false
7
7
  end
8
8
 
9
9
  describe ".generate_contract_tests!" do
10
- let(:valid_file) { File.join(SPEC_DIR_ROOT, "support/foobar.raml") }
10
+ let(:valid_file) { "foobar.raml" }
11
11
  let(:default_options) { { rails: true } }
12
12
 
13
13
  before(:each) do
14
- allow(Dir).to receive(:foreach).and_return(valid_file)
14
+ allow(Dir).to receive(:[]).and_return([valid_file])
15
15
  end
16
16
 
17
17
  context "in all cases" do
@@ -39,15 +39,48 @@ rails: false
39
39
  it "sets the RAML file to the one from the file" do
40
40
  expect(Rambo::DocumentGenerator)
41
41
  .to receive(:generate!)
42
- .with(File.expand_path("doc/raml/foobar.raml"), { "raml" => File.expand_path("doc/raml/foobar.raml"), "rails" => false })
42
+ .with(File.expand_path("doc/raml/foobar.raml"), { rails: false })
43
43
 
44
44
  Rambo.generate_contract_tests!
45
45
  end
46
+
47
+ context "rails option set to false in file" do
48
+ it "sets rails option to false" do
49
+ allow(Rambo).to receive(:yaml_options).and_return({ rails: false })
50
+ expect(Rambo::DocumentGenerator)
51
+ .to receive(:generate!)
52
+ .with(File.expand_path("doc/raml/foobar.raml"), { rails: false })
53
+ Rambo.generate_contract_tests!
54
+ end
55
+ end
56
+
57
+ context "rails option set to true in file" do
58
+ it "sets rails option to true" do
59
+ allow(Rambo).to receive(:yaml_options).and_return({ rails: true })
60
+ expect(Rambo::DocumentGenerator)
61
+ .to receive(:generate!)
62
+ .with(File.expand_path("doc/raml/foobar.raml"), { rails: true })
63
+ Rambo.generate_contract_tests!
64
+ end
65
+ end
66
+
67
+ context "rails option not set in file" do
68
+ it "sets rails option to true" do
69
+ allow(Rambo).to receive(:yaml_options).and_return({})
70
+ expect(Rambo::DocumentGenerator)
71
+ .to receive(:generate!)
72
+ .with(File.expand_path("doc/raml/foobar.raml"), { rails: true })
73
+ Rambo.generate_contract_tests!
74
+ end
75
+ end
46
76
  end
47
77
 
48
78
  context "when there is no .rambo.yml file" do
49
79
  it "uses default options" do
50
- expect(Rambo::DocumentGenerator).to receive(:generate!).with(valid_file, default_options)
80
+ expect(Rambo::DocumentGenerator)
81
+ .to receive(:generate!)
82
+ .with(File.expand_path("doc/raml/#{valid_file}"), default_options)
83
+
51
84
  Rambo.generate_contract_tests!
52
85
  end
53
86
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rambo_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Scheider
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-11 00:00:00.000000000 Z
11
+ date: 2016-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -100,6 +100,20 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '11.0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: activesupport
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '4.0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '4.0'
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: cucumber
105
119
  requirement: !ruby/object:Gem::Requirement
@@ -200,8 +214,8 @@ files:
200
214
  - features/support/examples/rspec/spec_helper_only_rack_test.rb.example
201
215
  - features/support/examples/rspec/spec_helper_rack_test_added.rb.example
202
216
  - features/support/foobar.raml
217
+ - lib/cli.rb
203
218
  - lib/rambo.rb
204
- - lib/rambo/cli.rb
205
219
  - lib/rambo/document_generator.rb
206
220
  - lib/rambo/rake.rb
207
221
  - lib/rambo/rake/task.rb
@@ -265,10 +279,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
279
  version: '0'
266
280
  requirements: []
267
281
  rubyforge_project:
268
- rubygems_version: 2.4.6
282
+ rubygems_version: 2.5.1
269
283
  signing_key:
270
284
  specification_version: 4
271
- summary: rambo_ruby-0.2.0
285
+ summary: rambo_ruby-0.2.1
272
286
  test_files:
273
287
  - features/create_files.feature
274
288
  - features/error_modes.feature
@@ -318,4 +332,3 @@ test_files:
318
332
  - spec/support/foobar.yml
319
333
  - spec/support/multiple_resources.raml
320
334
  - spec/support/post_with_request_headers.raml
321
- has_rdoc: