1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
|
RSpec.describe 'Weirdness' do
subject! { nil }
subject { nil }
subject(:foo) { nil }
subject!(:foo) { nil }
subject! (:foo) { |something| nil }
subject :foo do end
let(:foo) { |something| something }
let (:foo) { 1 }
let! (:bar){}
bar = -> {}
let(:foo, &bar)
let :a do end
let(:bar) { <<-HEREDOC }
What a pain.
HEREDOC
let(:bar) { <<-'HEREDOC' }
Even odder.
HEREDOC
let(:baz) do
<<-INSIDE
Hi. I'm in your lets.
INSIDE
end
let(:hi) {}
let(:bye) do
end
let(:doop) { foo; 1 }
let('foo') { 1 }
let('foo' \
'bar') { 1 }
let!('foo') { 1 }
let!('foo' \
'bar') { 1 }
let("foo#{1}") { 1 }
let!("foo#{1}") { 1 }
it {}
specify {}
it 'works', metadata: true do
end
describe {}
context {}
describe '#nothing' do
end
it 'is empty' do
end
it '' do end
describe do end
context do end
shared_examples 'a' do end
describe 'things' do
context 'with context' do
end
end
shared_examples 'weird rspec' do
end
shared_examples :something do
end
context 'test' do
include_examples 'weird rspec'
include_examples('weird rspec', serious: true) do
it_behaves_like :something
end
end
it_behaves_like :something
it_should_behave_like :something if RSpec::Core::Version::STRING < '4.0'
it_behaves_like :something do
let(:foo) { 'bar' }
end
it_behaves_like(:something) do |arg, *args, &block|
end
before {}
context 'never run' do
around {}
end
after {}
before { <<-DOC }
Eh, what's up?
DOC
around { |test| test.run; <<-DOC }
Eh, what's up?
DOC
after { <<-DOC }
Eh, what's up?
DOC
around do |test|
test.run
end
it 'is expecting you' do
expect('you').to eql('you')
end
it 'is expecting you not to raise an error' do
expect { 'you' }.not_to raise_error
end
it 'has chained expectations' do
expect('you').to eql('you').and(match(/y/))
end
%w[who likes dynamic examples].each do |word|
let(word) { word }
describe "#{word}" do
context "#{word}" do
it "lets the word '#{word}' be '#{word}'" do
expect(send(word)).to eql(word)
end
end
end
end
it { foo; 1 && 2}
it('has a description too') { foo; 1 && 2}
it %{quotes a string weird} do
end
it((' '.strip! ; 1 && 'isnt a simple string')) do
expect(nil).to be(nil)
end
it((' '.strip! ; 1 && 'isnt a simple string')) do
double = double(:foo)
allow(double).to receive(:oogabooga).with(nil).and_return(nil)
expect(double.oogabooga(nil)).to be(nil)
expect(double).to have_received(:oogabooga).once
end
it 'uses a matcher' do
expect([].empty?).to be(true)
expect([]).to be_empty
end
let(:klass) do
Class.new do
def initialize(thing)
@thing = thing
end
def announce
'wooo, so dynamic!'
end
end
end
it 'it does a thing' do
end
it 'It does a thing' do
end
it 'should not do the thing' do
end
specify do
foo = double(:bar)
allow(foo).to receive_message_chain(bar: 42, baz: 42)
allow(foo).to receive(:bar)
allow(foo).to receive_messages(bar: 42, baz: 42)
end
end
RSpec.describe {}
RSpec.shared_examples('pointless') {}
RSpec.shared_context('even pointless-er') {}
RSpec.describe do end
RSpec.shared_examples('pointless2') do end
RSpec.shared_context('even pointless-er2') do end
RSpec.describe
RSpec.describe 'empty'
class Broken
end
RSpec.describe Broken do
end
RSpec.describe 'RubocopBug' do
subject { true }
before do
each_row = allow(double(:exporter)).to receive(:each_row)
[1, 2].each do |sig|
each_row = each_row.and_yield(sig)
end
end
it 'has a single example' do
expect(subject).to be_truthy
end
it 'has an expectation' do
stats = double(event: nil)
stats.event('tada!')
expect(stats)
.to have_received(:event)
.with('tada!')
end
end
RSpec.describe do
let(:uh_oh) { <<-HERE.strip + ", #{<<-THERE.strip}" }
Seriously
HERE
who designed these things?
THERE
it 'is insane' do
expect(uh_oh).to eql('Seriously, who designed these things?')
end
end
|