spec/models/stenographer/change_spec.rb in stenographer-rails-0.6.5 vs spec/models/stenographer/change_spec.rb in stenographer-rails-0.7.0

- old
+ new

@@ -68,14 +68,14 @@ expect(change.sanitize_environment).to eq('thing1, thing2') end end describe '#to_markdown' do - subject { create(:change, message: '# hello') } - it 'translates its message to markdown' do - expect(subject.to_markdown.strip).to eq('<h1>hello</h1>') + change = create(:change, message: '# hello') + + expect(change.to_markdown.strip).to eq('<h1>hello</h1>') end end describe '#matches_filters' do let!(:change) { create(:change) } @@ -93,11 +93,11 @@ end end describe 'has match' do describe 'normal field' do - before :each do + before do change.update(change_type: 'new') output.update(filters: { change_type: 'new' }.to_json) end it 'returns true' do @@ -105,22 +105,22 @@ end end describe 'environments' do describe 'matches last' do - before :each do + before do change.update(environments: 'florida, california') output.update(filters: { environments: 'california' }.to_json) end it 'returns true' do expect(change.matches_filters(output)).to be_truthy end end describe 'does not match if not last' do - before :each do + before do change.update(environments: 'california, florida') output.update(filters: { environments: 'california' }.to_json) end it 'returns true' do @@ -129,22 +129,22 @@ end end end describe 'has empty match' do - before :each do + before do change.update(environments: 'staging') output.update(filters: { environments: '' }.to_json) end it 'returns true' do expect(change.matches_filters(output)).to be_truthy end end describe 'no match' do - before :each do + before do change.update(environments: 'community') output.update(filters: { environments: 'the office' }.to_json) end it 'returns false' do @@ -194,66 +194,66 @@ describe 'has source id' do describe 'source id found' do let!(:existing_change) { create(:change, source_id: '#aol', environments: 'england') } it 'does not create a new change' do - expect { + expect do Stenographer::Change.create_or_update_by_source_id({ - subject: 'test', - message: 'test1', - source_id: '#aol', - visible: true, - environments: 'france', - tracker_ids: '1234', - source: {}.to_json - }) - }.not_to change(Stenographer::Change, :count) - end - - it 'adds to the changes environment' do - Stenographer::Change.create_or_update_by_source_id({ subject: 'test', message: 'test1', source_id: '#aol', visible: true, environments: 'france', tracker_ids: '1234', source: {}.to_json + }) + end.not_to change(Stenographer::Change, :count) + end + + it 'adds to the changes environment' do + Stenographer::Change.create_or_update_by_source_id({ + subject: 'test', + message: 'test1', + source_id: '#aol', + visible: true, + environments: 'france', + tracker_ids: '1234', + source: {}.to_json }) expect(existing_change.reload.environments).to eq('england, france') end end describe 'source id not found' do it 'creates a new change' do - expect { + expect do Stenographer::Change.create_or_update_by_source_id({ - subject: 'test', - message: 'test1', - source_id: '#14983989', - visible: true, - environments: 'test', - tracker_ids: '1234', - source: {}.to_json + subject: 'test', + message: 'test1', + source_id: '#14983989', + visible: true, + environments: 'test', + tracker_ids: '1234', + source: {}.to_json }) - }.to change(Stenographer::Change, :count).by(1) + end.to change(Stenographer::Change, :count).by(1) end end end describe 'no source id' do it 'creates a new change' do - expect { + expect do Stenographer::Change.create_or_update_by_source_id({ subject: 'test', message: 'test1', visible: true, environments: 'test', tracker_ids: '1234', source: {}.to_json }) - }.to change(Stenographer::Change, :count).by(1) + end.to change(Stenographer::Change, :count).by(1) end end end end end