[PATCH conductor 1/7] Moves common shared examples for provider accounts API to their own file

pblaho at redhat.com pblaho at redhat.com
Wed Aug 15 17:11:24 UTC 2012


From: Petr Blaho <pblaho at redhat.com>

---
 .../provider_accounts_controller_spec.rb           |   34 --------------------
 .../shared_examples_for_provider_accounts_api.rb   |   34 ++++++++++++++++++++
 2 files changed, 34 insertions(+), 34 deletions(-)
 create mode 100644 src/spec/support/shared_examples_for_provider_accounts_api.rb

diff --git a/src/spec/controllers/provider_accounts_controller_spec.rb b/src/spec/controllers/provider_accounts_controller_spec.rb
index 0ba2c0b..456aedb 100644
--- a/src/spec/controllers/provider_accounts_controller_spec.rb
+++ b/src/spec/controllers/provider_accounts_controller_spec.rb
@@ -20,40 +20,6 @@ describe ProviderAccountsController do
 
   render_views
 
-  shared_examples_for "having XML with provider accounts" do
-    # TODO: implement more attributes checks
-    subject { Nokogiri::XML(response.body) }
-    context "list of provider accounts" do
-      let(:xml_provider_accounts) { subject.xpath('//provider_accounts/provider_account') }
-      context "number of provider accounts" do
-        it { xml_provider_accounts.size.should be_eql(number_of_provider_accounts) }
-      end
-      it "should have correct provider accounts" do
-        provider_accounts.each do |provider_account|
-          xml_provider_account = xml_provider_accounts.xpath("//provider_account[@id=\"#{provider_account.id}\"]")
-          xml_provider_account.xpath('name').text.should be_eql(provider_account.name.to_s)
-          xml_provider_account.xpath('@href').text.should be_eql(api_provider_account_url(provider_account))
-        end
-      end
-      it "should have not incorrect provider accounts" do
-        other_provider_accounts.each do |provider_account|
-          xml_provider_account = xml_provider_accounts.xpath("//provider_account[@id=\"#{provider_account.id}\"]")
-          xml_provider_account.should be_empty
-        end
-      end
-    end
-  end
-
-  shared_examples_for "having correct set of credentials" do
-    it "should be correct" do
-      provider_account.credentials.each do |credential|
-        label = credential.credential_definition.label
-        value = credential.value
-        xml_provider_account.xpath('//' + label).text.should be_eql(value)
-      end
-    end
-  end
-
   context "UI" do
 
     fixtures :all
diff --git a/src/spec/support/shared_examples_for_provider_accounts_api.rb b/src/spec/support/shared_examples_for_provider_accounts_api.rb
new file mode 100644
index 0000000..bf436ee
--- /dev/null
+++ b/src/spec/support/shared_examples_for_provider_accounts_api.rb
@@ -0,0 +1,34 @@
+
+shared_examples_for "having XML with provider accounts" do
+  # TODO: implement more attributes checks
+  subject { Nokogiri::XML(response.body) }
+  context "list of provider accounts" do
+    let(:xml_provider_accounts) { subject.xpath('//provider_accounts/provider_account') }
+    context "number of provider accounts" do
+      it { xml_provider_accounts.size.should be_eql(number_of_provider_accounts) }
+    end
+    it "should have correct provider accounts" do
+      provider_accounts.each do |provider_account|
+        xml_provider_account = xml_provider_accounts.xpath("//provider_account[@id=\"#{provider_account.id}\"]")
+        xml_provider_account.xpath('name').text.should be_eql(provider_account.name.to_s)
+        xml_provider_account.xpath('@href').text.should be_eql(api_provider_account_url(provider_account))
+      end
+    end
+    it "should have not incorrect provider accounts" do
+      other_provider_accounts.each do |provider_account|
+        xml_provider_account = xml_provider_accounts.xpath("//provider_account[@id=\"#{provider_account.id}\"]")
+        xml_provider_account.should be_empty
+      end
+    end
+  end
+end
+
+shared_examples_for "having correct set of credentials" do
+  it "should be correct" do
+    provider_account.credentials.each do |credential|
+      label = credential.credential_definition.label
+      value = credential.value
+      xml_provider_account.xpath('//' + label).text.should be_eql(value)
+    end
+  end
+end
-- 
1.7.7.6




More information about the aeolus-devel mailing list