1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
thoughtbot--shoulda-matchers/spec/shoulda/action_controller/set_session_matcher_spec.rb
2010-12-15 17:34:19 -05:00

48 lines
1.4 KiB
Ruby

require 'spec_helper'
describe Shoulda::Matchers::ActionController::SetSessionMatcher do
context "a controller that sets a session variable" do
before do
@controller = build_response do
session[:var] = 'value'
session[:false_var] = false
end
end
it "should accept assigning to that variable" do
@controller.should set_session(:var)
end
it "should accept assigning the correct value to that variable" do
@controller.should set_session(:var).to('value')
end
it "should reject assigning another value to that variable" do
@controller.should_not set_session(:var).to('other')
end
it "should reject assigning to another variable" do
@controller.should_not set_session(:other)
end
it "should accept assigning nil to another variable" do
@controller.should set_session(:other).to(nil)
end
it "should accept assigning false to that variable" do
@controller.should set_session(:false_var).to(false)
end
it "should accept assigning to the same value in the test context" do
@expected = 'value'
@controller.should set_session(:var).in_context(self).to { @expected }
end
it "should reject assigning to the another value in the test context" do
@expected = 'other'
@controller.should_not set_session(:var).in_context(self).to { @expected }
end
end
end