Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Cyril Kato cyril

🏠
Working from home
View GitHub Profile
@cyril
cyril / test-fix-isolation.rb
Last active Nov 3, 2015
Test Fix's isolation
View test-fix-isolation.rb
require 'fix'
greeting = 'Hello, world!'
Fix.describe greeting do
context do
on :gsub!, 'world', 'Alice' do
it { MUST eql 'Hello, Alice!' }
end
end
@cyril
cyril / test-rspec-isolation.rb
Last active Oct 13, 2015
Test RSpec's isolation
View test-rspec-isolation.rb
require 'rspec'
greeting = 'Hello, world!'
RSpec.describe 'Test' do
context 'Alice' do
before { greeting.gsub!('world', 'Alice') }
it { expect(greeting).to eql 'Hello, Alice!' }
end
@cyril
cyril / test-spectus-isolation.rb
Last active Nov 3, 2015
Test Spectus's isolation
View test-spectus-isolation.rb
require 'spectus'
include Spectus
greeting = 'Hello, world!'
it { greeting.gsub!('world', 'Alice') }.MUST! eql 'Hello, Alice!'
it { greeting.gsub!('world', 'Bob') }.MUST! eql 'Hello, Bob!'
@cyril
cyril / running-spectus-in-your-ruby-project-or-library.rb
Created Sep 12, 2015
Running Spectus Specs In Your Ruby Project / Library
View running-spectus-in-your-ruby-project-or-library.rb
require 'spectus'
require 'rake/testtask'
Rake::TestTask.new do |t|
t.verbose = true
t.warning = true
t.pattern = File.join('test', '**', 'test_*.rb')
end
task default: :test
@cyril
cyril / spectus-exemple-optional.rb
Last active Nov 1, 2015
An optional requirement of the specification in Spectus.
View spectus-exemple-optional.rb
include Spectus
it { 'foo'.blank? }.MAY be_false
# => #<Spectus::Result::Pass:0x007f81dc591770 @message="Info: undefined method `blank?' for \"foo\":String (NoMethodError).", @subject=#<Proc:0x007f81dc591c20@(irb):7>, @challenge=#<Defi::Challenge:0x007f81dc591ba8 @method=:call, @args=[]>, @actual=nil, @expected=#<Matchi::BeFalse:0x007f81dc591b08>, @got=nil, @error=#<NoMethodError: undefined method `blank?' for "foo":String>, @level=:Low, @negate=false, @valid=false>
@cyril
cyril / spectus-exemple-not-recommended.rb
Last active Nov 1, 2015
A not recommended requirement of the specification in Spectus.
View spectus-exemple-not-recommended.rb
@cyril
cyril / spectus-exemple-recommended.rb
Last active Nov 1, 2015
A recommended requirement of the specification in Spectus.
View spectus-exemple-recommended.rb
@cyril
cyril / spectus-exemple-absolute-prohibition.rb
Last active Nov 1, 2015
An absolute prohibition of the specification in Spectus.
View spectus-exemple-absolute-prohibition.rb
include Spectus
it { 'foo'.length }.MUST_NOT raise_exception NoMethodError
# => #<Spectus::Result::Pass:0x007f81dd8fad70 @message="Pass: Expected 3 not to raise_exception NoMethodError.", @subject=#<Proc:0x007f81dd8fb180@(irb):4>, @challenge=#<Defi::Challenge:0x007f81dd8fb108 @method=:call, @args=[]>, @actual=3, @expected=#<Matchi::RaiseException:0x007f81dd8fb040 @expected=NoMethodError>, @got=true, @error=nil, @level=:High, @negate=true, @valid=true>
@cyril
cyril / spectus-exemple-absolute-requirement.rb
Last active Nov 1, 2015
An absolute requirement of the specification in Spectus.
View spectus-exemple-absolute-requirement.rb
include Spectus
it { 'ルビー'.valid_encoding? }.MUST be_true
# => #<Spectus::Result::Pass:0x007f81dbadd248 @message="Pass: Expected true to be_true.", @subject=#<Proc:0x007f81dbadd630@(irb):3>, @challenge=#<Defi::Challenge:0x007f81dbadd5b8 @method=:call, @args=[]>, @actual=true, @expected=#<Matchi::BeTrue:0x007f81dbadd518>, @got=true, @error=nil, @level=:High, @negate=false, @valid=true>
@cyril
cyril / monster_fix_spec.rb
Last active Feb 28, 2016
Fix spec of monster.rb
View monster_fix_spec.rb
require_relative 'monster'
require 'fix'
Fix.describe Monster do
on :get do
on :keys do
it { MUST eql %i(boo hasu) }
end
end
You can’t perform that action at this time.