spec/lib/rambo_spec.rb in rambo_ruby-0.2.0 vs spec/lib/rambo_spec.rb in rambo_ruby-0.2.1
- old
+ new
@@ -5,15 +5,15 @@
rails: false
EOF
end
describe ".generate_contract_tests!" do
- let(:valid_file) { File.join(SPEC_DIR_ROOT, "support/foobar.raml") }
+ let(:valid_file) { "foobar.raml" }
let(:default_options) { { rails: true } }
before(:each) do
- allow(Dir).to receive(:foreach).and_return(valid_file)
+ allow(Dir).to receive(:[]).and_return([valid_file])
end
context "in all cases" do
it "generates documents" do
expect(Rambo::DocumentGenerator).to receive(:generate!).with(valid_file, default_options)
@@ -37,18 +37,51 @@
end
it "sets the RAML file to the one from the file" do
expect(Rambo::DocumentGenerator)
.to receive(:generate!)
- .with(File.expand_path("doc/raml/foobar.raml"), { "raml" => File.expand_path("doc/raml/foobar.raml"), "rails" => false })
+ .with(File.expand_path("doc/raml/foobar.raml"), { rails: false })
Rambo.generate_contract_tests!
end
+
+ context "rails option set to false in file" do
+ it "sets rails option to false" do
+ allow(Rambo).to receive(:yaml_options).and_return({ rails: false })
+ expect(Rambo::DocumentGenerator)
+ .to receive(:generate!)
+ .with(File.expand_path("doc/raml/foobar.raml"), { rails: false })
+ Rambo.generate_contract_tests!
+ end
+ end
+
+ context "rails option set to true in file" do
+ it "sets rails option to true" do
+ allow(Rambo).to receive(:yaml_options).and_return({ rails: true })
+ expect(Rambo::DocumentGenerator)
+ .to receive(:generate!)
+ .with(File.expand_path("doc/raml/foobar.raml"), { rails: true })
+ Rambo.generate_contract_tests!
+ end
+ end
+
+ context "rails option not set in file" do
+ it "sets rails option to true" do
+ allow(Rambo).to receive(:yaml_options).and_return({})
+ expect(Rambo::DocumentGenerator)
+ .to receive(:generate!)
+ .with(File.expand_path("doc/raml/foobar.raml"), { rails: true })
+ Rambo.generate_contract_tests!
+ end
+ end
end
context "when there is no .rambo.yml file" do
it "uses default options" do
- expect(Rambo::DocumentGenerator).to receive(:generate!).with(valid_file, default_options)
+ expect(Rambo::DocumentGenerator)
+ .to receive(:generate!)
+ .with(File.expand_path("doc/raml/#{valid_file}"), default_options)
+
Rambo.generate_contract_tests!
end
end
end
end