Last active
December 14, 2015 13:19
-
-
Save jfredett/5092389 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#command_factory_spec.rb: | |
require 'spec_helper' | |
describe CommandFactory do | |
let(:factory) { CommandFactory.new nil } | |
subject { factory.command(:foo) } | |
context 'a thing' do | |
it_behaves_like "a command" | |
end | |
end | |
# shared_examples_for_commands.rb: | |
shared_examples "a command" do | |
# your way (fixed) | |
#it "should respond to execute" do | |
# subject.should respond_to(:execute) | |
#end | |
#better way | |
it { should respond_to :execute } | |
# similar | |
#it "should respond to unexecute" do | |
# subject.should respond_to(:unexecute) | |
#end | |
# better | |
it { should respond_to :unexecute } | |
end |
context "Creates commands which:" do
subject { factory.command(:foo) }
it_behaves_like "a command"
end
CommandFactory
Creates commands which:
behaves like a command
should respond to #execute
should respond to #unexecute
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I run this I get:
CommandFactory
behaves like a command
should respond to #execute
should respond to #unexecute
The idea of the it block so I could get:
CommandFactory
Creates commands which:
behaves like a command
should respond to #execute
should respond to #unexecute