Guest User

Untitled

a guest
Jun 26th, 2014
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. script that calls the tests:
  2. -----------------------------
  3. require 'rspec'
  4.  
  5. ...
  6. RSpec.shared_context "shared env attributes", :a => :b do
  7. let(:shared_attr) { {'environment' => env_attr} }
  8. end
  9. result = RSpec::Core::Runner.run(existing_test_files)
  10. ...
  11.  
  12. existing_test_files is an array of 2 files:
  13.  
  14.  
  15. testfile1:
  16. ------------------------------------------------------
  17. require 'serverspec'
  18. include Serverspec::Helper::Exec
  19. include Serverspec::Helper::DetectOS
  20.  
  21. RSpec.configure do |config|
  22. config.color = true
  23. config.formatter = :documentation
  24. end
  25.  
  26. describe 'recipe app::upgrade tests' do
  27.  
  28. context file('/user/app') do
  29. it { should be_directory }
  30. it { should be_mode 755 }
  31. it { should be_owned_by 'user-app' }
  32. end
  33. end
  34.  
  35. testfile2:
  36. ------------------------------------------------------
  37. contains the same like testfile1
  38.  
  39.  
  40. stdout -> testresults
  41. ----------------
  42. recipe app::upgrade tests
  43.  
  44. recipe app::upgrade tests
  45. File "/user/app"
  46. File "/user/app"
  47. should be directory
  48. should be directory
  49. should be mode 755
  50. should be mode 755
  51. should be owned by "user-app"
  52. should be owned by "user-app"
  53. ...
  54. problem: the test are called n times. In this case 2 times. If I add a third testfile each test of each file is called 3 times.
  55. Hint: Before this problem I had to move RSpec.configure from the calling script to the testfiles, to see the testresults
Advertisement
Add Comment
Please, Sign In to add comment