Skip to content

Instantly share code, notes, and snippets.

@stevegraham
Forked from markburns/example_spec.rb
Last active December 12, 2015 02:18
Show Gist options
  • Save stevegraham/4696944 to your computer and use it in GitHub Desktop.
Save stevegraham/4696944 to your computer and use it in GitHub Desktop.
subject { App.new }
App::PURPOSES.each do |p,_|
context do
before { subject.purpose = p }
its(:purpose){ should == p }
end
end
App::PLATFORMS.each do |p,_|
context do
before { subject.platform = p }
its(:platform){ should == p }
end
end
let(:app) { App.new }
%w(purpose platform).each do |meth|
describe "#{meth}=" do
App.const_get(meth.pluralize.upcase).each do |attribute,_|
it "accepts #{attribute} as a valid value" do
app.send "#{meth}=", attribute
app.send(meth).should == attribute
end
end
end
end
@stevegraham
Copy link
Author

nice one burns. i've changed mine.

  • i like the underscore block var.
  • yours is very clean but i prefer not to set platform in the before block as its the functionality being tested.
  • what's yours look like run with the documentation formatter?
  • the way this project changes another attribute similar to platform and purpose will be added. all i have to do is thype one word to get the extra test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment