class ComplexNumberArithmeticEditForm < ActiveForm
- acts_as_problem :operators => %w[+ - * /], :term_number => true
+ acts_as_problem :operators => %w[plus minus times fraction], :term_number => true
column :min, :type => :integer
column :max, :type => :integer
def options_hash
{
- :minus => minus,
:min => min,
:max => max,
:fractional_mode => fractional_mode,
def set_options(options)
hash = ActiveSupport::JSON.decode(options)
- self.minus = hash["minus"]
self.min = hash["min"]
self.max = hash["max"]
self.fractional_mode = hash["fractional_mode"]
describe ComplexNumberArithmeticEditForm do
before do
@valid_attributes = {
- :unit_id => 1,
- :level => 1,
- :amount => 2,
- :min => 0,
- :max => 100,
- :fractional_mode => false,
- :term_number => 2,
- :operators_plus => true,
- :operators_minus => true,
- :operators_times => true,
-# :operators_div => true,
+ :unit_id => 1,
+ :level => 1,
+ :amount => 2,
+ :min => 0,
+ :max => 100,
+ :fractional_mode => false,
+ :term_number => 2,
+ :operators_plus => true,
+ :operators_minus => true,
+ :operators_times => true,
+ :operators_fraction => true,
}
@klass = ComplexNumberArithmeticEditForm
@basic = @klass.new(@valid_attributes)
@basic.operators_plus = false
@basic.operators_minus = false
@basic.operators_times = false
- # @basic.operators_div = false
+ @basic.operators_fraction = false
@basic
}
it{ should_not be_valid }
:min => 1, :max => 99,
:fractional_mode => true,
:term_number => 3,
- :operators => %w[+ - * div]
+ :operators => %w[+ - * /]
}
@basic.set_options(options.to_json)
@basic
its(:operators_plus){ should be_true }
its(:operators_minus){ should be_true }
its(:operators_times){ should be_true }
- its(:operators_div){ should be_true }
+ its(:operators_fraction){ should be_true }
end
context "set nothing" do
it "should not raise Exception" do