SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
Chiew Chung        @theworldinunion
Edward Middleton   @e14n
'rspec/core/rake_task'
RSpec.configure do |c|
   # ....




command line
./.rspec
~/.rspec
describe "something" do
 context "in some context" do
  it "does something" do
    # ...
  end
 end
end
# in spec/spec_helper.rb
RSpec.configure do |c|
 c.filter_run :focus => true
end

# in any spec file
describe "something" do
 it "does something", :focus => true do
   # ....
 end
end
RSpec.configure do |c|
 c.filter_run :focus => true
 c.run_all_when_everything_filtered = true
end
# in spec/spec_helper.rb
RSpec.configure do |c|
 c.exclusion_filter = { :ruby => lambda {|version|
  !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
 }}
end

# in any spec file
describe "something" do
 it "does something", :ruby => 1.8 do
   # ....
 end

 it "does something", :ruby => 1.9 do
   # ....
 end
end
actual.should == expected # object equality
actual.should equal(expected) # object identity




actual.should eq(expected) # object equality
actual.should be(expected) # object identity
def eat_cheese
 simple_matcher("eat cheese") do |actual|
  actual.eat?(:cheese)
 end
end



RSpec::Matchers.define :eat_cheese do
 match do |actual|
  actual.eat?(:cheese)
 end
end
RSpec::Matchers.define :eat_cheese do
 match do |actual|
  actual.should eat?(:cheese)
 end
end

RSpec::Matchers.define :eat_cheese do
 include MyCheesyAssertions
 match_unless_raises
Test::Unit::AssertionFailedError do |actual|
  assert_eats_chesse actual
 end
end
RSpec 1.x -> 2.0 の変更点

Mais conteúdo relacionado

Mais procurados

Mais procurados (9)

Extracting ruby gem
Extracting ruby gemExtracting ruby gem
Extracting ruby gem
 
My GAE apps.
My GAE apps.My GAE apps.
My GAE apps.
 
DataEngConf SF16 - Routing Billions of Analytics Events with High Deliverability
DataEngConf SF16 - Routing Billions of Analytics Events with High DeliverabilityDataEngConf SF16 - Routing Billions of Analytics Events with High Deliverability
DataEngConf SF16 - Routing Billions of Analytics Events with High Deliverability
 
Auto Build
Auto BuildAuto Build
Auto Build
 
搭建高品質開源項目的應用實踐
搭建高品質開源項目的應用實踐搭建高品質開源項目的應用實踐
搭建高品質開源項目的應用實踐
 
ZfDayIt 2014 - There is a module for everything
ZfDayIt 2014 - There is a module for everythingZfDayIt 2014 - There is a module for everything
ZfDayIt 2014 - There is a module for everything
 
Explore the Rake Gem
Explore the Rake GemExplore the Rake Gem
Explore the Rake Gem
 
Break through the serverless barriers with Durable Functions
Break through the serverless barriers with Durable FunctionsBreak through the serverless barriers with Durable Functions
Break through the serverless barriers with Durable Functions
 
bengar
bengarbengar
bengar
 

Destaque

Implicacións éticas do coñecemento da pegada xenética
Implicacións éticas do coñecemento da pegada xenéticaImplicacións éticas do coñecemento da pegada xenética
Implicacións éticas do coñecemento da pegada xenética
ccmundocontemporaneo
 
FlexUnit4でテスト駆動開発
FlexUnit4でテスト駆動開発FlexUnit4でテスト駆動開発
FlexUnit4でテスト駆動開発
theworldinunion
 
Implicacións éticas do coñecemento da pegada xenética
Implicacións éticas do coñecemento da pegada xenéticaImplicacións éticas do coñecemento da pegada xenética
Implicacións éticas do coñecemento da pegada xenética
ccmundocontemporaneo
 
Implicacións eticas pegada_xenetica
Implicacións eticas pegada_xeneticaImplicacións eticas pegada_xenetica
Implicacións eticas pegada_xenetica
ccmundocontemporaneo
 

Destaque (16)

Read 96
Read 96Read 96
Read 96
 
Orixe humanos
Orixe humanosOrixe humanos
Orixe humanos
 
ΤΕΙ Θεσσαλονίκης, Τμήμα Μηχανικών Πληροφορικής: Μεταπτυχιακό Πρόγραμμα Σπουδώ...
ΤΕΙ Θεσσαλονίκης, Τμήμα Μηχανικών Πληροφορικής: Μεταπτυχιακό Πρόγραμμα Σπουδώ...ΤΕΙ Θεσσαλονίκης, Τμήμα Μηχανικών Πληροφορικής: Μεταπτυχιακό Πρόγραμμα Σπουδώ...
ΤΕΙ Θεσσαλονίκης, Τμήμα Μηχανικών Πληροφορικής: Μεταπτυχιακό Πρόγραμμα Σπουδώ...
 
A célula e o adn
A célula   e o  adnA célula   e o  adn
A célula e o adn
 
Σύντομη εισαγωγή στην τεχνολογία GPU και την CUDA
Σύντομη εισαγωγή στην τεχνολογία GPU και την CUDAΣύντομη εισαγωγή στην τεχνολογία GPU και την CUDA
Σύντομη εισαγωγή στην τεχνολογία GPU και την CUDA
 
