Sha256: 1eb8e1fc20564ee689905ac34e2a4974b50298159fd9f1f8093d6bd3fc499e60

Contents?: true

Size: 1.06 KB

Versions: 10

Compression:

Stored size: 1.06 KB

Contents

require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')

class AssignToMatcherTest < Test::Unit::TestCase # :nodoc:

  context "a controller that assigns to an instance variable" do
    setup do
      @controller = build_response { @var = 'value' }
    end

    should "accept assigning to that variable" do
      assert_accepts assign_to(:var), @controller
    end

    should "accept assigning to that variable with the correct class" do
      assert_accepts assign_to(:var).with_kind_of(String), @controller
    end

    should "reject assigning to that variable with another class" do
      assert_rejects assign_to(:var).with_kind_of(Fixnum), @controller
    end

    should "accept assigning the correct value to that variable" do
      assert_accepts assign_to(:var).with('value'), @controller
    end

    should "reject assigning another value to that variable" do
      assert_rejects assign_to(:var).with('other'), @controller
    end

    should "reject assigning to another variable" do
      assert_rejects assign_to(:other), @controller
    end
  end

end

Version data entries

10 entries across 10 versions & 5 rubygems

Version Path
Flamefork-shoulda-2.10.1 test/matchers/controller/assign_to_matcher_test.rb
Flamefork-shoulda-2.10.2 test/matchers/controller/assign_to_matcher_test.rb
francois-shoulda-2.10.1 test/matchers/controller/assign_to_matcher_test.rb
technicalpickles-shoulda-2.10.0 test/matchers/controller/assign_to_matcher_test.rb
thoughtbot-shoulda-2.10.0 test/matchers/controller/assign_to_matcher_test.rb
thoughtbot-shoulda-2.10.1 test/matchers/controller/assign_to_matcher_test.rb
thoughtbot-shoulda-2.9.2 test/matchers/controller/assign_to_matcher_test.rb
shoulda-2.9.2 test/matchers/controller/assign_to_matcher_test.rb
shoulda-2.10.0 test/matchers/controller/assign_to_matcher_test.rb
shoulda-2.10.1 test/matchers/controller/assign_to_matcher_test.rb