|
415 | 415 | end |
416 | 416 | end |
417 | 417 |
|
| 418 | + describe "attribute access methods" do |
| 419 | + it "supports [] method with symbol" do |
| 420 | + model = mock_model(MockableModel, :name => "John", :age => 25) |
| 421 | + expect(model[:name]).to eq("John") |
| 422 | + expect(model[:age]).to eq(25) |
| 423 | + end |
| 424 | + |
| 425 | + it "supports [] method with string" do |
| 426 | + model = mock_model(MockableModel, :name => "John", :age => 25) |
| 427 | + expect(model["name"]).to eq("John") |
| 428 | + expect(model["age"]).to eq(25) |
| 429 | + end |
| 430 | + |
| 431 | + it "supports read_attribute method with symbol" do |
| 432 | + model = mock_model(MockableModel, :name => "John", :age => 25) |
| 433 | + expect(model.read_attribute(:name)).to eq("John") |
| 434 | + expect(model.read_attribute(:age)).to eq(25) |
| 435 | + end |
| 436 | + |
| 437 | + it "supports read_attribute method with string" do |
| 438 | + model = mock_model(MockableModel, :name => "John", :age => 25) |
| 439 | + expect(model.read_attribute("name")).to eq("John") |
| 440 | + expect(model.read_attribute("age")).to eq(25) |
| 441 | + end |
| 442 | + |
| 443 | + it "supports _read_attribute method with symbol" do |
| 444 | + model = mock_model(MockableModel, :name => "John", :age => 25) |
| 445 | + expect(model._read_attribute(:name)).to eq("John") |
| 446 | + expect(model._read_attribute(:age)).to eq(25) |
| 447 | + end |
| 448 | + |
| 449 | + it "supports _read_attribute method with string" do |
| 450 | + model = mock_model(MockableModel, :name => "John", :age => 25) |
| 451 | + expect(model._read_attribute("name")).to eq("John") |
| 452 | + expect(model._read_attribute("age")).to eq(25) |
| 453 | + end |
| 454 | + end |
| 455 | + |
418 | 456 | describe "ActiveModel Lint tests" do |
419 | 457 | begin |
420 | 458 | require 'minitest/assertions' |
|
0 commit comments