Hm, I am confused too. Which part i need to change? Not sure from where the symbol is coming though.
On Tuesday, May 14, 2019 at 7:32:57 PM UTC+5:30, Jon Rowe wrote: > > I believe you still need to defined expected, also I think you have > `actual` and `@second` the wrong way around in your description. > > Jon Rowe > --------------------------- > [email protected] <javascript:> > jonrowe.co.uk > > On 14 May 2019 at 09:29, Arup Rakshit wrote: > > Hello Jon, > > Thanks for your reply. > > I modified it as: > > RSpec::Matchers.define :have_constant do |const| > match do |owner| > @actual = owner.const_defined?(const) && owner.const_get(const) > @expected = @second > owner.const_defined?(const) && owner.const_get(const) == @second > end > > chain :with_value do |second| > @second = second > end > > diffable > > failure_message do |actual| > "expected that #{const} would be defined with #{actual} but got > #{@second}" > end > end > > Now the error message is close, but not quiet correct. > > Failures: > > 1) FeatureService constants should have constant > :TABLE_OF_PREVIOUS_INSPECTIONS with value "3oelqiFW1" > Failure/Error: it { is_expected.to > have_constant(:TABLE_OF_PREVIOUS_INSPECTIONS).with_value('3oelqiFW1') } > > expected that TABLE_OF_PREVIOUS_INSPECTIONS would be defined with > 3oelqiFW but got 3oelqiFW1 > Diff: > @@ -1,2 +1,2 @@ > -:TABLE_OF_PREVIOUS_INSPECTIONS > +"3oelqiFW" > > I want it to be like: > > Failures: > > 1) FeatureService constants should have constant > :TABLE_OF_PREVIOUS_INSPECTIONS with value "3oelqiFW1" > Failure/Error: it { is_expected.to > have_constant(:TABLE_OF_PREVIOUS_INSPECTIONS).with_value('3oelqiFW1') } > > expected that TABLE_OF_PREVIOUS_INSPECTIONS would be defined with > 3oelqiFW but got 3oelqiFW1 > Diff: > @@ -1,2 +1,2 @@ > -"3oelqiFW1" > +"3oelqiFW" > > What needs to be tweaked ? > > > On Monday, May 13, 2019 at 2:39:27 PM UTC+5:30, Jon Rowe wrote: > > -- You received this message because you are subscribed to the Google Groups "rspec" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/02bf10e2-e406-48a9-b45e-6609f395d448%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