Cosmovisão guia 01
Cosmovisão guia 01Cosmovisão guia 01
Cosmovisão guia 01
 
Flak
FlakFlak
Flak
 
Implicacións éticas do coñecemento da pegada xenética
Implicacións éticas do coñecemento da pegada xenéticaImplicacións éticas do coñecemento da pegada xenética
Implicacións éticas do coñecemento da pegada xenética
 
Xeomorfoloxia
XeomorfoloxiaXeomorfoloxia
Xeomorfoloxia
 
FlexUnit4でテスト駆動開発
FlexUnit4でテスト駆動開発FlexUnit4でテスト駆動開発
FlexUnit4でテスト駆動開発
 
Ek4
Ek4Ek4
Ek4
 
Μοντέλο Client/Server, Διαδικτυακές υπηρεσίες και Cloud computing
Μοντέλο Client/Server, Διαδικτυακές υπηρεσίες και Cloud computingΜοντέλο Client/Server, Διαδικτυακές υπηρεσίες και Cloud computing
Μοντέλο Client/Server, Διαδικτυακές υπηρεσίες και Cloud computing
 
Swiz フレームワーク for Flex and Actionscript
Swiz フレームワーク for Flex and ActionscriptSwiz フレームワーク for Flex and Actionscript
Swiz フレームワーク for Flex and Actionscript
 
Implicacións éticas do coñecemento da pegada xenética
Implicacións éticas do coñecemento da pegada xenéticaImplicacións éticas do coñecemento da pegada xenética
Implicacións éticas do coñecemento da pegada xenética
 
Implicacións eticas pegada_xenetica
Implicacións eticas pegada_xeneticaImplicacións eticas pegada_xenetica
Implicacións eticas pegada_xenetica
 
Σύντομη εισαγωγή στο MapReduce
Σύντομη εισαγωγή στο MapReduceΣύντομη εισαγωγή στο MapReduce
Σύντομη εισαγωγή στο MapReduce
 

Semelhante a RSpec 1.x -> 2.0 の変更点

A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
旻琦 潘
 
Complet vector.dep.inc# This code depends on make tool being .docx
Complet vector.dep.inc# This code depends on make tool being .docxComplet vector.dep.inc# This code depends on make tool being .docx
Complet vector.dep.inc# This code depends on make tool being .docx
ardhowp
 

Semelhante a RSpec 1.x -> 2.0 の変更点 (20)

RSpec 3.0: Under the Covers
RSpec 3.0: Under the CoversRSpec 3.0: Under the Covers
RSpec 3.0: Under the Covers
 
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, PuppetPuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
 
#CNX14 - Using Ruby for Reliability, Consistency, and Speed
#CNX14 - Using Ruby for Reliability, Consistency, and Speed#CNX14 - Using Ruby for Reliability, Consistency, and Speed
#CNX14 - Using Ruby for Reliability, Consistency, and Speed
 
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Cox
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
 
Complet vector.dep.inc# This code depends on make tool being .docx
Complet vector.dep.inc# This code depends on make tool being .docxComplet vector.dep.inc# This code depends on make tool being .docx
Complet vector.dep.inc# This code depends on make tool being .docx
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
2010 Smith Scripting101
2010 Smith Scripting1012010 Smith Scripting101
2010 Smith Scripting101
 
Does your configuration code smell?
Does your configuration code smell?Does your configuration code smell?
Does your configuration code smell?
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 
test ppt
test ppttest ppt
test ppt
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt21
ppt21ppt21
ppt21
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt17
ppt17ppt17
ppt17
 
ppt30
ppt30ppt30
ppt30
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
 

Último

Último (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

RSpec 1.x -> 2.0 の変更点

  • 1. Chiew Chung @theworldinunion Edward Middleton @e14n
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 10.
  • 11. RSpec.configure do |c| # .... command line ./.rspec ~/.rspec
  • 12. describe "something" do context "in some context" do it "does something" do # ... end end end
  • 13.
  • 14.
  • 15. # in spec/spec_helper.rb RSpec.configure do |c| c.filter_run :focus => true end # in any spec file describe "something" do it "does something", :focus => true do # .... end end
  • 16. RSpec.configure do |c| c.filter_run :focus => true c.run_all_when_everything_filtered = true end
  • 17. # in spec/spec_helper.rb RSpec.configure do |c| c.exclusion_filter = { :ruby => lambda {|version| !(RUBY_VERSION.to_s =~ /^#{version.to_s}/) }} end # in any spec file describe "something" do it "does something", :ruby => 1.8 do # .... end it "does something", :ruby => 1.9 do # .... end end
  • 18.
  • 19.
  • 20. actual.should == expected # object equality actual.should equal(expected) # object identity actual.should eq(expected) # object equality actual.should be(expected) # object identity
  • 21.
  • 22. def eat_cheese simple_matcher("eat cheese") do |actual| actual.eat?(:cheese) end end RSpec::Matchers.define :eat_cheese do match do |actual| actual.eat?(:cheese) end end
  • 23. RSpec::Matchers.define :eat_cheese do match do |actual| actual.should eat?(:cheese) end end RSpec::Matchers.define :eat_cheese do include MyCheesyAssertions match_unless_raises Test::Unit::AssertionFailedError do |actual| assert_eats_chesse actual end end