Skip to content

Commit

Permalink
Improve test coverage for allow_values_for.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jul 17, 2009
1 parent b36b960 commit 36cd656
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion remarkable_activerecord/spec/allow_values_for_matcher_spec.rb
Expand Up @@ -59,13 +59,27 @@ def define_and_validate(options={})
end

describe 'failures' do
it "should fail if any of the values are valid on invalid cases" do
before(:each) do
define_and_validate(:with => /X|Y|Z/)
end

it "should fail if any of the values are valid on invalid cases" do
lambda {
should_not allow_values_for :title, 'A', 'X', 'B'
}.should raise_error(Spec::Expectations::ExpectationNotMetError, /Did not expect Product to be valid/)
end

it "should also fail if all values are valid" do
lambda {
should_not allow_values_for :title, 'X', 'Y', 'Z'
}.should raise_error(Spec::Expectations::ExpectationNotMetError, /Did not expect Product to be valid/)
end

it "should not fail if all values are invalid" do
lambda {
should_not allow_values_for :title, 'A', 'B', 'C'
}.should_not raise_error
end
end
end

0 comments on commit 36cd656

Please sign in to comment.