Guest User

Untitled

a guest
Nov 21st, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. RSpec.describe 'Test Description' do
  2. attr_reader :result
  3.  
  4. before(:all)
  5. @result = build_result({some_parameters})
  6. end
  7.  
  8. context 'Some context' do
  9. it 'Looks lik a result' do
  10. expect(result.something).to ...
  11. end
  12.  
  13. it 'Feels lik a result' do
  14. expect(result.something).to ...
  15. end
  16. end
  17. end
  18.  
  19. RSpec.describe 'Test Description' do
  20. attr_reader :result
  21.  
  22. before(:all)
  23. @result = build_result({some_parameters})
  24. end
  25.  
  26. context 'Some context' do
  27. it_behaves_like "A result" result
  28. end
  29. end
  30.  
  31. RSpec.describe 'Test Description' do
  32. context 'for params x and y' do
  33. let(:expected_x) { 'x' }
  34. let(:expected_x) { 'y' }
  35.  
  36. subject { build_result({x: 'x', y: 'y'}) }
  37.  
  38. specify :aggregate_failures do
  39. expect(subject.x).to eq(expected_x)
  40. expect(subject.y).to eq(expected_y)
  41. end
  42. end
  43. end
  44.  
  45. shared_examples_for "A result" do |argument|
  46. # some tests with argument
  47. end
  48.  
  49. it_behaves_like "A result", my_argument
  50.  
  51. let(:result) { build_result({some_parameters}) }
  52.  
  53. describe '#type_id' do
  54. before { @resource = FactoryGirl.create :device }
  55. before { @type = Type.find @resource.type_id }
  56.  
  57. it 'sets the type_id field' do
  58. expect(@resource.type_id).to equal(@type.id)
  59. end
  60. end
  61.  
  62. describe '#type_id' do
  63. let(:resource) { FactoryGirl.create :device }
  64. let(:type) { Type.find resource.type_id }
  65.  
  66. it 'sets the type_id field' do
  67. expect(resource.type_id).to equal(type.id)
  68. end
  69. end
Add Comment
Please, Sign In to add comment