RevenueByLocationReport do describe "description" do it "returns a description of the reports purpose" do report = RevenueByLocationReport.new description = report.description expect(description).to eq("Forecasted billing amounts for each location") end end describe "headers" do it "returns descriptive headers" do report = RevenueByLocationReport.new headers = report.headers expect(headers).to eq(["Location", "Revenue Forecast"]) end end end 4
RevenueByProjectReport do describe "description" do it "returns a description of the reports purpose" do report = RevenueByProjectReport.new description = report.description expect(description).to eq("Forecasted billing amounts for each project") end end describe "headers" do it "returns descriptive headers" do report = RevenueByProjectReport.new headers = report.headers expect(headers).to eq(["Project", "Location", "Revenue Forecast"]) end end end 6
"description" do it "returns a description of the reports purpose" do # verify the description end end describe "headers" do it "returns descriptive headers" do # verify the headers end end end RSpec.describe RevenueByProjectReport do describe "description" do it "returns a description of the reports purpose" do # verify the description end end describe "headers" do it "returns descriptive headers" do # verify the headers end end end 7
RSpec.shared_examples "a report" do describe "description" do it "returns a String describing the reports purpose" do report = described_class.new expect(report.description).to be_a String end end describe "headers" do it "returns an Array of descriptive headers" do report = described_class.new expect(report.headers).to be_an Array expect(report.headers).to be_present end end end 8
do it "references the class being described" do puts described_class # => User puts described_class.new # => #<User:0x00007fe605872510> expect(described_class).to eq(User) # => true end end end 9
ng RSpec.describe "User" do describe "described_class" do it "references the described class" do puts described_class # => nil described_class.new # => undefined method on nil end end end 1
"implicit subject" do context "given a class" do it "sets the subject to an instance of the class" do puts subject.inspect #=> [] expect(subject).to be_empty end end end end 1
d h 4 S R (o h s a ) 4 L -e e 4 U o o -l s * 4 U o c m s *E o -l s : it { is_expected.to be true } L 4 m d h 4 S h s a 4 L -e e 4 u e r l 4 u c s a r b c e 1
RSpec.shared_examples "a report" do describe "description" do it "returns a String describing the reports purpose" do report = described_class.new expect(report.description).to be_a String end end describe "headers" do it "returns an Array of descriptive headers" do report = described_class.new expect(report.headers).to be_an Array expect(report.headers).to be_present end end end 1
fa to # spec/shared_examples/report_examples.rb RSpec.shared_examples "a report" do let(:report) { described_class.new } describe "description" do it "returns a String describing the reports purpose" do expect(report.description).to be_a String end end describe "headers" do it "returns an Array of descriptive headers" do expect(report.headers).to be_an Array expect(report.headers).to be_present end end end 1
"description" do it "returns a description of the reports purpose" do # verify the description end end describe "headers" do it "returns descriptive headers" do # verify the headers end end end RSpec.describe RevenueByProjectReport do describe "description" do it "returns a description of the reports purpose" do # verify the description end end describe "headers" do it "returns descriptive headers" do # verify the headers end end end 1
collection" (includes the examples in the current context) # RevenueByLocationReport # description # returns a String describing the reports purpose it_behaves_like "a collection" (includes the examples in a nested context) # RevenueByLocationReport # behaves like a report # description # returns a String describing the reports purpose 1
with markdown description" do describe "#description_html" do it "method exists" do record = described_class.new expect(record).to respond_to(:description_html) end end end 2
RSpec.describe Product do it_behaves_like "a record with a markdown description" end RSpec.describe Location do it_behaves_like "a record with a markdown description" end 2